Description
This howto will show you how to add multiple IP addresses to a single NIC on your Centos system.
Requirements
Explanation of requirements.
- Root access to the system
- A working network with at least 2 computers.
Doing the Work
Basic description of what will be done and what is expected.
- Make a copy of the interfaces config script:
- Edit the newly created alias and remove the HWADDR line, save and exit vi (esc :qw):
- Restart the network:
cat /etc/sysconfig/network-scripts/ifcfg-eth0 > /etc/sysconfig/network-scripts/ifcfg-eth0:1
vi /etc/sysconfig/network-scripts/ifcfg-eth0:1
1 2 3 4 5 6 7 8 9 10 11 |
# Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ <-- REMOVE THIS LINE DEVICE=eth0:1 <-- CHANGE THIS LINE BOOTPROTO=none BROADCAST=192.168.1.255 HWADDR=00:15:8F:9F:21:E6 <-- REMOVE THIS LINE IPADDR=192.168.1.5 <strong> <-- CHANGE THIS TO THE NEW IP NETMASK=255.255.254.0 NETWORK=192.168.1.0 ONBOOT=yes GATEWAY=192.168.1.1 TYPE=Ethernet |
C6: service network restart
or service NetworkManager restart
C7: systemctl restart network.service
or systemctl restart NetworkManager.service
Troubleshooting
How to test
Explanation troubleshooting basics and expectations.
- use ifconfig to see the currently configured interfaces:
- Ping the IPs to test:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
eth0 Link encap:Ethernet HWaddr 00:15:8F:9F:21:E6 inet addr:192.168.1.4 Bcast:192.168.1.255 Mask:255.255.254.0 inet6 addr: fe80::213:8fff:fe9e:31e6/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:61557428 errors:36898 dropped:94634 overruns:17643 frame:0 TX packets:56608276 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:2226223836 (2.0 GiB) TX bytes:1019572576 (972.3 MiB) Interrupt:201 Base address:0xc00 eth0:1 Link encap:Ethernet HWaddr 00:15:8F:9F:21:E6 inet addr:192.168.1.5 Bcast:192.168.1.255 Mask:255.255.254.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 Interrupt:201 Base address:0xc00 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:461180 errors:0 dropped:0 overruns:0 frame:0 TX packets:461180 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:270762863 (258.2 MiB) TX bytes:270762863 (258.2 MiB) |
From a computer other than 192.168.1.4 or 192.168.1.5 issue the following commands and examine the output which should be similar to the examples below:
ping 192.168.1.4
1 2 3 4 5 6 7 |
PING 192.168.1.4 (192.168.1.4) 56(84) bytes of data. 64 bytes from 192.168.1.4: icmp_seq=1 ttl=64 time=0.050 ms 64 bytes from 192.168.1.4: icmp_seq=2 ttl=64 time=0.039 ms --- 192.168.1.4 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 999ms rtt min/avg/max/mdev = 0.039/0.044/0.050/0.008 ms |
ping 192.168.1.5
1 2 3 4 5 6 7 |
PING 192.168.1.5 (192.168.1.5) 56(84) bytes of data. 64 bytes from 192.168.1.5: icmp_seq=1 ttl=64 time=3.81 ms 64 bytes from 192.168.1.5: icmp_seq=2 ttl=64 time=6.77 ms --- 192.168.1.5 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1000ms rtt min/avg/max/mdev = 3.815/5.296/6.778/1.483 ms |
Disclaimer
We test this stuff on our own machines, really we do. But you may run into problems, if you do, come to #centoshelp on irc.freenode.net