Network interface/dhcp problems ubuntu with kvm and network bridge
I'm genuinely surprised that no one has mentioned the obvious answer -
Drop DHCP and use static IP addressing. You can continue with NAT ETC, just don't assign the IP's from the DHCP pool, but in the same subnet and everything should work reliably and predictably.
All you need to do to enable static IP addressing is change
auto eth0 iface eth0 inet dhcp
to
auto eth0 address X.X.X.X iface eth0 inet static netmask 255.255.255.0 gateway X.X.X.Y
Making sure the gateway is the address assigned by KVM (if you do a /sbin/route -n it will show you the default gateway - thats the IP address to use).
Related videos on Youtube
Alex Edwards
Updated on September 18, 2022Comments
-
Alex Edwards over 1 year
I have a ubuntu system running 12.10
I am using KVM and have configured a bridge for the virtual machines, which is using nat forwarding. I am having problems with the connection dropping out periodically sometimes it stays up for a few days sometimes a few minutes.
I have disabled the bridge to resolve the issue but its still happening, I tried doing a manual dhcp release and renew which works sometimes, it gets me a new ip and im away again but i noticed that my ip is not updated when i run
ifconfig
or in kvm connection settings./etc/interfaces
auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp #auto br0 #iface br0 inet dhcp # bridge_ports eth0 # bridge_stp off # bridge_fd 0 # bridge_maxwait 0
ifconfig
eth0 Link encap:Ethernet HWaddr 38:60:77:aa:aa:aa inet addr:10.0.0.137 Bcast:10.0.0.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:52068 errors:0 dropped:0 overruns:0 frame:0 TX packets:10900 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:12322071 (12.3 MB) TX bytes:2494188 (2.4 MB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:2651 errors:0 dropped:0 overruns:0 frame:0 TX packets:2651 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:402096 (402.0 KB) TX bytes:402096 (402.0 KB) virbr0 Link encap:Ethernet HWaddr f6:94:09:8f:7b:b5 inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
sudo dhcpclient -r -v
Internet Systems Consortium DHCP Client 4.2.4 Copyright 2004-2012 Internet Systems Consortium. All rights reserved. For info, please visit https://www.isc.org/software/dhcp/ Listening on LPF/virbr0/f6:94:09:8f:7b:b5 Sending on LPF/virbr0/f6:94:09:8f:7b:b5 Listening on LPF/eth0/38:60:77:aa:aa:aa Sending on LPF/eth0/38:60:77:aa:aa:aa Sending on Socket/fallback DHCPRELEASE on eth0 to 10.0.0.254 port 67
sudo dhcpclient -v
Internet Systems Consortium DHCP Client 4.2.4 Copyright 2004-2012 Internet Systems Consortium. All rights reserved. For info, please visit https://www.isc.org/software/dhcp/ Listening on LPF/virbr0/f6:94:09:8f:7b:b5 Sending on LPF/virbr0/f6:94:09:8f:7b:b5 Sending on Socket/fallback DHCPDISCOVER on virbr0 to 255.255.255.255 port 67 interval 3 DHCPDISCOVER on virbr0 to 255.255.255.255 port 67 interval 5 DHCPDISCOVER on virbr0 to 255.255.255.255 port 67 interval 9 DHCPDISCOVER on virbr0 to 255.255.255.255 port 67 interval 15
At the moment the only way I know to recover from this state is to unplug the network cable and restart
UPDATE
When the connection drops out I have had some success running
sudo dhclient -v
without dropping the address first.dhclient -v
Internet Systems Consortium DHCP Client 4.2.4 Copyright 2004-2012 Internet Systems Consortium. All rights reserved. For info, please visit https://www.isc.org/software/dhcp/ Listening on LPF/virbr0/96:a2:d6:f5:30:fc Sending on LPF/virbr0/96:a2:d6:f5:30:fc Listening on LPF/eth0/38:60:77:aa:aa:aa Sending on LPF/eth0/38:60:77:aa:aa:aa Sending on Socket/fallback DHCPDISCOVER on virbr0 to 255.255.255.255 port 67 interval 3 DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 3 DHCPREQUEST of 10.0.0.129 on eth0 to 255.255.255.255 port 67 DHCPOFFER of 10.0.0.129 from 10.0.0.254 DHCPACK of 10.0.0.129 from 10.0.0.254 bound to 10.0.0.129 -- renewal in 5716 seconds.
here I can see I am being leased
10.0.0.129
but ifconfig still displays10.0.0.137
eth0 Link encap:Ethernet HWaddr 38:60:77:82:a8:61 inet addr:10.0.0.137 Bcast:10.0.0.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:312183 errors:0 dropped:0 overruns:0 frame:0 TX packets:85529 errors:0 dropped:1 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:80808972 (80.8 MB) TX bytes:20479979 (20.4 MB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:3910 errors:0 dropped:0 overruns:0 frame:0 TX packets:3910 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:461047 (461.0 KB) TX bytes:461047 (461.0 KB) virbr0 Link encap:Ethernet HWaddr 96:a2:d6:f5:30:fc inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
-
oo. about 11 yearsWhat type of network card do you have?
-
Alex Edwards about 11 yearslspci | egrep -i --color 'network|ethernet' 05:00.0 Network controller: Ralink corp. RT5390 Wireless 802.11n 1T/1R PCIe 06:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 06)
-
Alex Edwards about 11 yearsmaybe I should disable that wireless card as i'm not using that
-
rubo77 about 11 yearscan you post the output of
tail -f /var/log/syslog
? and a tcpdump of networkmanager while the connection gets lost? (best on pastebin.com ) -
Alex Edwards about 11 years@rubo77 will do, it could be a while its been well behaved today!
-
-
Alex Edwards about 11 yearswell I have disabled the bridge which is br0, when this is enabled eth0 has no ip it appears on br0, but I still get the same connection dropout issues. virbr0 is something kvm created, I think this is the nat for the virtual hosts which get externally addressable ips when they are running but this config is without any vm's running.
-
killermist about 11 yearsYa. It was a shot in the dark, and far too long to be a comment to the question. I figured it might spark some ideas that might lead you to the correct result. I hope you figure it out, or that someone else knows the answer.
-
Alex Edwards about 11 yearsipv6 should already be disabled I have net.ipv6.conf.all.disable_ipv6=1, net.ipv6.conf.default.disable_ipv6=1, net.ipv6.conf.lo.disable_ipv6=1, in my sysctl.conf file
-
Thufir over 6 yearsgood static ip explanation for bridging