LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to Assign more than one IP in redhat linux (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-assign-more-than-one-ip-in-redhat-linux-780897/)

rasa 01-08-2010 01:24 PM

How to Assign more than one IP in redhat linux
 
Hi,

I am using RHEL 5 or 5.5 version as my os. I want to assign more than one ip for that machine. I am very new to linux. Please guide me to do the same.


Thanks and Regards
Rasa

r3sistance 01-08-2010 01:38 PM

Hi,

The easy way to do this is to create a virtual interface/reference and assign the additional ips to them.

For CLI I use the method of copying the ifcfg-eth0 file in /etc/sysconfig/network-scripts/ the ifcfg-eth0 file should appear similar to the below copy (I have edited all networking information to private/reserved lan IPs).

Code:

DEVICE=eth0
BOOTPROTO=static
BROADCAST=192.168.1.255
HWADDR=xx:xx:xx:xx:xx:xx
IPADDR=192.168.1.3
GATEWAY=192.168.1.1
NETMASK=255.255.255.0
NETWORK=255.255.1.0
ONBOOT=yes

I will call the copy something like ifcfg-eth0:1 and then opening the file you change the device to eth0:1, change the IP information as required and remove the HWADDR field as this should not be required and depending on the networking configuration other details may also not be required (I.E. Gateway). I have given a simple configuration below of the ifcfg-eth0:1 configuration, you will note the only change is the IP what has gone from a .3 to a .12.

Code:

DEVICE=eth0:1
BOOTPROTO=static
BROADCAST=192.168.1.255
IPADDR=192.168.1.12
GATEWAY=192.168.1.1
NETMASK=255.255.255.0
NETWORK=255.255.1.0
ONBOOT=yes


abefroman 01-08-2010 02:10 PM

Or have a shell script to add the ips with ifconfig when the box boots.

rasa 01-08-2010 11:12 PM

Thanks to Both of you. One more question i have i made all the changes as you said and then i gave ifconfig ip (tried both ips) but it is giving the o/p as xxx.x.x.x: error fetching interface information: Device not found (xxx.x.x.x - is the ip which i have given as the parameter), i am really new to Linux admin side so i dont know whether the configuration i did is correct or not.

Please guide me to solve my issue.

r3sistance 01-09-2010 11:12 AM

Would you be able to copy and paste the error at all? Not really enough to go on here. I am assuming you already have one working IP here after all?

rasa 01-10-2010 11:40 AM

Quote:

Originally Posted by r3sistance (Post 3820255)
Would you be able to copy and paste the error at all? Not really enough to go on here. I am assuming you already have one working IP here after all?

I am getting following error

xxx.x.x.x: error fetching interface information: Device not found

Both ips are working but i am bit confused because of that error.

r3sistance 01-10-2010 11:58 AM

Sounds strange, when does this error tend to occur if it works then?

rasa 01-13-2010 11:00 PM

Sorry , i was wrong i have asked when i am givng command
ifconfig ip, it is giving some error. But i can ping both ip. But i cannot do ftp
While doing ftp secondip i am getting
Quote:

Connection closed by remote host


All times are GMT -5. The time now is 03:44 PM.