我想将我的主以太网适配器设置为静态 IP,因为 DHCP 每次在我的连接中都会出现问题。
这是我的 /etc/network/interfaces。
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto enp1s0
iface enp1s0 inet static
address 192.168.0.40
netmask 255.255.255.0
gateway 192.168.0.1
我确实重新启动了网络,services networking restart
但出现错误。
● networking.service - Raise network interfaces
Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor preset: en
Drop-In: /run/systemd/generator/networking.service.d
└─50-insserv.conf-$network.conf
Active: failed (Result: exit-code) since sun 2017-02-26 02:05:44 KST; 20s ago
Docs: man:interfaces(5)
Process: 13609 ExecStop=/sbin/ifdown -a --read-environment --exclude=lo (code=exite
Process: 13637 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=1/FA
Process: 13629 ExecStartPre=/bin/sh -c [ "$CONFIGURE_INTERFACES" != "no" ] && [ -n
Main PID: 13637 (code=exited, status=1/FAILURE)
2월 26 02:05:44 haseunggabserver systemd[1]: Starting Raise network interfaces...
2월 26 02:05:44 haseunggabserver ifup[13637]: RTNETLINK answers: File exists
2월 26 02:05:44 haseunggabserver ifup[13637]: Failed to bring up enp1s0.
2월 26 02:05:44 haseunggabserver systemd[1]: networking.service: Main process exited,
2월 26 02:05:44 haseunggabserver systemd[1]: Failed to start Raise network interfaces
2월 26 02:05:44 haseunggabserver systemd[1]: networking.service: Unit entered failed
2월 26 02:05:44 haseunggabserver systemd[1]: networking.service: Failed with result 'exit-code'. '
但是当我尝试这个时:只需#
在之前添加auto enp1s0
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
#auto enp1s0
iface enp1s0 inet static
address 192.168.0.40
netmask 255.255.255.0
gateway 192.168.0.1
networking
重启成功。
我认为我的接口文件没有任何问题...但我不知道为什么会出现这种情况。
我的 ifconfig:
enp1s0 Link encap:Ethernet HWaddr 40:8d:5c:d7:a7:0a
inet addr:192.168.0.40 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::8c37:9a69:f4f6:dd92/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:135599 errors:0 dropped:0 overruns:0 frame:0
TX packets:135766 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:14013385 (14.0 MB) TX bytes:139304076 (139.3 MB)
enp2s0 Link encap:Ethernet HWaddr 40:8d:5c:d7:a7:09
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:1015 errors:0 dropped:0 overruns:0 frame:0
TX packets:1015 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:95769 (95.7 KB) TX bytes:95769 (95.7 KB)
有什么办法可以解决这个问题吗?问候。