例题1 配置基于IP的虚拟主机
1. 配置虚拟网络接口
[root@localhost ~]# ifconfig eth0:1 192.168.0.111 up [root@localhost ~]# ifconfig eth0:2 192.168.0.222 up
如果希望实现永久配置,需要创建并改写ifcfg-eth0:1和ifcfg-eth0:2文件
创建ifcfg-eth0:1和ifcfg-eth0:2文件,复制ifcfg-eth0文件内容到这两个文件中,并将其中设备名和IP地址做如图1,图2所示的修改
[root@localhost ~]#cd /etc/sysconfig/network-scripts/ [root@localhost network-scripts]# cp ifcfg-eth0 ifcfg-eth0:1 [root@localhost network-scripts]# cp ifcfg-eth0 ifcfg-eth0:2 [root@localhost network-scripts]# vi ifcfg-eth0:1
图1 ifcfg-eth0:1内容
[root@localhost network-scripts]# vi ifcfg-eth0:2