* Set up a 6to4 tunnel on cartman.
svn path=/configurations/trunk/tud/; revision=26224
Eelco Dolstra committed
Mar 9, 2011 at 11:49 UTC
9c0ef9154a0bed1c6abf6dfe8d4742074923d606
1 file changed
+23
-5
cartman.nix
+23
-5
@@ -87,9 +87,9 @@ rec {
87
extraHosts = "192.168.1.5 cartman";
88
89
localCommands =
90
- # Provide NATting for the build machines on 192.168.1.*.
91
- # Obviously, this should be something that NixOS provides.
90
''
91
+ # Provide NATting for the build machines on 192.168.1.*.
92
+ # Obviously, this should be something that NixOS provides.
93
export PATH=${pkgs.iptables}/sbin:$PATH
94
95
modprobe ip_tables
@@ -103,13 +103,31 @@ rec {
103
iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -d 192.168.1.0/24 -j ACCEPT
104
iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -j SNAT --to-source ${myIP}
105
106
- # stan ssh (for the SCM seminar)
107
- iptables -t nat -A PREROUTING -p tcp -i eth1 --dport 2222 -j DNAT --to 192.168.1.20:22
108
-
106
# lucifer ssh (to give Karl/Armijn access for the BAT project)
107
iptables -t nat -A PREROUTING -p tcp -i eth1 --dport 22222 -j DNAT --to 192.168.1.25:22
108
109
echo 1 > /proc/sys/net/ipv4/ip_forward
110
+
111
+ # Set up a 6to4 tunnel for IPv6 connectivity.
112
+
113
+ # cleanup
114
+ ip -6 route flush dev tun6to4
115
+ ip link set dev tun6to4 down
116
+ ip tunnel del tun6to4
117
+
118
+ # compute 6to4 address
119
+ prefix6=$(printf "2002:%02x%02x:%02x%02x\n" $(echo ${myIP} | tr . ' '))
120
+ addr6="$prefix6"::1
121
+
122
+ # set up the tunnel
123
+ ip tunnel add tun6to4 mode sit remote any local ${myIP}
124
+ ip link set dev tun6to4 mtu 1472 up
125
+ ip -6 addr add $addr6/16 dev tun6to4
126
+ ip -6 route add ::/96 dev tun6to4 metric 1
127
+ ip -6 route add 2000::/3 via ::192.88.99.1 dev tun6to4 metric 1
128
+
129
+ # enable forwarding for the rest of the network
130
+ ip -6 route add $prefix6::/64 dev eth0
131
'';
132
};
133