请帮助我将网络恢复到我的服务器,基本上,我无法执行诸如此类的操作sudo apt update, git pull
,只是连接超时。
我的网络服务“失败”,无法工作,当我尝试启动它时sudo /etc/init.d/networking start
,它给出以下信息:
Starting 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!
如果我尝试重新加载它,sudo /etc/init.d/networking reload
:
Reloading network interfaces configuration...
ifup: no interface(s) specified
ifup: Use --help for help
如果我这么做,sudo ifup --all
我得到的是:
/etc/network/if-up.d/sendmail: 44: .: Can't open /usr/share/sendmail/dynamic
run-parts: /etc/network/if-up.d/sendmail exited with return code 2
Failed to bring up lo.
RTNETLINK answers: File exists
Failed to bring up eth0.
RTNETLINK answers: File exists
Failed to bring up eth0:0.
/etc/network/if-up.d/sendmail: 44: .: Can't open /usr/share/sendmail/dynamic
run-parts: /etc/network/if-up.d/sendmail exited with return code 2
ifup: post-up script failed.*\
这是我的接口文件:
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet dhcp
这是sudo /etc/init.d/networking status
:
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
/etc/systemd/system/networking.service.d
└─override.conf
Active: **failed** (Result: exit-code) since Wed 2019-05-08 16:12:22 EDT; 5min ago
Docs: man:interfaces(5)
Process: 19969 ExecStart=/sbin/ifup -a --read-environment **(code=exited, status=1/FAILURE)**
Process: 19961 ExecStartPre=/bin/sh -c [ "$CONFIGURE_INTERFACES" != "no" ] && [ -n "$(ifquery --read-environment --list --exclude=lo)" ] && udevadm settle (code=exited, status=0/SUCCESS)
Main PID: 19969 (code=exited, status=1/FAILURE)
May 08 16:12:22 s....secureserver.net ifup[19969]: Failed to bring up eth0.
May 08 16:12:22 s....secureserver.net ifup[19969]: RTNETLINK answers: File exists
May 08 16:12:22 s....secureserver.net ifup[19969]: Failed to bring up eth0:0.
May 08 16:12:22 s....secureserver.net ifup[19969]: /etc/network/if-up.d/sendmail: 44: .: Can't open /usr/share/sen...namic
May 08 16:12:22 s....secureserver.net ifup[19969]: run-parts: /etc/network/if-up.d/sendmail exited with return code 2
May 08 16:12:22 s....secureserver.net systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
May 08 16:12:22 s....secureserver.net ifup[19969]: /sbin/ifup: post-up script failed.
May 08 16:12:22 s....secureserver.net systemd[1]: **Failed to start Raise network interfaces.**
May 08 16:12:22 s....secureserver.net systemd[1]: networking.service: Unit entered failed state.
May 08 16:12:22 s....secureserver.net systemd[1]: networking.service: Failed with result 'exit-code'.
Hint: Some lines were ellipsized, use -l to show in full.
ifconfig -a
:
eth0 Link encap:Ethernet HWaddr ****************
inet addr:************ Bcast:************** Mask:255.255.*******
inet6 addr: *********************** Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:**** Metric:1
RX packets:2973672 errors:0 dropped:85624 overruns:0 frame:0
TX packets:203653 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:244631493 (244.6 MB) TX bytes:117977760 (117.9 MB)
eth0:0 Link encap:Ethernet HWaddr *****************
inet addr:**************** Bcast:**************** Mask:255.255.255.255
UP BROADCAST RUNNING MULTICAST MTU:**** Metric:1
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::****** Scope:Host
UP LOOPBACK RUNNING MTU:******* Metric:1
RX packets:99855 errors:0 dropped:0 overruns:0 frame:0
TX packets:99855 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:38028421 (38.0 MB) TX bytes:38028421 (38.0 MB)
答案1
#!/bin/bash
sudo ip addr flush dev lo
sudo ifdown --all
sudo ifup --all
sudo service networking restart