Operating System - HP-UX
1831939 Members
3192 Online
110032 Solutions
New Discussion

second ip address in lan0

 
SOLVED
Go to solution
Ricky_4
Frequent Advisor

second ip address in lan0

Hi All,

How could I add a second ip address through command line from my lan0 then later on remove that second ip address?

Thanks in advance.

Adriatico
5 REPLIES 5
Patrick Wallek
Honored Contributor

Re: second ip address in lan0

This is done thru ifconfig.

It would be something like:

# ifconfig lan0:1 1.1.1.1 netmask 255.255.255.0

or whatever is appropriate. You would use ifconfig to remove it as well. For more details see the ifconfig man page.

Senthilmurugan
Frequent Advisor

Re: second ip address in lan0

Hello Adriatico,

You can add a new alias to your lan0 in the command line as follows:

Format:
#ifconfig lan0:1 netmask

Eg:

#ifconfig lan0:1 172.16.1.100 netmask 255.255.255.0

To disable the lan0:1, you can simply do the following:

#ifconfig lan0:1 down


Regards,
Senthil Murugan.
Muthukumar_5
Honored Contributor

Re: second ip address in lan0

We can do this by assigning ip-address to secondary interface to the primary interface.

As suggested by peter,

we have to make secondary interface to the primary interface as,

primary interface = lan0
seconday interface = lan0:1

Note: lan0:0 is same to lan0.

ifconfig man page says -->
IP Index Number
Multiple IP addresses assigned to the same interface may be in
different subnets. An example of an interface name without an IP
index number is lan0. An example of an interface name with a IP index
number is lan0:1. Note: specifying lan0:0 is equivalent to lan0.

A primary interface is an interface whose IP index number is zero. A
secondary interface is an interface whose IP index number is non-zero.

Regards
Muthu
Easy to suggest when don't know about the problem!
Senthilmurugan
Frequent Advisor
Solution

Re: second ip address in lan0

Hello Adriatico,

Some tips to the above.
1.If you add the secondary address through the command line prompt. it will be available only upto the next restart of the networking services or the next reboot.

2. If you want to down the interface, you can do it by using the

#ifconfig lan0:1 down

command. but doing so will only stop the packets transmiting from that interface. If you want to disable the lan0:1 interface you can do this by using

#ifconfig lan0:1 0.0.0.0

This will NOT assign 0.0.0.0 to lan0:1 instead this will remove the lan0:1 interface.

Regards,
Senthil Murugan






Sridhar Bhaskarla
Honored Contributor

Re: second ip address in lan0

Hi,

Do not forget to add lan0:1 in /etc/rc.config.d/netconf file. The syntax is exactly the same as of lan0 except for the "index".

You cannot use 'unplumb' option with ifconfig to remove the IP. instead add the IP '0.0.0.0' to lan0:1.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try