ifdown:介面 enp0s3 未配置。 RTNETLINK 回答: 檔案存在。 ifup:無法啟動 enp0s3

ifdown:介面 enp0s3 未配置。 RTNETLINK 回答: 檔案存在。 ifup:無法啟動 enp0s3

我有一個虛擬盒子(6.1),最小化的是ubuntu。在網路部分的虛擬機器設定中,選擇「橋接適配器」。

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

我嘗試將字串“enp0s3=enp0s3”新增至 /run/network/ifstate 但它不起作用。但是 /run - 它是一個虛擬檔案系統,並且帶有 enp0s3 的字串將在重新載入守護程式或重新啟動伺服器後被刪除。有人說所有配置的介面都應該顯示在/run/network/ifstate中。但是,如果 enp0s3 介面已在 config 中註冊,為什麼它不會顯示在 /run/network/ifstate 中?

也許我的設定檔有一些錯誤?

重啟後,地址192.168.88.236/24上升,但這些命令不起作用:

ifup enp0s3
ifdown enp0s3

我不明白為什麼會出現錯誤:

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

除了檔案 /etc/network/interfaces 之外,ifup 和 ifdown 可以在哪裡取得與介面一起使用的設定?

檔案 /etc/networks 為空。

答案1

我發現 dhcpv4 在此conf檔案中啟用 -/etc/netplan/01-netcfg.yaml。重新啟動後 DHCP 被停用。

當虛擬機器開啟時,網路守護程序從/etc/網路/接口(靜態位址)配置和來自/etc/netplan/01-netcfg.yaml(DHCP)。

因此,當系統啟動時,作業系統嘗試透過靜態和 DHCP 從不同的配置中取得位址 192.168.88.236/24。衝突也因此產生。

/etc/netplan/01-netcfg.yaml我變了“dhcpv4:是”為了enp0s3“dhcpv4:否”。重啟後 dhcpclient 就消失了。

相關內容