Skip to content

Commit adc56b9

Browse files
author
Charles K. Lee II
committed
initial commit
0 parents  commit adc56b9

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

README

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
This is a wrapper for OpenBSD's dhclient-script which sets up an IPv6 tunnel
2+
provided by tunnelbroker.net.
3+
4+
It is used by using the following configuration in /etc/dhclient.conf
5+
6+
interface <interface name> {
7+
script "/path/to/dhclient-script/ipv6-tunnel";
8+
}

dhclient-script-ipv6tunnel

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/sh
2+
3+
# this is a wrapper script for dhclient-script, which is called by OpenBSD's dhclient
4+
# when a DHCP event occurs. It calls dhclient-script and then follows up with
5+
# maintenance tasks to manage an IPv6 tunnel (from tunnelbroker.net).
6+
7+
# the following variables must be defined in the configuration file
8+
#HE_USER_ID
9+
#HE_TUNNEL_ID
10+
#HE_MD5_PASS
11+
#TUNNEL_IF
12+
#TUNNEL_SRV_IPV4
13+
#TUNNEL_SRV_IPV6
14+
#TUNNEL_LOCAL_IPV6
15+
16+
LOG="/home/chuckx/ipv6.log"
17+
DHCLIENT_SCRIPT="/sbin/dhclient-script"
18+
19+
CONF="/home/chuckx/code/dhclient-script-ipv6tunnel/dhclient-script-ipv6tunnel.conf"
20+
21+
# load configuration file
22+
. ${CONF}
23+
24+
# call normal dhclient-script
25+
${DHCLIENT_SCRIPT}
26+
27+
# if dhclient-script fails, follow suit
28+
if [ "$?" -eq "1" ]
29+
then
30+
exit 1
31+
fi
32+
33+
# manage IPv6 tunnel
34+
case $reason in
35+
36+
BOUND|RENEW|REBIND|REBOOT)
37+
38+
echo "IPV6 processing..." >> ${LOG}
39+
40+
# if new IP address, update tunnel service
41+
if [ "$old_ip_address" != "$new_ip_address" ]; then
42+
43+
echo "Updating tunnelbroker.net with IPv4 address" >> ${LOG}
44+
45+
wget https://ipv4.tunnelbroker.net/ipv4_end.php?ipv4b=${new_ip_address}&pass=${HE_MD_PASS}&user_id=${HE_USER_ID}&tunnel_id=${HE_TUNNEL_ID}
46+
fi
47+
48+
# setup tunnel (IPv4 end points)
49+
ifconfig ${TUNNEL_IF} tunnel ${new_ip_address} ${TUNNEL_SRV_IPV4}
50+
51+
# setup tunnel (IPv6 end points)
52+
ifconfig ${TUNNEL_IF} inet6 alias ${TUNNEL_LOCAL_IPV6} ${TUNNEL_SRV_IPV6} prefixlen 128
53+
54+
# setup IPv6 default route
55+
route -n add -inet6 default ${TUNNEL_SRV_IPV6}
56+
57+
echo "done." >> ${LOG}
58+
echo >> ${LOG}
59+
60+
;;
61+
esac
62+
63+
exit 0

0 commit comments

Comments
 (0)