Created
January 21, 2023 19:38
-
-
Save hectorm/480d7655d2a806af6398916a1ece8de0 to your computer and use it in GitHub Desktop.
Hurricane Electric IPv6 Tunnel Broker service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=he.net IPv6 tunnel | |
After=network-online.target | |
Wants=network-online.target | |
[Service] | |
Type=oneshot | |
RemainAfterExit=yes | |
Environment=SERVER_IPV4_ADDR=xxx.xxx.xxx.xxx | |
Environment=CLIENT_IPV6_ADDR=xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx/xx | |
ExecStartPre=/bin/sh -euc ' \ | |
until ip route show default | grep -qF default; do sleep 1; done' | |
ExecStart=/bin/sh -euc ' \ | |
CLIENT_IPV4_ADDR=$$(ip route show default | awk '"'"'NR==1{print($$9)}'"'"'); \ | |
ip tunnel add he-ipv6 mode sit remote "$${SERVER_IPV4_ADDR:?}" local "$${CLIENT_IPV4_ADDR:?}" ttl 255; \ | |
ip link set he-ipv6 up mtu 1480; \ | |
ip addr add "$${CLIENT_IPV6_ADDR:?}" dev he-ipv6; \ | |
ip route add ::/0 dev he-ipv6' | |
ExecStop=/bin/sh -euc ' \ | |
ip route del ::/0 dev he-ipv6; \ | |
ip link set he-ipv6 down; \ | |
ip tunnel del he-ipv6' | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment