creating my first KVM VM with network bridge is not working

Issues related to configuring your network
Post Reply
sreese
Posts: 2
Joined: 2020/01/17 17:05:10

creating my first KVM VM with network bridge is not working

Post by sreese » 2020/01/17 17:10:00

Hello guys,

I have a network bridge on my CentOS 7 box where eno1 is the slave of br0. The br0 gets its IP via DHCP. Now I called following commands to create the VM.

Code: Select all

genisoimage -output plex.iso -volid cidata -joliet -rock user-data meta-data
qemu-img create -f qcow2 -o backing_file=../qcows/CentOS-7-x86_64-GenericCloud.qcow2 plex.qcow2
virt-install --connect qemu:///system --import --name plex --ram 4096 --vcpus 2 --disk path=plex.qcow2 --disk path=plex.iso,device=cdrom --network bridge=br0,model=virtio --os-type=linux --os-variant=centos7.0 --noautoconsole --nographics
Unluckily the network inside the VM does not start and does not get IP via DHCP, why? I see following error.

Code: Select all

[FAILED] Failed to start LSB: Bring up/down networking.
This prints after a timeout.

Code: Select all

[     *] A start job is running for LSB: Bri.../down networking (45s / 5min 5s)
The guest VM's network service logs the following.

Code: Select all

sudo systemctl status network
● network.service - LSB: Bring up/down networking
   Loaded: loaded (/etc/rc.d/init.d/network; bad; vendor preset: disabled)
   Active: failed (Result: timeout) since Fri 2020-01-17 18:52:11 UTC; 50s ago
     Docs: man:systemd-sysv-generator(8)

Jan 17 18:51:19 plex dhclient[855]: DHCPDISCOVER on eth0 to 255.255.255.255...5)
Jan 17 18:51:33 plex dhclient[855]: DHCPDISCOVER on eth0 to 255.255.255.255...5)
Jan 17 18:51:51 plex dhclient[855]: DHCPDISCOVER on eth0 to 255.255.255.255...5)
Jan 17 18:52:02 plex dhclient[855]: DHCPDISCOVER on eth0 to 255.255.255.255...5)
Jan 17 18:52:11 plex systemd[1]: network.service start operation timed out....g.
Jan 17 18:52:11 plex systemd[1]: Failed to start LSB: Bring up/down networking.
Jan 17 18:52:11 plex systemd[1]: Unit network.service entered failed state.
Jan 17 18:52:11 plex systemd[1]: network.service failed.
Jan 17 18:52:12 plex dhclient[855]: No DHCPOFFERS received.
Jan 17 18:52:12 plex network[726]: Determining IP information for eth0... f...d.
Hint: Some lines were ellipsized, use -l to show in full.
The eth0 on the guest looks like this.

Code: Select all

BOOTPROTO=dhcp
DEVICE=eth0
HWADDR=52:54:00:5d:f6:5d
ONBOOT=yes
TYPE=Ethernet
USERCTL=no
How I am setting up the bridge follows now.

List the state after CentOS installation on the host.

Code: Select all

nmcli con show --active
NAME    UUID                                  TYPE      DEVICE
eno1    6eaf6ce4-fd7b-428a-8a4f-0390f13d3930  ethernet  eno1
virbr0  5803036f-c5e9-4893-ad8c-b8f5cd42c0ed  bridge    virbr0
Create the bridge interface and add eno1 as slave.

Code: Select all

nmcli con add ifname br0 type bridge con-name br0
nmcli con add type bridge-slave ifname eno1 master br0
This adds 'bridge-slave-eno1', no idea why.

Disable spanning tree.

Code: Select all

nmcli con modify br0 bridge.stp no
At the end I get this.

Code: Select all

nmcli con show
NAME               UUID                                  TYPE      DEVICE
br0                c81fcfb4-9091-47f5-8c0b-503666401912  bridge    br0
eno1               6eaf6ce4-fd7b-428a-8a4f-0390f13d3930  ethernet  eno1
virbr0             5803036f-c5e9-4893-ad8c-b8f5cd42c0ed  bridge    virbr0
bridge-slave-eno1  310597e5-fa36-4fbb-a3aa-6c15b387af9a  ethernet  --
eno1 down and br0 up.

Code: Select all

nmcli con up br0
ncmli con down eno1
Everything looks OK to me (noob).

Code: Select all

ifconfig
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.5  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::cd6:5b23:4367:fab9  prefixlen 64  scopeid 0x20<link>
        ether 1c:69:7a:0a:98:2f  txqueuelen 1000  (Ethernet)
        RX packets 113  bytes 8477 (8.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 39  bytes 7002 (6.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 0.0.0.0
        ether 02:42:8d:49:28:10  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 1c:69:7a:0a:98:2f  txqueuelen 1000  (Ethernet)
        RX packets 97697  bytes 134675728 (128.4 MiB)
        RX errors 0  dropped 4  overruns 0  frame 0
        TX packets 32598  bytes 2350477 (2.2 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 16  memory 0xc0b00000-c0b20000

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:82:15:ce  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
Restart NetworkManager to be sure.

Code: Select all

sudo systemctl restart NetworkManager
Configured bridge in virtlib.

Code: Select all

cat > bridge.xml <<EOF
<network>
    <name>host-bridge</name>
    <forward mode="bridge"/>
    <bridge name="br0"/>
</network>
EOF
virsh net-define bridge.xml
virsh net-start host-bridge
virsh net-autostart host-bridge
Do I have to do more for virtlib to work?
Last edited by sreese on 2020/01/17 21:38:27, edited 1 time in total.
Cheers
Sherry

sreese
Posts: 2
Joined: 2020/01/17 17:05:10

Re: creating my first KVM VM with network bridge is not working

Post by sreese » 2020/01/17 19:07:44

It seems this was the freaking firewall.

Code: Select all

firewall-cmd --permanent --direct --passthrough ipv4 -I FORWARD -i br0 -j ACCEPT
firewall-cmd --permanent --direct --passthrough ipv4 -I FORWARD -o br0 -j ACCEPT
firewall-cmd --reload
And now I get the IP. Creating the bridge in virtlib (with virsh commands) are probably not necessary.
Cheers
Sherry

Post Reply

Return to “CentOS 7 - Networking Support”