3 # additional macvlan interface for lxc
7 # check if all required configurations have been set
8 # Source any configurable options
9 test ! -r /etc/sysconfig/lxc_macvlan ||
10 . /etc/sysconfig/lxc_macvlan
12 # Tests for data provided in /etc/sysconfig/lxc_macvlan
13 if [ -z "$MACVLAN_DEV" ]; then
14 echo "MACVLAN_DEV not set is /etc/sysconfig/lxc_macvlan"
18 if [ -z "$MACVLAN_NAME" ]; then
19 echo "MACVLAN_NAME not set is /etc/sysconfig/lxc_macvlan"
23 if [ -z "$MACVLAN_ADDRESS" ]; then
24 echo "MACVLAN_ADDRESS not set is /etc/sysconfig/lxc_macvlan"
29 macvlan_gen_default_hwaddr(){
30 # If not defined MACVLAN_HWADDRESS, calculate it from MACVLAN_ADDRESS
31 echo $MACVLAN_ADDRESS | awk -F "/" '{print $1}' | awk -F "." '{ printf "00:16:3e:%x:%x:%x\n", $2, $3, $4 }'
35 echo "LXC macvlan interface start"
39 if [ -z "$MACVLAN_HWADDRESS" ]; then
40 MACVLAN_HWADDRESS=`macvlan_gen_default_hwaddr`
42 ip link add link $MACVLAN_DEV name $MACVLAN_NAME address $MACVLAN_HWADDRESS type macvlan mode bridge
43 ip link set $MACVLAN_NAME up
44 ip address add $MACVLAN_ADDRESS brd + dev $MACVLAN_NAME
48 echo "LXC macvlan interface stop"
52 ip link set $MACVLAN_NAME down
53 ip link del $MACVLAN_NAME
57 echo "LXC macvlan interface status"
61 ip addr show $MACVLAN_NAME