手动网络配置在 Ubuntu 16.04 中不起作用

手动网络配置在 Ubuntu 16.04 中不起作用

好吧,我通过 Network-Manager 使用了网络管理器。出于某种原因,我必须将相同的配置放入其中/etc/network/interfcaes。这是ifconfig更改之前的结果

enp0s17   Link encap:Ethernet  HWaddr 08:00:27:d4:30:fe  
          inet addr:10.1.178.177  Bcast:10.1.178.255  Mask:255.255.255.0
          inet6 addr: fe80::b077:68e:9963:1b54/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:7053 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3514 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:8356545 (8.3 MB)  TX bytes:299049 (299.0 KB)

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:251 errors:0 dropped:0 overruns:0 frame:0
          TX packets:251 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:25485 (25.4 KB)  TX bytes:25485 (25.4 KB)

使用与参考相同的配置,我创建了一个新/etc/network/interfaces文件

auto lo
iface lo inet loopback

auto enp0s1
iface enp0s1 inet static
address 10.1.178.179
netmask 255.255.255.0
getway 10.1.178.1

我对接口名称做了一点小改动。enp0s17我尝试使用enp0s1enp0s17:1(虚拟接口是我要去的地方)。

但是,我无法采用此配置。我已经完成了,

首先,我做到了systemctl stop network-manager && systemctl restart networking

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 2016-10-05 18:17:56 IST; 20min ago
     Docs: man:interfaces(5)
  Process: 15599 ExecStop=/sbin/ifdown -a --read-environment (code=exited, status=0/SUCCESS)
  Process: 16189 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=1/FAILURE)
  Process: 16183 ExecStartPre=/bin/sh -c [ "$CONFIGURE_INTERFACES" != "no" ] && [ -n "$(ifquery --read-environment --list   --exclude=lo)" ] &&     
 Main PID: 16189 (code  =exited, status=1/FAILURE)

Oct 05 18:17:56 souvik-VirtualBox systemd[1]: Starting Raise network interfaces...
Oct 05 18:17:56 souvik-VirtualBox ifup[16189]: Cannot find device "enp0s1"
Oct 05 18:17:56 souvik-VirtualBox ifup[16189]: Failed to bring up enp0s1.
Oct 05 18:17:56 souvik-VirtualBox systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
Oct 05 18:17:56 souvik-VirtualBox systemd[1]: Failed to start Raise network interfaces.
Oct 05 18:17:56 souvik-VirtualBox systemd[1]: networking.service: Unit entered failed state.
Oct 05 18:17:56 souvik-VirtualBox systemd[1]: networking.service: Failed with result 'exit-code'.

此外我尝试ifdown enp0s17 --force成功,验证为

$ cat /run/network/ifstate
lo=lo

随后ifup enp0s1 --verbose --force,结果

Configuring interface enp0s1=enp0s1 (inet)
/bin/run-parts --exit-on-error --verbose /etc/network/if-pre-up.d
run-parts: executing /etc/network/if-pre-up.d/ethtool
run-parts: executing /etc/network/if-pre-up.d/wireless-tools
run-parts: executing /etc/network/if-pre-up.d/wpasupplicant
/bin/ip addr add 10.1.178.177/255.255.255.0 broadcast 10.1.178.255    dev enp0s1 label enp0s1
Cannot find device "enp0s1"
Failed to bring up enp0s1.

任何帮助,将不胜感激。

更新

阅读后 和这个udev,我的问题范围已经缩小了。如何重新发送由like fromenp0s17分配的网络接口名称enp0s1

并且,我如何继续添加虚拟网络接口(又名网络别名),因为它们将需要新的名称enps01:1enp0s1:2同样?

此外,我缺少下面的规则文件/etc/udev/rules.d,也无法重新生成它。有点类似于这个帖子

此外

可以使用网络管理器在 GUI 中添加网络别名,例如。如何在 CLI 中完成此操作,因为服务器不应该有 GUI。

相关内容