Created
September 8, 2024 22:38
-
-
Save UnixSage/74f89b331815de38fe5d3ecedc77e969 to your computer and use it in GitHub Desktop.
Can be used to move connectivity from an interface to a bridge with the provided IP information. While I have successfully used this while remote it must be done with care as it could very well send you to the datacenter. Also it assumes the DNS server is the same as the gateway.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $# -ne 3 ] ; then | |
echo "usage: $0 <interface> <ip/cidr> <gateway>" | |
echo "ie: $0 eno1 10.0.0.25/24 10.0.0.1" | |
exit 1 | |
fi | |
INTERFACE=$1 | |
IP=$2 | |
GATEWAY=$3 | |
DNS=${GATEWAY} | |
BRIDGE="br0" | |
nmcli connection add type bridge autoconnect yes con-name ${BRIDGE} ifname ${BRIDGE} | |
nmcli connection modify ${BRIDGE} ipv4.addresses ${IP} ipv4.method manual | |
nmcli connection modify ${BRIDGE} ipv4.gateway ${GATEWAY} | |
nmcli connection modify ${BRIDGE} ipv4.dns ${DNS} | |
nmcli connection modify ${BRIDGE} ipv4.dns-search srv.world | |
nmcli connection del ${INTERFACE} | |
nmcli connection add type bridge-slave autoconnect yes con-name ${INTERFACE} ifname ${INTERFACE} master ${BRIDGE} | |
sleep 3 | |
reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment