Operating System - Linux
1831060 Members
2848 Online
110019 Solutions
New Discussion

how to assign 2 ip address in a single lan card.

 
SOLVED
Go to solution
Guna_2
Regular Advisor

how to assign 2 ip address in a single lan card.

Dear all

I want to assign two ipaddress in a single lan card. in Linux.

I tried by using
ifconfig eth0:0 xxx.xxx.xxx.xxx. netmask 255.255.0.0

Its assining the ip address, But when i am trying to down and up the interface its givning error as "SIOCSIFFLAGS: Cannot assign requested address"

Can any one tell me the procedure..

Thanks & Regards,
Guna
5 REPLIES 5
Vitaly Karasik_1
Honored Contributor

Re: how to assign 2 ip address in a single lan card.

your method seems to be OK.
It works for me without error. Do you see any errors in syslog/dmesg?
which distro/kernel do you use?
It may be kernel bug, see for example http://www.uwsg.iu.edu/hypermail/linux/net/0211.0/0035.html about 2.4.18 kernel.

Wouter Jagers
Honored Contributor
Solution

Re: how to assign 2 ip address in a single lan card.

That error seems normal:

You configged the extra IP address on the command line with ifconfig.

If you down and up the interface using ifdown/ifup or init scripts, your system will use /etc/network/interfaces to find configuration data.

Assign the 2nd IP to the interface in /etc/network/interfaces as well and you shouldn't get the error anymore.

Cheers
an engineer's aim in a discussion is not to persuade, but to clarify.
Wouter Jagers
Honored Contributor

Re: how to assign 2 ip address in a single lan card.

Just in case, here's a short example:

iface eth0 inet static
address 192.168.0.1
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255

iface eth0:0 inet static
address 192.168.0.2
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
an engineer's aim in a discussion is not to persuade, but to clarify.
Guna_2
Regular Advisor

Re: how to assign 2 ip address in a single lan card.

Thank you
Wouter Jagers
Honored Contributor

Re: how to assign 2 ip address in a single lan card.

If we helped, feel free to assign us some points ;-)

Cheers
an engineer's aim in a discussion is not to persuade, but to clarify.