How to create a Bridge in Linux Virualization

 How to create a Bridge in Linux Virualization


nmcli connection show

brctl show



nmcli connection add type bridge ifname br0 con-name br0 \
  ipv4.addresses 192.168.1.66/24 \
  ipv4.gateway 192.168.1.1 \
  ipv4.dns 8.8.8.8 \
  ipv4.method manual \
  ipv6.method ignore


nmcli connection add type ethernet ifname ens2f0 master br0


nmcli connection up br0


nmcli connection down ens2f0


nmcli connection up br0


ip addr show br0


nmcli connection show br0


Removing IP from Existing interface


# 1. Delete any IP from ens2f0

sudo nmcli con mod ens2f0 ipv4.method disabled ipv6.method ignore


# 2. Create the bridge

sudo nmcli con add type bridge ifname br0 con-name br0 ipv4.addresses 192.168.1.66/24 ipv4.gateway 192.168.1.1 ipv4.method manual


# 3. Add physical NIC to the bridge

sudo nmcli con add type bridge-slave ifname ens2f0 master br0


# 4. Bring everything up

sudo nmcli con up br0

sudo nmcli con up bridge-slave-ens2f0

nmcli connection show --active


Removing old IP in VM

nano /etc/sysconfig/network-scripts/ifcfg-enp1s0


BOOTPROTO=static
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8
ONBOOT=yes


systemctl restart network


ifdown enp1s0 && sudo ifup enp1s0


sudo nmcli connection reload
sudo nmcli connection down enp1s0 && sudo nmcli connection up enp1s0

systemctl restart network


Disable DHCP and Force Static IP

nmcli con show


nmcli con mod enp1s0 ipv4.addresses 192.168.1.51/24
nmcli con mod enp1s0 ipv4.gateway 192.168.1.1
nmcli con mod enp1s0 ipv4.dns "8.8.8.8 8.8.4.4"
nmcli con mod enp1s0 ipv4.method manual


nmcli con down enp1s0
nmcli con up enp1s0

ip addr show enp1s0

nmcli con mod enp1s0 ipv4.method manual

sudo ip addr flush dev enp1s0
nmcli con up enp1s0

Disable ipv6

sysctl -w net.ipv6.conf.all.disable_ipv6=1
sysctl -w net.ipv6.conf.default.disable_ipv6=1

/etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1

sysctl -p

Comments