Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Setting multiple IP addrs for an interface

944 views
Skip to first unread message

Harjinder Chayra

unread,
Jan 6, 2003, 9:20:10 AM1/6/03
to
What calls do I need to make to give an Ethernet interface 2 IP addresses?

cheers
Harjinder


Vasu Dalal

unread,
Jan 6, 2003, 11:08:18 PM1/6/03
to
Hello :

> What calls do I need to make to give an Ethernet interface 2 IP addresses?
>

Use ifAddrAdd() in ifLib.h

ifAddrAdd (char* interfaceName,char* interfaceAddr, char*
broadcastAddr, int subnetmask);

Try for example :

ifAddrAdd "motfcc0","192.168.101.100","192.168.101.255",0xffffff00
<enter>

hth,
vasu

Toni Kurzberger

unread,
Jan 7, 2003, 3:54:14 AM1/7/03
to
"Harjinder Chayra" <harjinde...@imedia.com> wrote in message news:<avc3ao$rs6$1...@news.storm.ca>...

> What calls do I need to make to give an Ethernet interface 2 IP addresses?
>
> cheers
> Harjinder

ifAddrSet
ifMaskSet
for the 1st address
ifAddrAdd
for subsequent addresses

toni

Martin Roth

unread,
Jan 7, 2003, 7:07:51 AM1/7/03
to
Toni,

As I understand TCP/IP networking, the additional IP address added by
ifAddrAdd() should be from the same subnet. Am I correct ?
From my TCP/IP knowledge the subnet or network part of IP address on the
same subnet should be the same.

Martin
Mailto:bmr...@email.mot.com

"Toni Kurzberger" <gon...@gmx.at> wrote in message
news:8400a733.03010...@posting.google.com...

Joe Durusau

unread,
Jan 7, 2003, 10:31:30 PM1/7/03
to
I don't know whether WRS implementation can handle the
situation, but must compliant systems will allow you
to use non-routable addresses that are not in the same
subnet. If they were routable addresses, I would imagine
that having the net part of the addresses different on the
same physical interface could cause a mess.

Speaking only for myself,

Joe Durusau

Toni Kurzberger

unread,
Jan 8, 2003, 4:17:36 AM1/8/03
to
"Martin Roth" <bmr...@email.mot.com> wrote in message news:<avefti$379$1...@newshost.mot.com>...

> Toni,
>
> As I understand TCP/IP networking, the additional IP address added by
> ifAddrAdd() should be from the same subnet. Am I correct ?

Actually it's different. VxWorks is prepared to handle n fully
routeable addresses on a single interface. All of them have to be on
different networks. E.g.:
fei0 123.123.123.123:ffffff00
fei0 12.12.12.12:ffff0000
=> Would be legal and should work.
fei0 123.123.123.123:ffffff00
fei0 123.123.123.124:ffffff00
=> Will most likely cause trouble with VxWorks.
I'm not sure about the standard RIP and OSPF... in case you plan using
them it should be checked whether they can handle multiple networks on
a single interface.
At least this is something the routing code of the SENS stack is
prepared to handle.

toni

Martin Roth

unread,
Jan 8, 2003, 11:30:59 AM1/8/03
to
Toni,
Thanks for the reply.
This is very strange to me, because I was used that all the IP addresses on
a subnet or network should have the same subnet network id.
So, IP routers route packets to the same network interface having two IP
addresses from different subnets.
The question then is how is the router configured to route the two IP
addresses? Should the router interface also have two IP addresses or is it
a special route that we add to the routing table on the router?

Martin
Mailto:bmr...@email.mot.com

"Toni Kurzberger" <gon...@gmx.at> wrote in message
news:8400a733.03010...@posting.google.com...

Andrei

unread,
Jan 8, 2003, 10:37:04 PM1/8/03
to
> > Actually it's different. VxWorks is prepared to handle n fully
> > routeable addresses on a single interface. All of them have to be on
> > different networks. E.g.:
> > fei0 123.123.123.123:ffffff00
> > fei0 12.12.12.12:ffff0000
> > => Would be legal and should work.
> > fei0 123.123.123.123:ffffff00
> > fei0 123.123.123.124:ffffff00
> > => Will most likely cause trouble with VxWorks.

What Toni describes here, if true, is a bug in the IP stack. The IP
stack should handle multiple addresses on same subnet.
Andrei

Andrei

unread,
Jan 8, 2003, 10:37:04 PM1/8/03
to
> > Actually it's different. VxWorks is prepared to handle n fully
> > routeable addresses on a single interface. All of them have to be on
> > different networks. E.g.:
> > fei0 123.123.123.123:ffffff00
> > fei0 12.12.12.12:ffff0000
> > => Would be legal and should work.
> > fei0 123.123.123.123:ffffff00
> > fei0 123.123.123.124:ffffff00
> > => Will most likely cause trouble with VxWorks.

What Toni describes here, if true, is a bug in the IP stack. The IP


stack should handle multiple addresses on same subnet.
Andrei

> > I'm not sure about the standard RIP and OSPF... in case you plan using

Martin Roth

unread,
Jan 9, 2003, 5:29:42 AM1/9/03
to
Andrei,
I agree with you, because this is the basic of TCP/IP networking.
I am trying to think about a situation when you need to assign two IP
addresses to the same interface.
I can think of security reasons to grant some applications to use one IP
address and other applications to use a different IP address.
I think if both addresses are routable, - they should be on the same subnet.
I can accept one routable address and one private address. In this case the
routable address can be used by the external world to access low security
applications.
The private IP address (for the same interface) can be used to access
applications that should not be exposed to external networks.
I would appreciate if somebody highlights this issue, anyway I will try to
apply to Windriver.
Martin

"Andrei" <iub...@yahoo.com> wrote in message
news:371e4594.0301...@posting.google.com...

Andrei

unread,
Jan 10, 2003, 12:04:47 PM1/10/03
to
"Martin Roth" <bmr...@email.mot.com> wrote in message news:<avjiu2$auq$1...@newshost.mot.com>...

> Andrei,
> I agree with you, because this is the basic of TCP/IP networking.
> I am trying to think about a situation when you need to assign two IP
> addresses to the same interface.

This situation is also called 'interface aliaing', or 'multihoming'.
While normally not needed, here is an example when you do need it.

On your local ethernet network, there may be multiple IP subnets
defined. If you use only one interface, you can talk directly to just
one of the subnets, and have to rely on a gateway to route packets
from you to the other subnets. Instead, you can use interface aliases
to talk directly to all the other subnets.

> I can think of security reasons to grant some applications to use one IP
> address and other applications to use a different IP address.

Once an interface is defined, all applications can use it. I don't
know any OS that allows permission setting on an IP interface, and
that checks the process user id/group id (similar to how file
permissions work). The only permission restriction, on UNIXes and
Windows (not sure of VxWorx, does it support user permisions?), is
that applications can bind to port numbers < 1024 only if they have
root permission.

> I think if both addresses are routable, - they should be on the same subnet.
> I can accept one routable address and one private address. In this case the
> routable address can be used by the external world to access low security
> applications.
> The private IP address (for the same interface) can be used to access
> applications that should not be exposed to external networks.

What you're trying to do is difficult, but not impossible. It is
similar to the ipchains concept that Linux has. If VxWorks implements
hooks at the ethernet driver level which you can use to make it drop
incoming packets based on their src/dest IP address... it could be
done. For example, the OSE real-time system has that capability.

An easier approach would be to deal with security at the application
layer.

Andrei Radulescu-Banu

0 new messages