1# Configuration file for setting IP addresses for a network interface 2# and setting up two VLANs and one non-VLAN interfaces. 3 4INTERFACE="$1" 5 6HWADDR="00:00:5e:00:53:ff" 7 8VLAN_NAME_PREFIX="vlan" 9VLAN_1_ID=100 10VLAN_2_ID=200 11 12PREFIX_1_IPV6="2001:db8:100" 13PREFIXLEN_1_IPV6="64" 14PREFIX_2_IPV6="2001:db8:200" 15PREFIXLEN_2_IPV6="64" 16 17# From RFC 5737 18PREFIX_1_IPV4="198.51.100" 19PREFIXLEN_1_IPV4="24" 20PREFIX_2_IPV4="203.0.113" 21PREFIXLEN_2_IPV4="24" 22 23IPV6_ADDR_1="2001:db8::2" 24IPV6_ROUTE_1="2001:db8::/64" 25 26IPV4_ADDR_1="192.0.2.2/24" 27IPV4_ROUTE_1="192.0.2.0/24" 28 29ip link set dev ${INTERFACE} up 30 31ip link set dev ${INTERFACE} address ${HWADDR} 32 33ip -6 address add ${IPV6_ADDR_1} dev ${INTERFACE} 34ip -6 route add ${IPV6_ROUTE_1} dev ${INTERFACE} 35ip address add ${IPV4_ADDR_1} dev ${INTERFACE} 36ip route add ${IPV4_ROUTE_1} dev ${INTERFACE} 37 38ip link add link ${INTERFACE} name ${VLAN_NAME_PREFIX}.${VLAN_1_ID} \ 39 type vlan id ${VLAN_1_ID} 40ip link add link ${INTERFACE} name ${VLAN_NAME_PREFIX}.${VLAN_2_ID} \ 41 type vlan id ${VLAN_2_ID} 42 43ip link set ${VLAN_NAME_PREFIX}.${VLAN_1_ID} up 44ip link set ${VLAN_NAME_PREFIX}.${VLAN_2_ID} up 45 46ip -6 addr add ${PREFIX_1_IPV6}::2 dev ${VLAN_NAME_PREFIX}.${VLAN_1_ID} 47ip -6 route add ${PREFIX_1_IPV6}::/${PREFIXLEN_1_IPV6} \ 48 dev ${VLAN_NAME_PREFIX}.${VLAN_1_ID} 49 50ip -6 addr add ${PREFIX_2_IPV6}::2 dev ${VLAN_NAME_PREFIX}.${VLAN_2_ID} 51ip -6 route add ${PREFIX_2_IPV6}::/${PREFIXLEN_2_IPV6} \ 52 dev ${VLAN_NAME_PREFIX}.${VLAN_2_ID} 53 54ip addr add ${PREFIX_1_IPV4}.2/${PREFIXLEN_1_IPV4} \ 55 dev ${VLAN_NAME_PREFIX}.${VLAN_1_ID} 56ip route add ${PREFIX_1_IPV4}/${PREFIXLEN_1_IPV4} \ 57 dev ${VLAN_NAME_PREFIX}.${VLAN_1_ID} 58 59ip addr add ${PREFIX_2_IPV4}.2/${PREFIXLEN_2_IPV4} \ 60 dev ${VLAN_NAME_PREFIX}.${VLAN_2_ID} 61ip route add ${PREFIX_2_IPV4}/${PREFIXLEN_2_IPV4} \ 62 dev ${VLAN_NAME_PREFIX}.${VLAN_2_ID} 63