Page 1 of 1

Nat Network stops working after a couple days

Posted: 5. Sep 2021, 14:44
by RuudBrandsma
I'm experiencing the same issue.
VirtualBox 6.1.26 on a Windows 7 Host
Oracle Linux VM using NAT Network.

After starting the VM ip configuration is as follows:

Code: Select all

[oracle@10 etc]$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 08:00:27:0e:8a:eb brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.120/24 brd 10.0.2.255 scope global noprefixroute dynamic eth0
       valid_lft 367sec preferred_lft 367sec
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 52:54:00:6e:44:5f brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 500
    link/ether 52:54:00:6e:44:5f brd ff:ff:ff:ff:ff:ff
[oracle@10 etc]$
valid_lft and preferred_lft for eth0 start with a default of 600 sec. After 600 sec my eth0 adapter loses its ip-address and it is not renewed (this appears to be the same issue as described in this topic).
If I stop and start eth0 by using the following commands:

Code: Select all

[oracle@10 etc]$ ifdown eth0
Device `eth0` succesfully disconnected
[oracle@10 etc]$ ifup eth0
Connection succcesfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)
[oracle@10 etc]$
my network is restored and after every 600 sec the ip-address is automatically renewed.

Assuming this is the same issue:
Why isn't the ip-address renewed after the first 600 sec and do I have to use ifdown and ifup?
How can I configure a valid_lft and preferred_lft with the value forever, so this (mis)behaviour does not appear?
Are there any other solutions to prevent this from happening?

Regards

Re: Nat Network stops working after a couple days

Posted: 6. Sep 2021, 15:44
by scottgus1
You've dug a lot deeper into the specifics than I know about, but there is one thing about NAT Network that can glitch the results:

If one changes the default IP address range of the NAT Network after one has started the VM using the network, the DHCP server for the NAT Network does not follow the change. Virtualbox Networks: In Pictures: NAT network

Your 'ip a' output shows a 10.0.2.### range, which appears to be the default, but if it was changed then changed back, maybe something got broken. It's just a guess.

You could try making a new NAT Network, and try setting the VM to use it instead, see what happens.

Also check to see if this happens on other Virtualbox network types, or if it is really a VM OS problem (does the trouble happen on real PCs too?)

Re: Nat Network stops working after a couple days

Posted: 6. Sep 2021, 19:35
by fth0
You can configure the VirtualBox DHCP server quite extensively: 8.42. VBoxManage dhcpserver

Re: Nat Network stops working after a couple days

Posted: 8. Sep 2021, 14:03
by RuudBrandsma
Removed my VM, Nat Network by the name of Oracle and corresponding DHCP server.

Created a new (default) NatNetwork, corresponding DHCP server is created automatically with default settings.
Imported the VM (from scratch), Network adapter 1 NatNetwork.
Started the VM and experience the exact same behaviour. After 600 seconds eth0 loses it's ip-address, ifdown followed bu ifup restores the network and after that the ip-address on eth0 is renewed every 600 seconds.

Re: Nat Network stops working after a couple days

Posted: 8. Sep 2021, 18:48
by RuudBrandsma
Did some additional research and it appears not te be a VirtualBox issue but a general Linux issue.
For instance see https://bugs.launchpad.net/ubuntu/+sour ... ug/1586528
In this post the exact same behaviour and logging is /var/log/messages is described. Post does not give a fix but some clues and workarounds. Probably ipv6 related, but this workarounds do not work on my environment.
Decided to implement my own workaround by using ifdown and ifup after boot.

Re: Nat Network stops working after a couple days

Posted: 8. Sep 2021, 19:56
by fth0
You could use Wireshark to capture the network traffic in the guest OS, to see if a DHCP renew and/or a DHCP rebind takes place. Expect the renew after less than half the lifetime.