Skip to content

Instantly share code, notes, and snippets.



Last active Jan 14, 2019
What would you like to do?


  • if you use android tethering, masquerade makes client device's TTL decrease.

    • so Telco can detect what packet is used with tethering.
  • this means that if your kernel doesn't decrease TTL with hop, telco can't detect tethering packet by TTL value.

    • but, there's another way to detect. however, I think that TTL is enough to use. maybe, maybe...


  • bascially tethering use 'masquerade' and it use 'ip_forward'. and it is linux's net function.

  • and, it count one hop. so ip_forward must obey ip specification. this means that decrease ttl with passing hop.

  • bingo! if decrease code is by-passed, all ok!!!

  • default TTL for android is 64. so, forwarded packet's TTL must be fixed 64.

    • default TTL can be set with sysctl. but, non-rooted device does not use that feature. so it's no worth to talk.


diff --git a/include/net/ip.h b/include/net/ip.h
index 0623529..1734ff5 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -304,7 +304,8 @@ int ip_decrease_ttl(struct iphdr *iph)
u32 check = (__force u32)iph->check;
check += (__force u32)htons(0x0100);
iph->check = (__force __sum16)(check + (check>=0xFFFF));
- return --iph->ttl;
+ iph->ttl = 64;
+ return iph->ttl;
static inline int ip_mtu_locked(const struct dst_entry *dst)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment