Showing posts with label two ips on one network card. Show all posts
Showing posts with label two ips on one network card. Show all posts

Monday, March 23, 2009

Put two IP addresses on one NIC

Here is how to have two IPs using one network card in linux.


In the directory /etc/sysconfig/networking/devices

Create the following new file by typing "vi ifcfg-eth0:0"

DEVICE=eth0:0
BOOTPROTO=none
IPADDR=192.168.1.23 # your second IP
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
TYPE=Ethernet
ONPARENT=yes

Next, in the directory /etc/sysconfig/networking/profiles/default

create the same file again by typing "vi ifcfg-eth0:0"

DEVICE=eth0:0
BOOTPROTO=none
IPADDR=192.168.1.14 # your second IP
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
TYPE=Ethernet
ONPARENT=yes


now, bounce networking with "service networking restart" and use ifconfig to see if the net interface shows up...

[root@mail default]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:13:72:52:3A:2C
inet addr:192.168.1.23 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:211994158 errors:2 dropped:0 overruns:0 frame:1
TX packets:1031665949 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:898868933 (857.2 MiB) TX bytes:245145424 (233.7 MiB)
Base address:0xecc0 Memory:fe6e0000-fe700000

eth0:0 Link encap:Ethernet HWaddr 00:13:72:52:3A:2C
inet addr:192.168.1.14 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Base address:0xecc0 Memory:fe6e0000-fe700000

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:45061099 errors:0 dropped:0 overruns:0 frame:0
TX packets:45061099 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3353720043 (3.1 GiB) TX bytes:3353720043 (3.1 GiB)