-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathzeth-vlan.conf
62 lines (46 loc) · 1.78 KB
/
zeth-vlan.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
# Configuration file for setting IP addresses for a network interface
# and setting up two VLANs and one non-VLAN interfaces.
INTERFACE="$1"
HWADDR="00:00:5e:00:53:ff"
VLAN_NAME_PREFIX="vlan"
VLAN_1_ID=100
VLAN_2_ID=200
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"
IPV6_ADDR_1="2001:db8::2"
IPV6_ROUTE_1="2001:db8::/64"
IPV4_ADDR_1="192.0.2.2/24"
IPV4_ROUTE_1="192.0.2.0/24"
ip link set dev ${INTERFACE} up
ip link set dev ${INTERFACE} address ${HWADDR}
ip -6 address add ${IPV6_ADDR_1} dev ${INTERFACE}
ip -6 route add ${IPV6_ROUTE_1} dev ${INTERFACE}
ip address add ${IPV4_ADDR_1} dev ${INTERFACE}
ip route add ${IPV4_ROUTE_1} dev ${INTERFACE}
ip link add link ${INTERFACE} name ${VLAN_NAME_PREFIX}.${VLAN_1_ID} \
type vlan id ${VLAN_1_ID}
ip link add link ${INTERFACE} name ${VLAN_NAME_PREFIX}.${VLAN_2_ID} \
type vlan id ${VLAN_2_ID}
ip link set ${VLAN_NAME_PREFIX}.${VLAN_1_ID} up
ip link set ${VLAN_NAME_PREFIX}.${VLAN_2_ID} up
ip -6 addr add ${PREFIX_1_IPV6}::2 dev ${VLAN_NAME_PREFIX}.${VLAN_1_ID}
ip -6 route add ${PREFIX_1_IPV6}::/${PREFIXLEN_1_IPV6} \
dev ${VLAN_NAME_PREFIX}.${VLAN_1_ID}
ip -6 addr add ${PREFIX_2_IPV6}::2 dev ${VLAN_NAME_PREFIX}.${VLAN_2_ID}
ip -6 route add ${PREFIX_2_IPV6}::/${PREFIXLEN_2_IPV6} \
dev ${VLAN_NAME_PREFIX}.${VLAN_2_ID}
ip addr add ${PREFIX_1_IPV4}.2/${PREFIXLEN_1_IPV4} \
dev ${VLAN_NAME_PREFIX}.${VLAN_1_ID}
ip route add ${PREFIX_1_IPV4}/${PREFIXLEN_1_IPV4} \
dev ${VLAN_NAME_PREFIX}.${VLAN_1_ID}
ip addr add ${PREFIX_2_IPV4}.2/${PREFIXLEN_2_IPV4} \
dev ${VLAN_NAME_PREFIX}.${VLAN_2_ID}
ip route add ${PREFIX_2_IPV4}/${PREFIXLEN_2_IPV4} \
dev ${VLAN_NAME_PREFIX}.${VLAN_2_ID}