我有 Ubuntu 17.04。我在 ifconfig 上看到我有 eno1(不是 eth0)。我创建了 vlan,它正在工作(我可以从该 vlan ping 设备)。但实际上我看到那台计算机连接到两个网络。
eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.1.1.52 netmask 255.255.255.0 broadcast 10.1.1.255
inet6 fe80::21fb:881b:982f:a314 prefixlen 64 scopeid 0x20<link>
ether 34:17:eb:cd:2e:0d txqueuelen 1000 (Ethernet)
RX packets 13464458 bytes 1276532566 (1.2 GB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 14381729 bytes 996608618 (996.6 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 20 memory 0xf7c00000-f7c20000
eno1.90: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.66.64.10 netmask 255.255.252.0 broadcast 10.66.66.255
inet6 fe80::3617:ebff:fecd:2e0d prefixlen 64 scopeid 0x20<link>
ether 34:17:eb:cd:2e:0d txqueuelen 1000 (Ethernet)
RX packets 1157363 bytes 48659026 (48.6 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1375778 bytes 79131321 (79.1 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
我需要更改此设置。PC 应该只在 vlan90 上工作。我的意思是 vlan 90 将在 eno1 上提供服务,而不是在子接口 eno1.90 上。无需连接到“管理网络”。
网络 10.1.1.0/24 未标记。网络 10.66.64.0/22 已标记。
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto eno1.90
iface eno1.90 inet static
address 10.66.64.9
netmask 255.255.252.0
network 10.66.64.0
broadcast 10.66.66.255
mtu 1500
vlan-raw-device eno1
我禁用网络管理器:
● NetworkManager.service - Network Manager
Loaded: loaded (/lib/systemd/system/NetworkManager.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Tue 2017-07-11 08:45:50 CEST; 52s ago
Docs: man:NetworkManager(8)
Main PID: 999 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/NetworkManager.service
└─10450 /sbin/dhclient -d -q -sf /usr/lib/NetworkManager/nm-dhcp-helper -pf /var/run/dhcli
lip 11 07:22:42 user NetworkManager[999]: <info> [1499750562.7541] dhcp4 (eno1): lease ti
lip 11 07:22:42 user NetworkManager[999]: <info> [1499750562.7541] dhcp4 (eno1): nameserv
lip 11 07:22:42 user NetworkManager[999]: <info> [1499750562.7542] dhcp4 (eno1): nameserv
lip 11 07:22:42 user NetworkManager[999]: <info> [1499750562.7542] dhcp4 (eno1): domain n
lip 11 07:22:42 user NetworkManager[999]: <info> [1499750562.7542] dhcp4 (eno1): state chan
lip 11 07:22:42 user dhclient[10450]: bound to 10.1.1.52 -- renewal in 14027 seconds.
lip 11 08:45:50 user systemd[1]: Stopping Network Manager...
lip 11 08:45:50 user NetworkManager[999]: <info> [1499755550.2979] caught SIGTERM, shutting
lip 11 08:45:50 user NetworkManager[999]: <info> [1499755550.2987] exiting (success)
lip 11 08:45:50 user systemd[1]: Stopped Network Manager.
我在界面上添加了新的配置:
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto eno1
#iface eno1 inet dhcp
iface eno1 inet manual
# address 10.1.1.250
# netmask 255.255.255.0
# gateway 10.1.1.253
# network 10.1.1.0
# broadcast 10.1.1.255
# mtu 1500
auto eno1.90
iface eno1.90 inet static
address 10.66.64.9
netmask 255.255.252.0
gateway 10.1.1.1
network 10.66.64.0
broadcast 10.66.66.255
mtu 1500
vlan-raw-device eno1
但重启 NM 后什么都没发生,所以我再次禁用它。下一步我关闭了接口,然后再次打开它。之后我看到它似乎开始工作了,因为我无法从 10.1.1.0/24 网络 ping 设备。但当我使用 ifconfig 时,我看到的信息与 top 中的信息相同。
现在我发现我的网络服务遇到了一些问题,也许这是 IP 地址冻结的原因?
● networking.service - Raise network interfaces
Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor prese
Active: failed (Result: exit-code) since Fri 2017-07-14 16:45:41 CEST; 1min 5
Docs: man:interfaces(5)
Main PID: 15424 (code=exited, status=1/FAILURE)
lip 14 16:45:34 user systemd[1]: Starting Raise network interfaces...
lip 14 16:45:41 user ifup[15424]: Set name-type for VLAN subsystem. Sho
lip 14 16:45:41 user ifup[15424]: RTNETLINK answers: File exists
lip 14 16:45:41 user ifup[15424]: Failed to bring up eno1.90.
lip 14 16:45:41 user systemd[1]: networking.service: Main process exite
lip 14 16:45:41 user systemd[1]: Failed to start Raise network interfac
lip 14 16:45:41 user systemd[1]: networking.service: Unit entered faile
lip 14 16:45:41 user systemd[1]: networking.service: Failed with result
2017/07/17 我认为我只是解决了第一个问题。我首先使用方法 #2https://www.cyberciti.biz/tips/howto-configure-linux-virtual-local-area-network-vlan.html所以我有必要的设置。我删除它,使用
# ifconfig eno1.90 down
# vconfig rem eno1.90
之后我关闭了接口,然后重新启动网络服务(它启动了,没有错误),然后启动了接口。现在/proc/net/vlan
创建了文件 eno1.90。所以我认为配置现在是正确的。也许主接口是一样的,因为当我用静态选项设置接口时:
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto eno1
#iface eno1 inet dhcp
#iface eno1 inet manual
iface eno1 inet static
address 10.1.1.250
netmask 255.255.255.0
gateway 10.1.1.253
# network 10.1.1.0
# broadcast 10.1.1.255
# mtu 1500
auto eno1.90
iface eno1.90 inet static
address 10.66.64.9
netmask 255.255.252.0
gateway 10.1.1.1
network 10.66.64.0
broadcast 10.66.66.255
mtu 1500
vlan-raw-device eno1
ifconfig 仍然显示我有 IP 10.1.1.52
,而实际上应该有10.1.1.250
。此外,我可以使用这两个地址 ping PC(它响应 .52 和 .250):D 但我不知道如何修复它。
答案1
您可以禁用eno1
。它由网络管理器启动。
您可以通过禁用网络管理器或添加来修复此问题
iface eno1 inet manual
至/etc/network/interfaces
。NM 不会处理 中声明的任何接口interfaces
。
要应用此设置运行
sudo systemctl restart network-manager
答案2
我认为我已经解决了问题。我首先使用方法 #2https://www.cyberciti.biz/tips/howto-configure-linux-virtual-local-area-network-vlan.html所以我有必要的设置。我删除它,使用
# ifconfig eth0.90 down
# vconfig rem eth0.90
之后我关闭了接口,然后重新启动网络服务(它启动了,没有错误),然后启动了接口。现在/proc/net/vlan
创建了文件eno1.90
。所以我认为配置现在是正确的。