howto add ip address to server

From WebHostingNeeds.com
Jump to: navigation, search

Here is how to a range of IP's to server. This method will work only if you don't have added IP one by one using configuration file for each IP, if you have them, you need to remove them first.

Back up, then delete all files matching /etc/sysconfig/network-scripts/ifcfg-eth?:*

My server have one IP now.

[[email protected] network-scripts]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0B:6A:AB:14:A9
          inet addr:66.90.101.78  Bcast:66.90.101.255  Mask:255.255.255.0
          inet6 addr: fe80::20b:6aff:feab:14a9/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:37215449 errors:0 dropped:0 overruns:0 frame:0
          TX packets:18067520 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1067039279 (1017.6 MiB)  TX bytes:2104800475 (1.9 GiB)
          Interrupt:193 Base address:0xd400

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:210458 errors:0 dropped:0 overruns:0 frame:0
          TX packets:210458 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:16963769 (16.1 MiB)  TX bytes:16963769 (16.1 MiB)

[[email protected] network-scripts]#


I need to add following IP's to the server.

208.53.161.106
208.53.161.107
208.53.161.108
208.53.161.109
208.53.161.110
mask 255.255.255.248

Create a file /etc/sysconfig/network-scripts/ifcfg-eth0-range0 with following content

vi /etc/sysconfig/network-scripts/ifcfg-eth0-range0
IPADDR_START=208.53.161.106
IPADDR_END=208.53.161.110
CLONENUM_START=0

Now restart network service.

service network restart

Do not stop and start, if you stopped it, you will be logged off and will not able to start again and will require a reboot.

[[email protected] network-scripts]# service network restart
Shutting down interface eth0:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:                                [  OK  ]
[[email protected] network-scripts]#

Now lets check the ip addresses configured on the server with ifconfig command.

[[email protected] ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0B:6A:AB:14:A9
          inet addr:66.90.101.78  Bcast:66.90.101.255  Mask:255.255.255.0
          inet6 addr: fe80::20b:6aff:feab:14a9/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:37257388 errors:0 dropped:0 overruns:0 frame:0
          TX packets:18097277 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1072492167 (1022.8 MiB)  TX bytes:2143263121 (1.9 GiB)
          Interrupt:193 Base address:0xd400

eth0:0    Link encap:Ethernet  HWaddr 00:0B:6A:AB:14:A9
          inet addr:208.53.161.106  Bcast:208.53.161.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:193 Base address:0xd400

eth0:1    Link encap:Ethernet  HWaddr 00:0B:6A:AB:14:A9
          inet addr:208.53.161.107  Bcast:208.53.161.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:193 Base address:0xd400

eth0:2    Link encap:Ethernet  HWaddr 00:0B:6A:AB:14:A9
          inet addr:208.53.161.108  Bcast:208.53.161.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:193 Base address:0xd400

eth0:3    Link encap:Ethernet  HWaddr 00:0B:6A:AB:14:A9
          inet addr:208.53.161.109  Bcast:208.53.161.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:193 Base address:0xd400

eth0:4    Link encap:Ethernet  HWaddr 00:0B:6A:AB:14:A9
          inet addr:208.53.161.110  Bcast:208.53.161.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:193 Base address:0xd400

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:211038 errors:0 dropped:0 overruns:0 frame:0
          TX packets:211038 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:17011449 (16.2 MiB)  TX bytes:17011449 (16.2 MiB)

[[email protected] ~]#

You can see the extra IP's now on ifconfig.