netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* IP address: property of host or interface?
@ 2009-01-24 13:57 Michael Tokarev
  2009-01-26 17:43 ` Rick Jones
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Tokarev @ 2009-01-24 13:57 UTC (permalink / raw)
  To: netdev

Hello!

Long time ago there was an ifconfig command and
interface "aliases".  Now, thanks to new way of
doing things and to famous `ip' utility, we learned
that there's no such thing as INTERFACE alias and
an IP address belongs to whole interface, not to
some "alias" of it.  So far so good.

But now I'm asking if an IP really belongs to any
particular interface, instead of the whole HOST
in question.

For example, suppose we have two interfaces, eth0
and eth1, and two addresses/nets, A0/24 and A1/24,
configured.

Let's ping address A1 from segment 0: the host in
question will answer those pings, provided we've
routing on our "external" host set up to point to
A0.  The same is true when pinging A0 from segment 1.
So, it makes no difference which IP address to access,
a host will happily answer to any of them assigned to
it, *except* of 127/8 (which is a different story).
Note that this works regardless of ip_forward, because
it's not forwarding.

Now, I'm setting up the host interfaces somewhat
differently:

 ip addr add A0/32 dev lo
 ip route add A0/24 dev eth0 src A0
 ip addr add A1/32 dev lo
 ip route add A1/24 dev eth1 src A1

I.e., I'm assigning both addresses to loopback interface
and adding ROUTES to corresponding networks/interfaces.
And guess what?  This thing will work exactly the same
way as traditional setup.

In other words, I can assign all addresses that belongs
to the host to it's loopback interface, and only add
routes (which gets added automatically behind the scenes
when I configure ADDRESS with mask != 32 on a broadcast
iface) to corresponding "remote" (not belonging to the
host) addresses.

There's even more: think of peer-to-peer (not broadcast)
interfaces, such as tun or ppp.  Traditionally we used
to have "local IP" and "remote IP" or "peer IP", and
used to set up routes to that remote IP.  For example,

  ip addr add A peer R dev ppp0
  ip route add RS/M via R

but the same works without assigning any address at all
to ppp0 interface!

  ip route add R dev ppp0
  ip route add RS/M dev ppp0

(if A is not listed locally, it's possible to add it to
lo interface again).

So.. am I right that an IP address is a HOST property,
not an INTERFACE property, and that the traditional
way is just more convenient to set up?
And that all the tools that complains that "there's
no IP address assigned to this interface" (tcpdump)
are wrong? :)

Thanks!

/mjt

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: IP address: property of host or interface?
  2009-01-24 13:57 IP address: property of host or interface? Michael Tokarev
@ 2009-01-26 17:43 ` Rick Jones
  2009-01-26 18:06   ` Ben Greear
  0 siblings, 1 reply; 4+ messages in thread
From: Rick Jones @ 2009-01-26 17:43 UTC (permalink / raw)
  To: Michael Tokarev; +Cc: netdev

> So.. am I right that an IP address is a HOST property, not an INTERFACE
> property, and that the traditional way is just more convenient to set up? And
> that all the tools that complains that "there's no IP address assigned to this
> interface" (tcpdump) are wrong? :)

There are two "schools" of thought - the Linux stack follows the "weak end 
system" model in which IP addresses are treated as a host property.  There is 
another school of thought called the "strong end system" model where IP addresses 
are an interface property.  There are some "other" stacks out there which can be 
configured to behave in a "strong end system" way but they tend to default to 
more of something in between the two.

Tcpdump may simply be caught in the middle :)

rick jones

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: IP address: property of host or interface?
  2009-01-26 17:43 ` Rick Jones
@ 2009-01-26 18:06   ` Ben Greear
  2009-01-26 18:20     ` Michael Tokarev
  0 siblings, 1 reply; 4+ messages in thread
From: Ben Greear @ 2009-01-26 18:06 UTC (permalink / raw)
  To: Rick Jones; +Cc: Michael Tokarev, netdev

Rick Jones wrote:
>> So.. am I right that an IP address is a HOST property, not an INTERFACE
>> property, and that the traditional way is just more convenient to set 
>> up? And
>> that all the tools that complains that "there's no IP address 
>> assigned to this
>> interface" (tcpdump) are wrong? :)
>
> There are two "schools" of thought - the Linux stack follows the "weak 
> end system" model in which IP addresses are treated as a host 
> property.  There is another school of thought called the "strong end 
> system" model where IP addresses are an interface property.  There are 
> some "other" stacks out there which can be configured to behave in a 
> "strong end system" way but they tend to default to more of something 
> in between the two.
>
> Tcpdump may simply be caught in the middle :)
With a bit of configuring (away from system defaults), Linux can behave 
as a 'strong end system', and even
in default behaviour, I don't believe it will process IP packets from an 
interface that has NO IP address assigned
to it.

Thanks,
Ben

>
> rick jones
> -- 
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


-- 
Ben Greear <greearb@candelatech.com> 
Candela Technologies Inc  http://www.candelatech.com



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: IP address: property of host or interface?
  2009-01-26 18:06   ` Ben Greear
@ 2009-01-26 18:20     ` Michael Tokarev
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Tokarev @ 2009-01-26 18:20 UTC (permalink / raw)
  To: Ben Greear; +Cc: Rick Jones, netdev

Ben Greear wrote:
> Rick Jones wrote:
>>> So.. am I right that an IP address is a HOST property, not an INTERFACE
>>> property, and that the traditional way is just more convenient to set
>>> up? And
>>> that all the tools that complains that "there's no IP address
>>> assigned to this
>>> interface" (tcpdump) are wrong? :)
>>
>> There are two "schools" of thought - the Linux stack follows the "weak
>> end system" model in which IP addresses are treated as a host
>> property.  There is another school of thought called the "strong end
>> system" model where IP addresses are an interface property.  There are
>> some "other" stacks out there which can be configured to behave in a
>> "strong end system" way but they tend to default to more of something
>> in between the two.

As someone else pointed out, it's all described in RFC1122 (1989!).
It was quite.. interesting reading.

>> Tcpdump may simply be caught in the middle :)

heh.

> With a bit of configuring (away from system defaults), Linux can behave
> as a 'strong end system', and even

Well, that's quite "a bit". Involves iptable filters.

> in default behaviour, I don't believe it will process IP packets from an
> interface that has NO IP address assigned
> to it.

Just try it.  Trivial to do.  Assume you've a "simple-workstation"
config (no fancy stuff just lo and eth0 with single ip) with
192.168.1.5/24 on your eth0:

# ip addr add 192.168.1.5/32 dev lo  <== assigns that IP to lo interface
# ifconfig eth0 0.0.0.0  <= clears it (and routes) from eth0 but
                         <= keeps the interface up
# ip route add 192.168.1.0/24 dev eth0 <= restores the route

Now ping (or whatever) 192.168.1.5 from any host on eth0 segment.
All IP/TCP/UDP/etc stuff will work as usual.

/mjt

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-01-26 18:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-24 13:57 IP address: property of host or interface? Michael Tokarev
2009-01-26 17:43 ` Rick Jones
2009-01-26 18:06   ` Ben Greear
2009-01-26 18:20     ` Michael Tokarev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).