0

I have a virtual box (6.1) with ubuntu minimal. in the settings of the virtual machine in the network section, "Bridged Adapter" is selected.

root@ubuntu:/home/mista# dmesg -T|head -1
[Sun Oct 24 10:56:10 2021] Linux version 5.4.0-89-generic (buildd@lgw01-amd64-044) (gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)) #100-Ubuntu SMP Fri Sep 24 14:50:10 UTC 2021 (Ubuntu 5.4.0-89.100-generic 5.4.143)

root@ubuntu:/home/mista# ip a

    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
        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
        inet6 ::1/128 scope host 
           valid_lft forever preferred_lft forever
    2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
        link/ether 08:00:27:1e:5b:6d brd ff:ff:ff:ff:ff:ff
        inet 192.168.88.236/24 brd 192.168.88.255 scope global dynamic enp0s3
           valid_lft 473sec preferred_lft 473sec
        inet6 fe80::a00:27ff:fe1e:5b6d/64 scope link 
           valid_lft forever preferred_lft forever

root@ubuntu:/home/mista# cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

auto enp0s3
iface enp0s3 inet static
address 192.168.88.236
netmask 255.255.255.0
gateway 192.168.88.1

root@ubuntu:/home/mista# ifdown enp0s3
ifdown: interface enp0s3 not configured

root@ubuntu:/home/mista# ifup enp0s3
RTNETLINK answers: File exists
ifup: failed to bring up enp0s3

root@ubuntu:/home/mista# systemctl status networking

● networking.service - Raise network interfaces
     Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Sun 2021-10-24 11:24:35 MSK; 1min 39s ago
       Docs: man:interfaces(5)
    Process: 826 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=1/FAILURE)
   Main PID: 826 (code=exited, status=1/FAILURE)

Oct 24 11:24:35 ubuntu systemd[1]: Starting Raise network interfaces...
Oct 24 11:24:35 ubuntu ifup[844]: RTNETLINK answers: File exists
Oct 24 11:24:35 ubuntu ifup[826]: ifup: failed to bring up enp0s3
Oct 24 11:24:35 ubuntu systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
Oct 24 11:24:35 ubuntu systemd[1]: networking.service: Failed with result 'exit-code'.
Oct 24 11:24:35 ubuntu systemd[1]: Failed to start Raise network interfaces.


root@ubuntu:/home/mista# cat /run/network/ifstate
lo=lo

I tried to add the string "enp0s3=enp0s3" to /run/network/ifstate but it doesn't work. But /run - it's a virtual file system and the string with enp0s3 will be delete after reload daemons or reboot the server. Some people say that all configured interfaces should be displayed in /run/network/ifstate. But why, then, the enp0s3 interface is not displayed in the /run/network/ifstate if it is registered in the config ?

And may be I have some mistake in config file?

after reboot, the address 192.168.88.236/24 rises, but these commands do not work:

ifup enp0s3
ifdown enp0s3

I don't understand why errors are coming out:

root@ubuntu:/home/mista# ifdown enp0s3
ifdown: interface enp0s3 not configured

root@ubuntu:/home/mista# ifup enp0s3
RTNETLINK answers: File exists
ifup: failed to bring up enp0s3

Where ifup and ifdown can get the config to work with the interface except for the file /etc/network/interfaces?

The file /etc/networks is empty.

Mexanizm456
  • 41
  • 1
  • 4
  • This interface is configured twice: once with DHCP (`valid_lft 473sec preferred_lft 473sec` is a strong hint for DHCP), once with ifupdown and a static address. Figure out where is the duplication. – A.B Oct 24 '21 at 09:53
  • I have a virtual box (6.1) with ubuntu minimal. in the settings of the virtual machine in the network section, "Bridged Adapter" is selected. - maybe this things have some conflict? Thanks a lot! I think the problem is really in dhcp server but I don't specify the DHCP server in /etc/network/interfaces. How to check dhcp server is running on ubuntu or no? – Mexanizm456 Oct 24 '21 at 10:19
  • You have to find the *client* not the server. – A.B Oct 24 '21 at 10:19
  • Thank you very much! I found that dhcpv4 was be enable in this conf file - /etc/netplan/01-netcfg.yaml. After reboot the DHCP is was disable. – Mexanizm456 Oct 24 '21 at 13:13
  • To thank me, write an answer to your own question (and probably accept it in a few days). I can't write it myself because it requires knowing every details involved. – A.B Oct 24 '21 at 13:15

1 Answers1

2

I found that dhcpv4 was be enable in this conf file - /etc/netplan/01-netcfg.yaml. After reboot the DHCP was disable.

when the virtual machine was turned on, the network daemon raised interfaces from the /etc/network/interfaces (static address) config and from the /etc/netplan/01-netcfg.yaml (DHCP).

therefore, when the system was started, the operating system tried to raise the address 192.168.88.236/24 from different configs by statics and by DHCP. The conflict arose for this reason.

in /etc/netplan/01-netcfg.yaml I changed "dhcpv4: yes" for enp0s3 to "dhcpv4: no". And after reboot the dhcpclient was gone.

Mexanizm456
  • 41
  • 1
  • 4