uncloud-mravi/network/create-bridge.sh

24 lines
471 B
Bash
Raw Normal View History

#!/bin/sh
2019-11-15 16:11:45 +00:00
if [ $# -ne 3 ]; then
echo "$0 brid dev ip"
echo "f.g. $0 100 vxlan100 fd00:/64"
echo "Missing arguments" >&2
exit 1
fi
brid=$1; shift
dev=$1; shift
2019-11-15 16:11:45 +00:00
ip=$1; shift
bridge=br${brid}
sysctl net.ipv6.conf.all.forwarding=1 > /dev/null
if ! ip link show $bridge > /dev/null 2> /dev/null; then
ip link add name $bridge type bridge
ip link set $bridge up
ip link set $dev master $bridge
2019-11-15 16:11:45 +00:00
ip address add $ip dev $bridge
fi
echo $bridge