CentOS中所有的设备都是文件.网卡也在文件中定义.
IP的绑定也只需要更改文件.
网卡相关文件在目录:/etc/sysconfig/network-scripts
查询当前IP信息:
ifconfig:
eth0Linkencap:EthernetHWaddr00:50:56:AC:6B:0F
inetaddr:42.51.135.206Bcast:42.51.135.255Mask:255.255.255.0
inet6addr:fe80::250:56ff:fead:6b0f/64Scope:Link
UPBROADCASTRUNNINGMULTICASTMTU:1500Metric:1
RXpackets:374772errors:0dropped:0overruns:0frame:0
TXpackets:35165errors:0dropped:0overruns:0carrier:0
collisions:0txqueuelen:1000
RXbytes:28759089(27.4MiB)TXbytes:4779278(4.5MiB)
在当前目录下有文件:
ifcfg-eth0
在目录下新建文件:
ifcfg-eth0:1
内容如下:
DEVICE=eth0:1
IPADDR=42.51.138.1
NETMASK=255.255.255.0
HWADDR=00:50:56:AC:6B:0F
NM_CONTROLLED=yes
ONBOOT=yes
BOOTPROTO=dhcp
TYPE=Ethernet
IPV6INIT=no
USERCTL=no
ifcfg-eth0:2
DEVICE=eth0:2
IPADDR=42.51.138.2
NETMASK=255.255.255.0
HWADDR=00:50:56:AC:6B:0F
NM_CONTROLLED=yes
ONBOOT=yes
BOOTPROTO=dhcp
TYPE=Ethernet
IPV6INIT=no
USERCTL=no
ifcfg-eth0:3
DEVICE=eth0:3
IPADDR=42.51.138.3
NETMASK=255.255.255.0
HWADDR=00:50:56:AC:6B:0F
NM_CONTROLLED=yes
ONBOOT=yes
BOOTPROTO=dhcp
TYPE=Ethernet
IPV6INIT=no
USERCTL=no
重启网卡:
servicenetworkrestart
这时候再查看IP:
eth0Linkencap:EthernetHWaddr00:50:56:AC:6B:0F
inetaddr:42.51.135.206Bcast:42.51.135.255Mask:255.255.255.0
inet6addr:fe80::250:56ff:fead:6b0f/64Scope:Link
UPBROADCASTRUNNINGMULTICASTMTU:1500Metric:1
RXpackets:384344errors:0dropped:0overruns:0frame:0
TXpackets:35241errors:0dropped:0overruns:0carrier:0
collisions:0txqueuelen:1000
RXbytes:29462159(28.0MiB)TXbytes:4791402(4.5MiB)
eth0:1Linkencap:EthernetHWaddr00:50:56:AC:6B:0F
inetaddr:42.51.138.1Bcast:42.51.138.255Mask:255.255.255.0
UPBROADCASTRUNNINGMULTICASTMTU:1500Metric:1
eth0:2Linkencap:EthernetHWaddr00:50:56:AC:6B:0F
inetaddr:42.51.138.2Bcast:42.51.138.255Mask:255.255.255.0
UPBROADCASTRUNNINGMULTICASTMTU:1500Metric:1
eth0:3Linkencap:EthernetHWaddr00:50:56:AC:6B:0F
inetaddr:42.51.138.3Bcast:42.51.138.255Mask:255.255.255.0
UPBROADCASTRUNNINGMULTICASTMTU:1500Metric:1
测试:
在其它机器上分别ping上面几个IP.