-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathzeth-tunnel.conf
69 lines (54 loc) · 2.37 KB
/
zeth-tunnel.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Configuration file for setting IP addresses for tunneling network interfaces
INTERFACE="$1"
HWADDR="00:00:5e:00:53:ff"
# Read the "TUNNEL_VxVy" as "Vx over Vy"
TUNNEL_V4V4=${INTERFACE}-ipip
TUNNEL_V4V6=${INTERFACE}-ipip6
TUNNEL_V6V4=${INTERFACE}-ip6ip
TUNNEL_V6V6=${INTERFACE}-ip6ip6
PREFIX_1_IPV6="2001:db8:100"
PREFIXLEN_1_IPV6="64"
PREFIX_2_IPV6="2001:db8:200"
PREFIXLEN_2_IPV6="64"
# From RFC 5737
PREFIX_1_IPV4="198.51.100"
PREFIXLEN_1_IPV4="24"
PREFIX_2_IPV4="203.0.113"
PREFIXLEN_2_IPV4="24"
# Remote and local addresses for the tunnel.
IPV6_ADDR_REMOTE="2001:db8::1"
IPV6_ADDR_LOCAL="2001:db8::2"
IPV6_ROUTE_LOCAL="2001:db8::/64"
IPV4_ADDR_REMOTE="192.0.2.1"
IPV4_ADDR_LOCAL="192.0.2.2"
IPV4_ROUTE_LOCAL="192.0.2.0/24"
ip link set dev ${INTERFACE} up
ip link set dev ${INTERFACE} address ${HWADDR}
ip -6 address add ${IPV6_ADDR_LOCAL} dev ${INTERFACE}
ip -6 route add ${IPV6_ROUTE_LOCAL} dev ${INTERFACE}
ip address add ${IPV4_ADDR_LOCAL} dev ${INTERFACE}
ip route add ${IPV4_ROUTE_LOCAL} dev ${INTERFACE}
ip tunnel add name ${TUNNEL_V4V4} mode ipip local ${IPV4_ADDR_LOCAL} \
remote ${IPV4_ADDR_REMOTE} dev ${INTERFACE}
ip tunnel add name ${TUNNEL_V6V4} mode sit local ${IPV4_ADDR_LOCAL} \
remote ${IPV4_ADDR_REMOTE} dev ${INTERFACE}
ip tunnel add name ${TUNNEL_V4V6} mode ipip6 local ${IPV6_ADDR_LOCAL} \
remote ${IPV6_ADDR_REMOTE} dev ${INTERFACE}
# Create separate ip6ip6 link, otherwise the tunnel creation can fail
# (because default interface ip6tnl0 might already exist)
ip link add name ${TUNNEL_V6V6} type ip6tnl local ${IPV6_ADDR_LOCAL} \
remote ${IPV6_ADDR_REMOTE} mode ip6ip6
ip tunnel add name ${TUNNEL_V6V6} mode ip6ip6 local ${IPV6_ADDR_LOCAL} \
remote ${IPV6_ADDR_REMOTE} dev ${INTERFACE}
ip link set ${TUNNEL_V4V4} up
ip link set ${TUNNEL_V6V4} up
ip link set ${TUNNEL_V4V6} up
ip link set ${TUNNEL_V6V6} up
ip addr add ${PREFIX_1_IPV4}.2/${PREFIXLEN_1_IPV4} dev ${TUNNEL_V4V4}
ip addr add ${PREFIX_2_IPV4}.2/${PREFIXLEN_2_IPV4} dev ${TUNNEL_V4V6}
ip route add ${PREFIX_1_IPV4}/${PREFIXLEN_1_IPV4} dev ${TUNNEL_V4V4}
ip route add ${PREFIX_2_IPV4}/${PREFIXLEN_2_IPV4} dev ${TUNNEL_V4V6}
ip -6 addr add ${PREFIX_1_IPV6}::2/${PREFIXLEN_1_IPV6} dev ${TUNNEL_V6V6}
ip -6 addr add ${PREFIX_2_IPV6}::2/${PREFIXLEN_2_IPV6} dev ${TUNNEL_V6V4}
ip -6 route add ${PREFIX_1_IPV6}::/${PREFIXLEN_1_IPV6} dev ${TUNNEL_V6V6}
ip -6 route add ${PREFIX_2_IPV6}::/${PREFIXLEN_2_IPV6} dev ${TUNNEL_V6V4}