[Linux-users] 2 IP's on the same network card
Dirk Moolman
DirkM
Tue Aug 28 05:48:47 PDT 2007
-----Original Message-----
From: linux-users-bounces at pananix.com
[mailto:linux-users-bounces at pananix.com] On Behalf Of David Bandel
On 8/27/07, James McDonald <james at jamesmcdonald.id.au> wrote:
> Dirk Moolman wrote:
> > Ok, I found it - and it is actually so simple:
> >
> > http://learnlinux.tsf.org.za/courses/build/net-admin/ch01s10.html
> >
> > To plumb your device, you may run the command:
> >
> > ifconfig eth0 192.168.0.1 netmask 255.255.255.0
> > ifconfig eth0:1 172.16.5.1 netmask 255.255.255.0
> >
> >
> > "These commands would plumb the interface. Notice that the eth0:1
gives
> > the interface the second IP address. Using any number in place of
the
> > '1' would also work."
> >
> >
> >
> Another lower level way of doing the same thing is using ip
>
> ip addr
>
> 2: eth0: <BROADCAST,MULTICAST,UP,10000> mtu 1500 qdisc pfifo_fast qlen
1000
> link/ether 00:08:74:3b:59:58 brd ff:ff:ff:ff:ff:ff
> inet 192.168.1.6/24 brd 192.168.1.255 scope global eth0
> inet6 fe80::208:74ff:fe3b:5958/64 scope link
> valid_lft forever preferred_lft forever
>
> ip addr add 192.168.1.220 dev eth0
> 2: eth0: <BROADCAST,MULTICAST,UP,10000> mtu 1500 qdisc pfifo_fast
> qlen 1000
> link/ether 00:08:74:3b:59:58 brd ff:ff:ff:ff:ff:ff
> inet 192.168.1.6/24 brd 192.168.1.255 scope global eth0
> inet 192.168.1.220/32 scope global eth0
> inet6 fe80::208:74ff:fe3b:5958/64 scope link
> valid_lft forever preferred_lft forever
>
> To delete
> ip addr del 192.168.1.220 dev eth0
>
> However the secondary address will not show up using ifconfig
> ifconfig
> eth0 Link encap:Ethernet HWaddr 00:08:74:3B:59:58
> inet addr:192.168.1.6 Bcast:192.168.1.255
Mask:255.255.255.0
> inet6 addr: fe80::208:74ff:fe3b:5958/64 Scope:Link
> UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
> RX packets:4377 errors:0 dropped:0 overruns:0 frame:0
> TX packets:1777 errors:0 dropped:0 overruns:0 carrier:0
> collisions:0 txqueuelen:1000
> RX bytes:1151555 (1.0 MiB) TX bytes:145992 (142.5 KiB)
> Interrupt:11 Base address:0x2c00
>
>This is actually the better way to do it. The problem with using
>aliases (eth0:1, etc.) is that if you try to down eth0 for any reason,
>you will down _all_ aliases as well. Using the ip method, this
>doesn't happen.
Thanks. I removed the ip (eth0:1), and recreated it using the ip
command. It works similar to the ifconfig command. The interface
eth0:1 gets created, but it isn't permanent. I rebooted, and the
interface was gone again.
*** Disclaimer ***
The information contained in this e-mail is confidential and legally privileged and is intended solely for the addressee and to others who have the authority to receive it. Access to this e-mail by anyone else is unauthorized and as such, any disclosure, copying, distribution or any action taken or omitted in reliance on it is unlawful. If you have received this e-mail in error, please notify the sender immediately.
The views expressed in this e-mail are the views of the individual sender and should in no way be construed as the views of the Company.
The Company is not liable to ensure that outgoing e-mails are virus-free.
The Company is not liable, should information or data, for whatever reason, be corrupted or fail to reach its intended addressee.
The Company is not liable for any loss or damage of whatsoever nature and howsoever arising resulting from the opening or the use of the information in this e-mail, including its attachments and links.
The sender of this e-mail is subject to and bound by the terms and conditions of Company+IBk-s Electronic Communications Usage Policy.
More information about the Linux-users
mailing list