无法重新启动网络服务

无法重新启动网络服务

操作系统:Ubuntu 16.04 服务器

[root@wspbm]# uname -a
Linux wspbm 4.4.0-131-generic #157-Ubuntu SMP Thu Jul 12 15:51:36 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

启动时,该机器会启动所有预期到位的网络。重新启动网络后,显示所有接口均未知。

Dmesg 输出显示接口在启动时被重命名,并且接口文件引用了这些新名称。然而,所有错误消息都表明接口未知。此处的目标只是能够无错误地重新启动网络服务。很高兴提供任何其他详细信息。提前感谢任何建议。

ip 添加输出:

    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    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: enp3s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master br0 state UP group default qlen 1000
    link/ether d4:85:64:76:33:7a brd ff:ff:ff:ff:ff:ff
    inet6 fe80::d685:64ff:fe76:337a/64 scope link 
       valid_lft forever preferred_lft forever
3: enp3s0f1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master br_parental state UP group default qlen 1000
    link/ether d4:85:64:76:33:7c brd ff:ff:ff:ff:ff:ff
    inet6 fe80::d685:64ff:fe76:337c/64 scope link 
       valid_lft forever preferred_lft forever
4: enp4s0f0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether d4:85:64:76:33:7e brd ff:ff:ff:ff:ff:ff
5: enp4s0f1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether d4:85:64:76:33:80 brd ff:ff:ff:ff:ff:ff
6: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether d4:85:64:76:33:7a brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.17/24 brd 192.168.1.255 scope global br0
       valid_lft forever preferred_lft forever
    inet6 fe80::d685:64ff:fe76:337a/64 scope link 
       valid_lft forever preferred_lft forever
7: br_parental: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether d4:85:64:76:33:7c brd ff:ff:ff:ff:ff:ff
    inet 192.168.5.1/24 brd 192.168.5.255 scope global br_parental
       valid_lft forever preferred_lft forever
    inet6 fe80::d685:64ff:fe76:337c/64 scope link 
       valid_lft forever preferred_lft forever
8: br1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether fe:54:00:14:06:b4 brd ff:ff:ff:ff:ff:ff
    inet 192.168.2.5/24 brd 192.168.2.255 scope global br1
       valid_lft forever preferred_lft forever
    inet6 fe80::20ac:ff:fe77:5264/64 scope link 
       valid_lft forever preferred_lft forever
9: br-252fbfc5e3eb: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:25:62:de:bb brd ff:ff:ff:ff:ff:ff
    inet 172.18.0.1/16 scope global br-252fbfc5e3eb
       valid_lft forever preferred_lft forever
10: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:42:ec:d9:07:0a brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 scope global docker0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:ecff:fed9:70a/64 scope link 
       valid_lft forever preferred_lft forever
12: veth9bc939a@if11: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default 
    link/ether e2:19:05:d2:13:f6 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet6 fe80::e019:5ff:fed2:13f6/64 scope link 
       valid_lft forever preferred_lft forever
13: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 52:54:00:20:6c:b8 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
14: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
    link/ether 52:54:00:20:6c:b8 brd ff:ff:ff:ff:ff:ff
15: vnet0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UNKNOWN group default qlen 1000
    link/ether fe:54:00:52:92:86 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fc54:ff:fe52:9286/64 scope link 
       valid_lft forever preferred_lft forever
16: vnet1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UNKNOWN group default qlen 1000
    link/ether fe:54:00:1e:29:a4 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fc54:ff:fe1e:29a4/64 scope link 
       valid_lft forever preferred_lft forever
17: vnet2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br1 state UNKNOWN group default qlen 1000
    link/ether fe:54:00:14:06:b4 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fc54:ff:fe14:6b4/64 scope link 
       valid_lft forever preferred_lft forever

/etc/network/interfaces 文件:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# source /etc/network/interfaces.d/*

# The loopback network interfaces
auto lo
iface lo inet loopback


# Configure the primary network interface
# This is the interface facing the internet
# and is in the br0 bridge
auto enp3s0f0

# Configure the interface facing the kid's router
# This is the interface on ingress which has unfiltered 
# traffic and is in the br_parental bridge
auto enp3s0f1

# Configure the other two interfaces to try and avoid errors
auto enp4s0f0
auto enp4s0f1

auto br0
iface br0 inet dhcp
    bridge_ports enp3s0f0
    bridge_stp off
    bridge_fd 0
    bridge_maxwait 0


auto br_parental
iface br_parental inet static
    address 192.168.5.1
    netmask 255.255.255.0
    bridge_ports enp3s0f1
    bridge_stp off
    bridge_fd 0
    bridge_maxwait 0 

dmesg 输出:

[root@wspbm]# dmesg | grep enp 
[    3.156327] bnx2 0000:03:00.1 enp3s0f1: renamed from eth1
[    3.726740] bnx2 0000:03:00.0 enp3s0f0: renamed from eth0
[    3.811065] bnx2 0000:04:00.1 enp4s0f1: renamed from eth3
[    3.854786] bnx2 0000:04:00.0 enp4s0f0: renamed from eth2
[   10.707562] device enp3s0f0 entered promiscuous mode
[   10.707743] device enp3s0f1 entered promiscuous mode
[   11.031815] bnx2 0000:03:00.1 enp3s0f1: using MSIX
[   11.031850] IPv6: ADDRCONF(NETDEV_UP): enp3s0f1: link is not ready
[   11.099798] bnx2 0000:03:00.0 enp3s0f0: using MSIX
[   11.099826] IPv6: ADDRCONF(NETDEV_UP): enp3s0f0: link is not ready
[   14.221725] bnx2 0000:03:00.1 enp3s0f1: NIC Copper Link is Up, 1000 Mbps full duplex
[   14.221826] IPv6: ADDRCONF(NETDEV_CHANGE): enp3s0f1: link becomes ready
[   14.221873] br_parental: port 1(enp3s0f1) entered forwarding state
[   14.221885] br_parental: port 1(enp3s0f1) entered forwarding state
[   14.772048] bnx2 0000:03:00.0 enp3s0f0: NIC Copper Link is Up, 1000 Mbps full duplex
[   14.772148] IPv6: ADDRCONF(NETDEV_CHANGE): enp3s0f0: link becomes ready
[   14.772187] br0: port 1(enp3s0f0) entered forwarding state
[   14.772199] br0: port 1(enp3s0f0) entered forwarding state

服务网络重启输出:

[root@wspbm]# service networking restart
Job for networking.service failed because the control process exited with error code. See "systemctl status networking.service" and "journalctl -xe" for details.
[root@wspbm]# 

systemctl status networking.service 输出:

    ● networking.service - Raise network interfaces
   Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor preset: enabled)
  Drop-In: /run/systemd/generator/networking.service.d
           └─50-insserv.conf-$network.conf
   Active: failed (Result: exit-code) since Wed 2018-08-08 08:37:41 MDT; 2min 31s ago
     Docs: man:interfaces(5)
  Process: 16185 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=1/FAILURE)
  Process: 16179 ExecStartPre=/bin/sh -c [ "$CONFIGURE_INTERFACES" != "no" ] && [ -n "$(ifquery --read-environment --list --exclude=lo)" ] && udevadm settle (code=exited, status=0/SUCCESS)
 Main PID: 16185 (code=exited, status=1/FAILURE)

Aug 08 08:37:41 wspbm ifup[16185]: Unknown interface enp4s0f0
Aug 08 08:37:41 wspbm ifup[16185]: Unknown interface enp4s0f1
Aug 08 08:37:41 wspbm ifup[16185]: Unknown interface enp3s0f0
Aug 08 08:37:41 wspbm ifup[16185]: Unknown interface enp3s0f1
Aug 08 08:37:41 wspbm ifup[16185]: Unknown interface enp4s0f0
Aug 08 08:37:41 wspbm ifup[16185]: Unknown interface enp4s0f1
Aug 08 08:37:41 wspbm systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
Aug 08 08:37:41 wspbm systemd[1]: Failed to start Raise network interfaces.
Aug 08 08:37:41 wspbm systemd[1]: networking.service: Unit entered failed state.
Aug 08 08:37:41 wspbm systemd[1]: networking.service: Failed with result 'exit-code'.

答案1

由于我的声誉低,我无法发表评论,所以请先原谅我的回答。

来自人机界面.5语法应包含节 + 方法。我刚刚尝试了类似的配置,删除了节和方法,但结果出现了相同的错误消息。

复制粘贴并编辑你的 /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# source /etc/network/interfaces.d/*

# The loopback network interfaces
auto lo
iface lo inet loopback


# Configure the primary network interface
# This is the interface facing the internet
# and is in the br0 bridge
auto enp3s0f0
iface enp3s0f0 inet manual

# Configure the interface facing the kid's router
# This is the interface on ingress which has unfiltered 
# traffic and is in the br_parental bridge
auto enp3s0f1
iface enp3s0f1 inet manual

# Configure the other two interfaces to try and avoid errors
auto enp4s0f0
iface enp4s0f0 inet manual

auto enp4s0f1
iface enp4s0f1 inet manual

auto br0
iface br0 inet dhcp
    bridge_ports enp3s0f0
    bridge_stp off
    bridge_fd 0
    bridge_maxwait 0

auto br_parental
iface br_parental inet static
    address 192.168.5.1
    netmask 255.255.255.0
    # do you want to set gateway?
    bridge_ports enp3s0f1
    bridge_stp off
    bridge_fd 0
    bridge_maxwait 0

答案2

只是为了明确地写出答案,/etc/networking/interfaces 文件中缺少以下几行,导致网络服务无法无错误地重新启动:

iface enp3s0f0 inet manual
iface enp3s0f1 inet manual
iface enp4s0f0 inet manual
iface enp4s0f1 inet manual

在相应接口的‘自动’行之后立即添加这些行,网络服务就可以正确重新启动:

[root@wspbm]# service networking restart
[root@wspbm]# systemctl status networking.service
● networking.service - Raise network interfaces
   Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor preset: enabled)
  Drop-In: /run/systemd/generator/networking.service.d
           └─50-insserv.conf-$network.conf
   Active: active (exited) since Wed 2018-08-08 16:18:25 MDT; 5min ago
     Docs: man:interfaces(5)
  Process: 4062 ExecStop=/sbin/ifdown -a --read-environment --exclude=lo (code=exited, status=0/SUCCESS)
  Process: 4397 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=0/SUCCESS)
  Process: 4390 ExecStartPre=/bin/sh -c [ "$CONFIGURE_INTERFACES" != "no" ] && [ -n "$(ifquery --read-environment --list --exclude=lo)" ] && udevadm settle (code=exited, status=0/SUCCESS)
 Main PID: 4397 (code=exited, status=0/SUCCESS)
    Tasks: 1
   Memory: 1.2M
      CPU: 1.177s
   CGroup: /system.slice/networking.service
           └─4962 /sbin/dhclient -1 -v -pf /run/dhclient.br0.pid -lf /var/lib/dhcp/dhclient.br0.leases -I -df /var/lib/dhcp/dhclient6.br0.leases br0

Aug 08 16:18:24 wspbm dhclient[4821]: DHCPDISCOVER on br0 to 255.255.255.255 port 67 interval 4 (xid=0xccaaa745)
Aug 08 16:18:24 wspbm ifup[4397]: DHCPDISCOVER on br0 to 255.255.255.255 port 67 interval 4 (xid=0xccaaa745)
Aug 08 16:18:24 wspbm dhclient[4821]: DHCPREQUEST of 192.168.1.17 on br0 to 255.255.255.255 port 67 (xid=0x45a7aacc)
Aug 08 16:18:24 wspbm ifup[4397]: DHCPREQUEST of 192.168.1.17 on br0 to 255.255.255.255 port 67 (xid=0x45a7aacc)
Aug 08 16:18:24 wspbm ifup[4397]: DHCPOFFER of 192.168.1.17 from 192.168.1.53
Aug 08 16:18:24 wspbm dhclient[4821]: DHCPOFFER of 192.168.1.17 from 192.168.1.53
Aug 08 16:18:25 wspbm dhclient[4821]: DHCPACK of 192.168.1.17 from 192.168.1.53
Aug 08 16:18:25 wspbm ifup[4397]: DHCPACK of 192.168.1.17 from 192.168.1.53
Aug 08 16:18:25 wspbm ifup[4397]: bound to 192.168.1.17 -- renewal in 34561 seconds.
Aug 08 16:18:25 wspbm systemd[1]: Started Raise network interfaces.
[root@wspbm]# 

相关内容