[root@vm257 network-scripts]# cat ifcfg-eth1.25
NAME=eth1.25
DEVICE=eth1.25
BOOTPROTO=static
IPADDR=192.168.25.54
NETMASK=255.255.255.0
GATEWAY=192.168.25.254
ONBOOT=yes
VLAN=yes
--------------------以上为验证配置
Centos7-1811测试
TYPE=Vlan
VLAN_ID=2000
俩参数无效,以文件名为VLANID。
ip a生成新的网卡子接口
18: eth1.25@eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 06:76:8b:13:46:a2 brd ff:ff:ff:ff:ff:ff
inet 192.168.25.54/24 brd 192.168.25.255 scope global eth1.25
valid_lft forever preferred_lft forever
inet6 fe80::476:8bff:fe13:46a2/64 scope link
valid_lft forever preferred_lft forever
[root@vm257 network-scripts]# systemctl status network.service -l
● network.service - LSB: Bring up/down networking
Loaded: loaded (/etc/rc.d/init.d/network; bad; vendor preset: disabled)
Active: failed (Result: exit-code) since 三 2022-02-23 16:43:21 CST; 13s ago
Docs: man:systemd-sysv-generator(8)
Process: 3104 ExecStop=/etc/rc.d/init.d/network stop (code=exited, status=0/SUCCESS)
Process: 4876 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=1/FAILURE)
Tasks: 3
CGroup: /system.slice/network.service
├─3778 /sbin/dhclient -1 -q -lf /var/lib/dhclient/dhclient--eth0.lease -pf /var/run/dhclient-eth0.pid -H vm257 eth0
├─3914 /sbin/dhclient -1 -q -lf /var/lib/dhclient/dhclient--eth1.lease -pf /var/run/dhclient-eth1.pid -H vm257 eth1
└─4071 /sbin/dhclient -1 -q -lf /var/lib/dhclient/dhclient--eth1.20.lease -pf /var/run/dhclient-eth1.20.pid -H vm257 eth1.20
2月 23 16:43:21 vm257 network[4876]: RTNETLINK answers: File exists
2月 23 16:43:21 vm257 network[4876]: RTNETLINK answers: File exists
2月 23 16:43:21 vm257 network[4876]: RTNETLINK answers: File exists
2月 23 16:43:21 vm257 network[4876]: RTNETLINK answers: File exists
2月 23 16:43:21 vm257 network[4876]: RTNETLINK answers: File exists
2月 23 16:43:21 vm257 network[4876]: RTNETLINK answers: File exists
2月 23 16:43:21 vm257 systemd[1]: network.service: control process exited, code=exited status=1
2月 23 16:43:21 vm257 systemd[1]: Failed to start LSB: Bring up/down networking.
2月 23 16:43:21 vm257 systemd[1]: Unit network.service entered failed state.
2月 23 16:43:21 vm257 systemd[1]: network.service failed.
RTNETLINK answers: File exists
此报错如果采DHCP获取IP
删除
/var/lib/dhclient/dhclient–eth0.lease
/var/run/dhclient-eth0.pid
以及killall dhclient 进程。
确保ifcfg-eth之类文件内配置正确。
Centos7不存在/etc/udev/rules.d/70-XXX规则限制。