Multiple IP addresses (or hosts) on one LAN interface

Multiple IP addresses (or hosts) on one LAN interface

Post by Patrick La » Tue, 22 Jul 2003 19:42:56



Dear all:

I need to setup multiple hosts (or servers) on the same machine which has
only one LAN interface.  That is, I would have IP addresses like:

207.10.2.5
207.10.2.10
207.10.2.67

on the same LAN interface (on one machine) and bind 3 different processes
onto these 3 addresses so that:

process1 would be identified to have IP address 207.10.2.5
process2 would be identified to have IP address 207.10.2.10
process3 would be identified to have IP address 207.10.2.67

I know this is possible in Solaris (but I already forgot how I did it).  Is
this also possible in Linux (I actually think so)?  How is it done?

Thanks so very much in advance,

Patrick

 
 
 

Multiple IP addresses (or hosts) on one LAN interface

Post by James Knot » Tue, 22 Jul 2003 19:53:16



> Dear all:

> I need to setup multiple hosts (or servers) on the same machine which has
> only one LAN interface.  That is, I would have IP addresses like:

> 207.10.2.5
> 207.10.2.10
> 207.10.2.67

> on the same LAN interface (on one machine) and bind 3 different processes
> onto these 3 addresses so that:

> process1 would be identified to have IP address 207.10.2.5
> process2 would be identified to have IP address 207.10.2.10
> process3 would be identified to have IP address 207.10.2.67

> I know this is possible in Solaris (but I already forgot how I did it).
> Is
> this also possible in Linux (I actually think so)?  How is it done?

> Thanks so very much in advance,

> Patrick

man ifconfig

--

Fundamentalism is fundamentally wrong.


james.knott.

 
 
 

Multiple IP addresses (or hosts) on one LAN interface

Post by Kasper Dupon » Tue, 22 Jul 2003 20:03:10



> Dear all:

> I need to setup multiple hosts (or servers) on the same machine which has
> only one LAN interface.  That is, I would have IP addresses like:

> 207.10.2.5
> 207.10.2.10
> 207.10.2.67

> on the same LAN interface (on one machine) and bind 3 different processes
> onto these 3 addresses so that:

> process1 would be identified to have IP address 207.10.2.5
> process2 would be identified to have IP address 207.10.2.10
> process3 would be identified to have IP address 207.10.2.67

> I know this is possible in Solaris (but I already forgot how I did it).  Is
> this also possible in Linux (I actually think so)?  How is it done?

First you choose three different interface names like eth0, eth0:id1,
and eth0:id2. The id after the : can be anything you like. You should
use the primary IP address for eth0 and additional IP addresses for
the other interfaces. To use only one of the three IP addresses, a
process must first bind a socket to that IP address using the bind
system call.

--
Kasper Dupont -- der bruger for meget tid paa usenet.

This reply intentionally does not answer the question completely.

 
 
 

Multiple IP addresses (or hosts) on one LAN interface

Post by Whoeve » Wed, 23 Jul 2003 01:58:38




> > Dear all:

> > I need to setup multiple hosts (or servers) on the same machine which has
> > only one LAN interface.  That is, I would have IP addresses like:

> > 207.10.2.5
> > 207.10.2.10
> > 207.10.2.67

> > on the same LAN interface (on one machine) and bind 3 different processes
> > onto these 3 addresses so that:

> > process1 would be identified to have IP address 207.10.2.5
> > process2 would be identified to have IP address 207.10.2.10
> > process3 would be identified to have IP address 207.10.2.67

> > I know this is possible in Solaris (but I already forgot how I did it).  Is
> > this also possible in Linux (I actually think so)?  How is it done?

> First you choose three different interface names like eth0, eth0:id1,
> and eth0:id2. The id after the : can be anything you like. You should

Actually, this is not neccessarily true. If you install the iproute2
tools, you can use:
/sbin/ip addr add ....
and add multiple IP addresses to eth0 (without the ":idx" suffix).

As for then having different BIND processes listening on the different IP
addresses, look for "listen-on" in BIND's config file (man named.conf).
You will have to edit the config files and probably the init scripts to
make sure that the 3 different bind proceses don't interfere with each
other (different PID files, etc.)

 
 
 

Multiple IP addresses (or hosts) on one LAN interface

Post by Kasper Dupon » Wed, 23 Jul 2003 16:12:24





> > > Dear all:

> > > I need to setup multiple hosts (or servers) on the same machine which has
> > > only one LAN interface.  That is, I would have IP addresses like:

> > > 207.10.2.5
> > > 207.10.2.10
> > > 207.10.2.67

> > > on the same LAN interface (on one machine) and bind 3 different processes
> > > onto these 3 addresses so that:

> > > process1 would be identified to have IP address 207.10.2.5
> > > process2 would be identified to have IP address 207.10.2.10
> > > process3 would be identified to have IP address 207.10.2.67

> > > I know this is possible in Solaris (but I already forgot how I did it).  Is
> > > this also possible in Linux (I actually think so)?  How is it done?

> > First you choose three different interface names like eth0, eth0:id1,
> > and eth0:id2. The id after the : can be anything you like. You should

> Actually, this is not neccessarily true. If you install the iproute2
> tools, you can use:
> /sbin/ip addr add ....
> and add multiple IP addresses to eth0 (without the ":idx" suffix).

I wonder what it actually does, after adding one, I cannot see it
with ifconfig. I also wonder what is going on here, how can the
destination host be unreachable:

[root:pts/1:/home/kasperd] /sbin/ip addr add 172.16.42.96 dev eth0
[root:pts/1:/home/kasperd] ping 172.16.42.96
PING 172.16.42.96 (172.16.42.96) 56(84) bytes of data.
64 bytes from 172.16.42.96: icmp_seq=2 ttl=64 time=0.228 ms
64 bytes from 172.16.42.96: icmp_seq=3 ttl=64 time=0.224 ms
From 172.16.42.1 icmp_seq=1 Destination Host Unreachable
64 bytes from 172.16.42.96: icmp_seq=4 ttl=64 time=0.214 ms

--- 172.16.42.96 ping statistics ---
4 packets transmitted, 3 received, +1 errors, 25% packet loss, time 3032ms
rtt min/avg/max/mdev = 0.214/0.222/0.228/0.005 ms, pipe 3

Quote:

> As for then having different BIND processes listening on the different IP
> addresses, look for "listen-on" in BIND's config file (man named.conf).
> You will have to edit the config files and probably the init scripts to
> make sure that the 3 different bind proceses don't interfere with each
> other (different PID files, etc.)

Nobody said anything about BIND.

--
Kasper Dupont -- der bruger for meget tid paa usenet.

Their business was zero and it was shrinking.

 
 
 

Multiple IP addresses (or hosts) on one LAN interface

Post by Cedric Blanche » Wed, 23 Jul 2003 16:23:55


Dans sa prose, Kasper Dupont nous ecrivait :


>> Actually, this is not neccessarily true. If you install the iproute2
>> tools, you can use:
>> /sbin/ip addr add ....
>> and add multiple IP addresses to eth0 (without the ":idx" suffix).
> I wonder what it actually does, after adding one, I cannot see it with
> ifconfig.

"ip addr add" just add an ARP entry to the interface, i.e. an IP for which
the interface will answer.
ifconfig does a bit more, such as setting according routes.

--
BOFH excuse #443:

Zombie processes detected, machine is haunted.

 
 
 

Multiple IP addresses (or hosts) on one LAN interface

Post by Kasper Dupon » Wed, 23 Jul 2003 20:24:42



> Dans sa prose, Kasper Dupont nous ecrivait :

> >> Actually, this is not neccessarily true. If you install the iproute2
> >> tools, you can use:
> >> /sbin/ip addr add ....
> >> and add multiple IP addresses to eth0 (without the ":idx" suffix).
> > I wonder what it actually does, after adding one, I cannot see it with
> > ifconfig.

> "ip addr add" just add an ARP entry to the interface, i.e. an IP for which
> the interface will answer.
> ifconfig does a bit more, such as setting according routes.

But still there is a difference between
1) Adding the IP using "ifconfig interface:id"
2) Adding the IP using "ip addr add" and the
   route using "route add"

--
Kasper Dupont -- der bruger for meget tid paa usenet.

Their business was zero and it was shrinking.

 
 
 

Multiple IP addresses (or hosts) on one LAN interface

Post by Cedric Blanche » Wed, 23 Jul 2003 21:11:30


Dans sa prose, Kasper Dupont nous ecrivait :

Quote:> But still there is a difference between 1) Adding the IP using "ifconfig
> interface:id" 2) Adding the IP using "ip addr add" and the
>    route using "route add"

Except the fact you do not create an aliased interface, I don't think
there's any difference. I personaly prefer use ifconfig for I can see
aliases as eth0:idx.

--
 Sur francom.amitie il y a aussi des fois des massages court
 -+- K in GNU - La main du masseur dans la culotte du zouave -+-

 
 
 

Multiple IP addresses (or hosts) on one LAN interface

Post by /dev/rob » Thu, 24 Jul 2003 00:35:45




Quote:>> But still there is a difference between 1) Adding the IP using "ifconfig
>> interface:id" 2) Adding the IP using "ip addr add" and the
>>    route using "route add"

> Except the fact you do not create an aliased interface, I don't think
> there's any difference. I personaly prefer use ifconfig for I can see
> aliases as eth0:idx.

I use /sbin/ip to add my aliases, but I use the ethX:alias syntax. :) A
compromise, as it were. It's also necessary if you want to use the alias
interface with iptables. Well, I think you can only use the whole ethX
interface, which includes any :alias.

I use aliases for different services, so they're portable if I need to
move them to another machine (set up the service on B, stop the service
on A, cancel the alias on A, set up the alias on B, start the service on
B ... and everyone goes on as if nothing had happened.) If the alias is
in the same subnet no special routing is needed.
--

  or put "not-spam" or "/dev/rob0" in Subject header to reply