1# Configuration file for setting IP addresses for a network interface.
2
3INTERFACE="$1"
4DOCKER_USER_INTERFACE=net-tools0
5
6HWADDR="00:00:5e:00:53:ff"
7
8IPV6_ADDR_1="2001:db8::254"
9IPV6_ROUTE_1="2001:db8::/64"
10
11IPV4_ADDR_1="192.0.2.254"
12IPV4_ROUTE_1="192.0.2.0/24"
13
14DOCKER_INTERFACE=$( docker network create \
15		    --subnet $IPV4_ROUTE_1 \
16		    --gateway $IPV4_ADDR_1 \
17		    --ipv6=true \
18		    --subnet $IPV6_ROUTE_1 \
19		    --gateway $IPV6_ADDR_1 \
20		    $DOCKER_USER_INTERFACE )
21
22if [ $? -eq 0 ]
23then
24	DOCKER_INTERFACE="br-$(echo $DOCKER_INTERFACE | cut -c -12)"
25
26	ip link set dev $INTERFACE address $HWADDR
27
28	brctl addif $DOCKER_INTERFACE $INTERFACE
29
30	# By default the LLDP packets are not crossing the bridge interface
31	# so need to enable it here.
32	echo 16384 > /sys/class/net/${DOCKER_INTERFACE}/bridge/group_fwd_mask
33
34	ip link set dev $INTERFACE up
35else
36	DOCKER_INTERFACE=br-"$(docker network ls | \
37			 grep $DOCKER_USER_INTERFACE | \
38			 (read br rest ; echo $br) )"
39fi
40
41echo Created bridge: $DOCKER_INTERFACE
42echo Created docker net: $DOCKER_USER_INTERFACE
43