1. 進入目錄:cd /etc/sysconfig/network-scripts/ 2. 使用vi命令編輯ifcfg-eth0,如下: DEVICE=eth0 BOOTPROTO=static BROADCAST=192.168.0.255 HWADDR=00:0C:29:25:96:A3 #第1個IP IPADDR=192.168.0.2 NETMASK=255.255.255.0 NETWORK=192.168.0.0 ONBOOT=yes GATEWAY=192.168.0.1
3. 保存退出,然后再拷貝一個ifcfg-eth0,如: cp ifcfg-eth0 ifcfg-eth1 4. 使用vi命令編輯ifcfg-eth1,如: #注意:設(shè)備還是eth0 DEVICE=eth0 BOOTPROTO=static BROADCAST=192.168.0.255 HWADDR=00:0C:29:25:96:A3 #第二個IP IPADDR=192.168.0.3 NETMASK=255.255.255.0 NETWORK=192.168.0.0 ONBOOT=yes
5.重啟網(wǎng)卡 service network restart
=========子接口方式============= 1. 進入目錄:cd /etc/sysconfig/network-scripts/ 2.復(fù)制網(wǎng)卡配置文件: cp ifcfg-eth0 ifcfg-eth0:0
ifcfg-eth0文件內(nèi)容 ------------------------- DEVICE=eth0 BOOTPROTO=static BROADCAST=192.168.0.255 HWADDR=00:0C:29:25:96:A3 #第1個IP IPADDR=192.168.0.2 NETMASK=255.255.255.0 NETWORK=192.168.0.0 ONBOOT=yes GATEWAY=192.168.0.1 ------------------------------
ifcfg-eth0:0文件內(nèi)容 ----------------------------- DEVICE=eth0:0 BOOTPROTO=static BROADCAST=192.168.0.255 HWADDR=00:0C:29:25:96:A3 #第1個IP IPADDR=192.168.0.3 NETMASK=255.255.255.0 NETWORK=192.168.0.0 ONBOOT=yes GATEWAY=192.168.0.1 |