This commit is contained in:
Kroese 2023-04-20 01:52:34 +02:00 committed by GitHub
parent 5ed0553489
commit d320ee2328

View File

@ -1,4 +1,48 @@
#!/usr/bin/env bash
if [[ $EUID > 0 ]]
then echo "Run this script as root"
exit
fi
BRIDGE="br0"
TAP="tap0"
INTERFACE="eth0"
echo "Adding bridge $BRIDGE"
ip link add name $BRIDGE type bridge
echo "Flushing interface $INTERFACE"
ip addr flush dev $INTERFACE
echo "Setting $BRIDGE as master of $INTERFACE"
ip link set $INTERFACE master $BRIDGE
echo "Adding tap $TAP"
ip tuntap add $TAP mode tap
echo "Setting $BRIDGE as master of $TAP"
ip link set $TAP master $BRIDGE
echo "Setting $INTERFACE, $BRIDGE and $TAP up"
ip link set up dev $INTERFACE
ip link set up dev $TAP
ip link set up dev $BRIDGE
echo "Stopping NetworkManager"
systemctl stop NetworkManager
echo "Requesting ip for $BRIDGE"
dhclient $BRIDGE
if [ $? -eq 0 ]; then
echo "Requesting ip for $INTERFACE"
dhclient $INTERFACE
echo "Killing dhclient and starting NetworkManager"
pkill -9 dhclient
systemctl start NetworkManager
fi
##!/usr/bin/env bash
set -eu
# Docker environment variabeles