Skip to content

Instantly share code, notes, and snippets.

@l0rzl
Last active April 24, 2022 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save l0rzl/8c7d2974bbf8031f5a6c0aeac76c26dd to your computer and use it in GitHub Desktop.
Save l0rzl/8c7d2974bbf8031f5a6c0aeac76c26dd to your computer and use it in GitHub Desktop.
DS-Lite tunnel setup for Xpass
#!/bin/sh
srcaddr=$(ifconfig hn0 | grep -o '2001:f[67][0-9a-f:]*')
dstaddr=$(drill dgw.xpass.jp aaaa | grep -o '2001:f[67][0-9a-f:]*')
ifconfig gif0 create
ifconfig gif0 inet6 -accept_rtadv -auto_linklocal tunnel $srcaddr $dstaddr
ifconfig gif0 up mtu 1500
route -4 delete default
route -4 add default -interface gif0 -mtu 1240
sysctl net.inet.ip.forwarding=1
ifconfig gif0
route -4 get default
root@localhost:/home/user# tcpdump -ttttt -vvv icmp
tcpdump: listening on venet0, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes
# [via PPPoE(IPv4)]
# ping -c 1 -D -s 1428 xxx.xxx.xxx.xxx => NG
# ping -c 1 -D -s 1426 xxx.xxx.xxx.xxx => OK
00:00:05.126369 IP (tos 0x0, ttl 111, id 39682, offset 0, flags [DF], proto ICMP (1), length 1454)
120.51.***.*** > xxx.xxx.xxx.xxx: ICMP echo request, id 1, seq 811, length 1434
00:00:05.126410 IP (tos 0x0, ttl 64, id 55537, offset 0, flags [none], proto ICMP (1), length 1454)
xxx.xxx.xxx.xxx > 120.51.***.***: ICMP echo reply, id 1, seq 811, length 1434
# ping -c 1 -s 2000 xxx.xxx.xxx.xxx => OK
00:00:31.921976 IP (tos 0x0, ttl 111, id 39683, offset 0, flags [+], proto ICMP (1), length 1452)
120.51.***.*** > xxx.xxx.xxx.xxx: ICMP echo request, id 1, seq 812, length 1432
00:00:31.921982 IP (tos 0x0, ttl 111, id 39683, offset 1432, flags [none], proto ICMP (1), length 596)
120.51.***.*** > xxx.xxx.xxx.xxx: icmp
00:00:31.922031 IP (tos 0x0, ttl 64, id 55538, offset 0, flags [+], proto ICMP (1), length 1500)
xxx.xxx.xxx.xxx > 120.51.***.***: ICMP echo reply, id 1, seq 812, length 1480
00:00:31.922035 IP (tos 0x0, ttl 64, id 55538, offset 1480, flags [none], proto ICMP (1), length 548)
xxx.xxx.xxx.xxx > 120.51.***.***: icmp
# [via IPoE(IPv6)]
# ping -c 1 -s 2000 xxx.xxx.xxx.xxx => OK
00:03:12.671615 IP (tos 0x0, ttl 108, id 44382, offset 0, flags [+], proto ICMP (1), length 1500)
133.32.***.*** > xxx.xxx.xxx.xxx: ICMP echo request, id 25381, seq 813, length 1480
00:03:12.671621 IP (tos 0x0, ttl 108, id 44382, offset 1480, flags [none], proto ICMP (1), length 548)
133.32.***.*** > xxx.xxx.xxx.xxx: icmp
00:03:12.671673 IP (tos 0x0, ttl 64, id 54399, offset 0, flags [+], proto ICMP (1), length 1500)
xxx.xxx.xxx.xxx > 133.32.***.***: ICMP echo reply, id 25381, seq 813, length 1480
00:03:12.671676 IP (tos 0x0, ttl 64, id 54399, offset 1480, flags [none], proto ICMP (1), length 548)
xxx.xxx.xxx.xxx > 133.32.***.***: icmp
# ping -c 1 -D -s 1474 xxx.xxx.xxx.xxx => NG
# ping -c 1 -D -s 1472 xxx.xxx.xxx.xxx => OK
00:04:29.133829 IP (tos 0x0, ttl 108, id 44390, offset 0, flags [DF], proto ICMP (1), length 1500)
133.32.***.*** > xxx.xxx.xxx.xxx: ICMP echo request, id 25382, seq 817, length 1480
00:04:29.133875 IP (tos 0x0, ttl 64, id 54400, offset 0, flags [none], proto ICMP (1), length 1500)
xxx.xxx.xxx.xxx > 133.32.***.***: ICMP echo reply, id 25382, seq 817, length 1480
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment