I'm struggling to connect my KVM virtual machine to the local network.
$ brctl show br0
bridge name bridge id STP enabled interfaces
br0 8000.4c5262097e59 yes enp0s31f6
vnet0
enp0s31f6 is the hosts' ethenet card and vnet0 that of the KVM guest.
On the host, I have full network connectivity. No problems.
On the vm, I have no network connectivity at all:
$ping 8.8.8.8
connect: Network is unreachable
So I'm trying to figure out what is worng. Already here, I'm puzzled because I thought that a bridge is the equivalent of a hardware switch and if this is so, how can one device plugged into the switch reach the network but not the other?
Let's look at their IP addresses:
$ ip a show enp0s31f6
2: enp0s31f6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br0 state UP group default qlen 1000
link/ether 4c:52:62:09:7e:59 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.4/24 brd 192.168.1.255 scope global enp0s31f6
valid_lft forever preferred_lft forever
$ ip a show vnet0
26: vnet0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br0 state UNKNOWN group default qlen 1000
link/ether fe:54:00:f0:0e:f8 brd ff:ff:ff:ff:ff:ff
inet6 fe80::fc54:ff:fef0:ef8/64 scope link
valid_lft forever preferred_lft forever
So, the host has an IP 192.168.1.4 but the vm doesn't (except for an IPv6, no idea why).
The host received it's IP from the DHCP server on the LAN:
sudo dhclient -v enp0s31f6
Internet Systems Consortium DHCP Client 4.3.5
Copyright 2004-2016 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Listening on LPF/enp0s31f6/4c:52:62:09:7e:59
Sending on LPF/enp0s31f6/4c:52:62:09:7e:59
Sending on Socket/fallback
DHCPREQUEST of 192.168.1.4 on enp0s31f6 to 255.255.255.255 port 67 (xid=0x64e68ab1)
DHCPACK of 192.168.1.4 from 192.168.1.1
RTNETLINK answers: File exists
bound to 192.168.1.4 -- renewal in 40526 seconds.
So let's try to get one for the vm too:
$ sudo dhclient -v vnet0
Internet Systems Consortium DHCP Client 4.3.5
Copyright 2004-2016 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Listening on LPF/vnet0/fe:54:00:f0:0e:f8
Sending on LPF/vnet0/fe:54:00:f0:0e:f8
Sending on Socket/fallback
DHCPDISCOVER on vnet0 to 255.255.255.255 port 67 interval 3 (xid=0xf64429)
DHCPDISCOVER on vnet0 to 255.255.255.255 port 67 interval 3 (xid=0xf64429)
DHCPDISCOVER on vnet0 to 255.255.255.255 port 67 interval 7 (xid=0xf64429)
DHCPDISCOVER on vnet0 to 255.255.255.255 port 67 interval 13 (xid=0xf64429)
DHCPDISCOVER on vnet0 to 255.255.255.255 port 67 interval 14 (xid=0xf64429)
DHCPDISCOVER on vnet0 to 255.255.255.255 port 67 interval 18 (xid=0xf64429)
DHCPDISCOVER on vnet0 to 255.255.255.255 port 67 interval 10 (xid=0xf64429)
DHCPDISCOVER on vnet0 to 255.255.255.255 port 67 interval 15 (xid=0xf64429)
DHCPDISCOVER on vnet0 to 255.255.255.255 port 67 interval 18 (xid=0xf64429)
^C
It doesn't get one. :-(
So maybe the bridge is broken and the host still gets an IP because it is physically connected to the LAN? No, because the bridge itself does seem to talk the DHCP server too:
$ sudo dhclient -v br0
Internet Systems Consortium DHCP Client 4.3.5
Copyright 2004-2016 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Listening on LPF/br0/4c:52:62:09:7e:59
Sending on LPF/br0/4c:52:62:09:7e:59
Sending on Socket/fallback
DHCPREQUEST of 192.168.1.4 on br0 to 255.255.255.255 port 67 (xid=0x58c2333c)
DHCPACK of 192.168.1.4 from 192.168.1.1
RTNETLINK answers: File exists
bound to 192.168.1.4 -- renewal in 42819 seconds.
How do I continue from here?
(Feels like I have tried an checked just about everything, but I'm sparing you the information about that here as I'm now trying to systematically identify where I'm going wrong in the above steps.)
/etc/network/interfaces
everything worked. – Christoph Mar 06 '20 at 22:12