Linux 创建网卡子接口

创建网卡子接口,添加IP别名

ifconfig eth0:0  2.2.2.2/24

ip addr add 2.2.2.2/24 dev eth0 label eth0:0

清除网卡子接口,删除IP别名

ifconfig eth0:1 down

ip addr del 2.2.2.2/24 dev eth0 label eth0:0

配置成功后,ifconfig查看:

如果想让配置永久生效,创建/etc/sysconfig/network-scripts/ifcfg-eth0:0,添加:

DEVICE=eth0:0
IPADDR=2.2.2.2
PREFIX=24
ONPARENT=yes

系统重启子接口依然存在 

原文地址:https://www.cnblogs.com/reachos/p/12167744.html