网卡的子接口(1个网卡多个IP地址)
这里本人用虚拟机给大家演示一下。
配置之前为
vim /etc/sysconfig/network-scripts/ifcfg-ens33
步骤:
cp /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-ens33:0
sed -i 's/DEVICE="ens33"/DEVICE="ens33:0"/' /etc/sysconfig/network-scripts/ifcfg-ens33:0
sed -i 's/NAME="ens33"/NAME="ens33:0/' /etc/sysconfig/network-scripts/ifcfg-ens33:0
sed -i 's/IPADDR=192.168.86.138/IPADDR=192.168.86.3/' /etc/sysconfig/network-scripts/ifcfg-ens33:0
cp /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-ens33:1
sed -i 's/DEVICE="ens33"/DEVICE="ens33:1"/' /etc/sysconfig/network-scripts/ifcfg-ens33:1
sed -i 's/NAME="ens33"/NAME="ens33:1/' /etc/sysconfig/network-scripts/ifcfg-ens33:1
sed -i 's/IPADDR=192.168.86.138/IPADDR=192.168.86.4/' /etc/sysconfig/network-scripts/ifcfg-ens33:1
cp /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-ens33:2
sed -i 's/DEVICE="ens33"/DEVICE="ens33:2"/' /etc/sysconfig/network-scripts/ifcfg-ens33:2
sed -i 's/NAME="ens33"/NAME="ens33:2/' /etc/sysconfig/network-scripts/ifcfg-ens33:2
sed -i 's/IPADDR=192.168.86.138/IPADDR=192.168.86.5/' /etc/sysconfig/network-scripts/ifcfg-ens33:2
systemctl restart network
配置完成。
版权声明:本文为m0_49190412原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
THE END