# 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}