All the devices in the CentOS are files. The NIC is also defined in the file.
The binding of IP also requires only changes to the file.
Network card related files in directory:/etc/sysconfig/network-scripts
Querying Current IP information:
Ifconfig
Eth0 Link encap:ethernet hwaddr 00:50:56:ac:6b:0f
inet addr:42.51.135.206 bcast:42.51.135.255 mask:255.255.255.0
Inet6 ADDR:FE80::250:56FF:FEAD:6B0F/64 Scope:link
Up broadcast RUNNING multicast mtu:1500 metric:1
RX packets:374772 errors:0 dropped:0 overruns:0 frame:0
TX packets:35165 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:28759089 (27.4 MiB) TX bytes:4779278 (4.5 MiB)
There are files in the current directory:
Ifcfg-eth0
To create a new file in the directory:
Ifcfg-eth0:1
The contents are as follows:
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
To reboot the network card:
Service Network restart
Then look at the IP:
Eth0 Link encap:ethernet hwaddr 00:50:56:ac:6b:0f
inet addr:42.51.135.206 bcast:42.51.135.255 mask:255.255.255.0
Inet6 ADDR:FE80::250:56FF:FEAD:6B0F/64 Scope:link
Up broadcast RUNNING multicast mtu:1500 metric:1
RX packets:384344 errors:0 dropped:0 overruns:0 frame:0
TX packets:35241 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:29462159 (28.0 MiB) TX bytes:4791402 (4.5 MiB)
Eth0:1 Link encap:ethernet hwaddr 00:50:56:ac:6b:0f
inet addr:42.51.138.1 bcast:42.51.138.255 mask:255.255.255.0
Up broadcast RUNNING multicast mtu:1500 metric:1
Eth0:2 Link encap:ethernet hwaddr 00:50:56:ac:6b:0f
inet addr:42.51.138.2 bcast:42.51.138.255 mask:255.255.255.0
Up broadcast RUNNING multicast mtu:1500 metric:1
Eth0:3 Link encap:ethernet hwaddr 00:50:56:ac:6b:0f
inet addr:42.51.138.3 bcast:42.51.138.255 mask:255.255.255.0
Up broadcast RUNNING multicast mtu:1500 metric:1
Test:
Ping the above several IP on the other machine separately.