Re: Bir Linux makinesinde birden fazla IP numarasi

OmER BaLTa (omerb@ankara.datasel.com.tr)
Sat, 11 May 1996 16:47:42 +0200 (EET)


On Sat, 11 May 1996, Fevzi Alimoglu wrote:

> Merhaba
>
> Bir Ethernet'e tek kartla bagli bir Linux makinesine birden fazla IP
> numarasi vermek mumkun mu? Mumkun ise nasil?
>
> Yardimci olursaniz sevinirim.

Selam,
VIF(Virtual IP interface) diye bir program var,
Linux icin test edilmemeis ama SunOs ve HP-UX icin test edilmis ve
calisiyor. ama degistirilirse Linux icin de calisir.
AcIklamasI a$aGIda.

---------------------------------------------------------------
This code lets you have multiple IP addresses for a single interface.
It is useful in those situations where you have multiple logical nets
on the same physical network segment.

The code was originally written by John Ioannidis. I have included part
of his original message at the end of this README file. Note that with
my version of the code, the extraneous network route mentioned by John
Ioannidies does *not* appear, and therefore does not need to be deleted.

I have cleaned up the code a little, ported it to HP-UX 9.05, and made it
modloadable (and unloadable) on SunOS 4.1.3/4.1.4. Please note that the
code has only been tested on the following hardware/OS combinations:

SunOS 4.1.3 sun4c
SunOS 4.1.4 sun4m
HP-UX 9.05 HP 700

Note that using this code is entirely unsupported, and you are very much
on your own if it crashes your machine! It is not recommended for people
who have never made a new Unix kernel. Root privileges are obviously needed
for installation.

I expect it should be portable to other operating systems with BSD based
networking code.

HP gotcha #1: I cannot get ARP to work on HP - the arp program refuses to
install the necessary entry.

HP gotcha #2: The code will almost certainly not work on interfaces using
checksum offload (eg. FDDI).

I would be happy to receive feedback on this code, ports to other OSs etc.

950115/Steinar Haug <steinar.haug@runit.sintef.no>
----------------------------------------------------------------------
From: ji@polaris.ctr.columbia.edu (John Ioannidis)
Subject: Multiple IP addresses on a single Ethernet interface
Date: 13 Feb 92 19:33:56 GMT

This is a topic that comes up once in a while on comp.protocols.tcp-ip
and other newsgroups. The question is, how to get a machine with one
network interface to respond to more than one IP addresses.

The other day, a colleague forwarded to me a request from the
namedroppers mailing list for exactly that. Here's my response:

> In article <1992Feb1.082712.18549@mahler.ntt.jp> hitoaki@mahler.ntt.jp (Hitoaki Sakamoto) writes:
> >In article <216@pivot.sbi.com> jordan@pivot.sbi.com (kuo-lin Hu) writes:
> > >But it is just out of my curiousity that whether it is possible
> > >I can assign dual IP addresses to a single controller?
>
> >No,you can't.
>
> Is this restriction common among UNIX TCP/IP implementations?
> Has anybody tried to modify this?
>
> -- Kenji
> --
> Kenji Rikitake
> kenji@macrofield.or.jp // kenji@macrofield.org // ...!uunet!reseau!kenji

I have a solution than might suit you. For my doctoral work (there's
a paper about it in this year's ('91) SIGCOMM, also available for
anonymous FTP from cs.columbia.edu:/pub/ji/sigcomm*.ps.Z), I've
developed what I call the "Virtual Interface" (VIF). To the networking
code, it looks like an interface. It gets ifattach()ed when you open
the /dev/vif* device, and then you can ifconfig it as you like. It
does not have an if_input procedure; it only has an if_output. Packets
that it receives (from higher-level protocols) which have its
IP address, it simply loops back (like any well-behaved if driver).
Packets that it receives that are destined for some other address, it
encapsulates in an encapsulation protocol I call IPIP (IP-within-IP,
protocol number IPPROTO_IPIP == 94), and sends it to another machine
that groks that encapsulation protocol. This feature you won't need,
but here's how to have multiple IP addresses on a machine with a
single real interface:

Let's say your primary interface's IP address is 198.3.2.1, and you
also want it to respond to addresses 198.4.3.2 and 198.5.4.3 (note
that these are three distinct class C addresses in three distinct
class C nets). Here are the ifconfigs:

ifconfig le0 198.3.2.1 up -trailers # config primary interface

ifconfig vif0 198.4.3.2 up # config first virtual interface
route delete net 198.4.3 198.4.3.2 # delete spurious route
route add host 198.4.3.2 198.4.3.2 0 # add route for this i/f

ifconfig vif1 198.5.4.3 up # config second virtual interface
route delete net 198.5.4 198.5.4.3 # delete spurious route
route add host 198.5.4.3 198.5.4.3 0 # add route for this i/f

The route deletes are needed because the ifconfig creates a default
route to the interface's network, which can cause problems; all that's
needed is the (host) route to the interface's address.

Now, get le0's ethernet address (say, 8:0:20:3:2:1), and add the
following static ARP entries:

arp -s 198.4.3.2 8:0:20:3:2:1 pub
arp -s 198.5.4.3 8:0:20:3:2:1 pub

This will cause any ARP requests for the VIF addresses to be replied
with your machine's ethernet address.

Now, make sure your default route is to your segment's gateway,
throught the real interface. FInally, make sure your routers and/or
hosts on the same segment as yours know that 198.4.3.2 and 198.5.4.3
are on that cable.

Here's what you've accomplished.

ARP requests for any of your host's addresses will be replied to with
the host's ethernet address (the real one, because that's what it is,
the virtual ones because of the public static arp entries). Packets
reaching your host with any of these addresses will be accepted by the
ip_input routine because they match the address of one of the host's
interfaces. Packets leaving your host can have any of its addresses
(real and virtual).
------------------------------------------------------------------

Saygilar OMER.