启动后 SSH 和绑定缓慢。重启网络时出错

启动后 SSH 和绑定缓慢。重启网络时出错

我正在使用 16.04.2 构建路由器。安装 SSH、重命名/设置接口,然后安装 Bind 后,我注意到 ssh 和 bind 大约需要 5 分钟才能开始响应(ICMP 在 30 秒内开始响应)。一旦服务启动,一切似乎都运行正常。

另外,我发现重新启动网络时出现此错误:

sudo /etc/init.d/networking restart

[....] Restarting networking (via systemctl): networking.serviceJob for networking.service failed because the control process exited with error code. See "systemctl status networking.service" and "journalctl -xe" for details.
failed!

所以我认为这与重命名/设置接口有关。我按照这里的说明修改了 grub:更改网络接口名称 Ubuntu 16.04然后我创建了/etc/udev/rules.d/70-persistent-net.rules:

# spectrum
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="f0:4d:a2:24:99:af", ATTR{dev_id}=="0x0", ATTR{type}=="1", NAME="eth0spectrum"

# name1.lan
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:86:52:31", ATTR{dev_id}=="0x0", ATTR{type}=="1", NAME="eth1name1"

# name2.lan
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:86:52:30", ATTR{dev_id}=="0x0", ATTR{type}=="1", NAME="eth2name2"

# available
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:86:52:33", ATTR{dev_id}=="0x0", ATTR{type}=="1", NAME="eth3"

# available
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:86:52:32", ATTR{dev_id}=="0x0", ATTR{type}=="1", NAME="eth4"

然后设置/etc/network/interfaces:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
#
auto eth0spectrum
iface eth0spectrum inet dhcp
#
auto eth1name1
iface eth1name1 inet static
address 10.27.66.3
netmask 255.255.255.0
network 10.27.66.0
broadcast 10.27.66.255
gateway 10.27.66.1
dns-nameservers 127.0.0.1
#
auto eth2name2
iface eth2name2 inet static
address 10.28.66.1
netmask 255.255.255.0
network 10.28.66.0
broadcast 10.28.66.255
gateway 10.28.66.1
dns-nameservers 127.0.0.1
#
auto eth3
iface eth3 inet dhcp
#
auto eth4
iface eth4 inet dhcp

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 Sun 2017-07-16 10:56:59 EDT; 15s ago
     Docs: man:interfaces(5)
  Process: 1976 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=1/FAILURE)
  Process: 1970 ExecStartPre=/bin/sh -c [ "$CONFIGURE_INTERFACES" != "no" ] && [ -n "$(ifquery --read-
 Main PID: 1976 (code=exited, status=1/FAILURE)

Jul 16 10:56:59 cog systemd[1]: Starting Raise network interfaces...
Jul 16 10:56:59 cog ifup[1976]: RTNETLINK answers: File exists
Jul 16 10:56:59 cog ifup[1976]: Failed to bring up eth2name2.
Jul 16 10:56:59 cog systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
Jul 16 10:56:59 cog systemd[1]: Failed to start Raise network interfaces.
Jul 16 10:56:59 cog systemd[1]: networking.service: Unit entered failed state.
Jul 16 10:56:59 cog systemd[1]: networking.service: Failed with result 'exit-code'.

journalctl -xe 的输出

Jul 16 10:56:59 cog named[1127]: automatic empty zone: 100.51.198.IN-ADDR.ARPA
Jul 16 10:56:59 cog named[1127]: automatic empty zone: 113.0.203.IN-ADDR.ARPA
Jul 16 10:56:59 cog named[1127]: automatic empty zone: 255.255.255.255.IN-ADDR.ARPA
Jul 16 10:56:59 cog named[1127]: automatic empty zone: 0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0
Jul 16 10:56:59 cog named[1127]: automatic empty zone: 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0
Jul 16 10:56:59 cog named[1127]: automatic empty zone: D.F.IP6.ARPA
Jul 16 10:56:59 cog named[1127]: automatic empty zone: 8.E.F.IP6.ARPA
Jul 16 10:56:59 cog named[1127]: automatic empty zone: 9.E.F.IP6.ARPA
Jul 16 10:56:59 cog named[1127]: automatic empty zone: A.E.F.IP6.ARPA
Jul 16 10:56:59 cog named[1127]: automatic empty zone: B.E.F.IP6.ARPA
Jul 16 10:56:59 cog named[1127]: automatic empty zone: 8.B.D.0.1.0.0.2.IP6.ARPA
Jul 16 10:56:59 cog named[1127]: automatic empty zone: EMPTY.AS112.ARPA
Jul 16 10:56:59 cog named[1127]: reloading configuration succeeded
Jul 16 10:56:59 cog named[1127]: any newly configured zones are now loaded
Jul 16 10:56:59 cog systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
Jul 16 10:56:59 cog systemd[1]: Failed to start Raise network interfaces.
-- Subject: Unit networking.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit networking.service has failed.
-- 
-- The result is failed.
Jul 16 10:56:59 cog systemd[1]: networking.service: Unit entered failed state.
Jul 16 10:56:59 cog systemd[1]: networking.service: Failed with result 'exit-code'.
Jul 16 10:56:59 cog sudo[1958]: pam_unix(sudo:session): session closed for user root
Jul 16 10:57:07 cog dhclient[1260]: DHCPDISCOVER on eth0spectrum to 255.255.255.255 port 67 interval 1
Jul 16 10:57:22 cog dhclient[1260]: DHCPDISCOVER on eth0spectrum to 255.255.255.255 port 67 interval 1

/var/log/syslog 的输出

Jul 16 10:54:34 cog dhclient[1260]: DHCPDISCOVER on eth0spectrum to 255.255.255.255 port 67 interval 10 (xid=0x2325a874)
Jul 16 10:54:44 cog dhclient[1260]: DHCPDISCOVER on eth0spectrum to 255.255.255.255 port 67 interval 9 (xid=0x2325a874)
Jul 16 10:54:53 cog dhclient[1260]: DHCPDISCOVER on eth0spectrum to 255.255.255.255 port 67 interval 13 (xid=0x2325a874)
Jul 16 10:55:06 cog dhclient[1260]: DHCPDISCOVER on eth0spectrum to 255.255.255.255 port 67 interval 16 (xid=0x2325a874)
Jul 16 10:55:22 cog dhclient[1260]: DHCPDISCOVER on eth0spectrum to 255.255.255.255 port 67 interval 19 (xid=0x2325a874)
Jul 16 10:55:41 cog dhclient[1260]: DHCPDISCOVER on eth0spectrum to 255.255.255.255 port 67 interval 14 (xid=0x2325a874)
Jul 16 10:55:55 cog dhclient[1260]: DHCPDISCOVER on eth0spectrum to 255.255.255.255 port 67 interval 10 (xid=0x2325a874)
Jul 16 10:56:05 cog dhclient[1260]: DHCPDISCOVER on eth0spectrum to 255.255.255.255 port 67 interval 10 (xid=0x2325a874)
Jul 16 10:56:15 cog dhclient[1260]: DHCPDISCOVER on eth0spectrum to 255.255.255.255 port 67 interval 20 (xid=0x2325a874)
Jul 16 10:56:35 cog dhclient[1260]: DHCPDISCOVER on eth0spectrum to 255.255.255.255 port 67 interval 11 (xid=0x2325a874)
Jul 16 10:56:46 cog dhclient[1260]: DHCPDISCOVER on eth0spectrum to 255.255.255.255 port 67 interval 10 (xid=0x2325a874)
Jul 16 10:56:56 cog dhclient[1260]: DHCPDISCOVER on eth0spectrum to 255.255.255.255 port 67 interval 11 (xid=0x2325a874)
Jul 16 10:56:59 cog systemd[1]: Stopped Raise network interfaces.
Jul 16 10:56:59 cog systemd[1]: Starting Raise network interfaces...
Jul 16 10:56:59 cog ifup[1976]: RTNETLINK answers: File exists
Jul 16 10:56:59 cog ifup[1976]: Failed to bring up eth2name2.

有什么办法可以解决这个问题吗?任何帮助都将不胜感激。

答案1

经过一番挖掘,我发现了这个:https://ubuntuforums.org/showthread.php?t=2323253&p=13489687#post13489687

当我在桌子上构建这个时,只有两个接口处于打开状态。

在当前未使用的 DHCP 接口上临时设置虚拟静态网络解决了该问题。

相关内容