How to ARP the address of a Linux Box?

Extracted from askslashdot
Tip provided by ?
Markus Reimer asks:   "Is it possible to ARP address a Linux box in the same way
you can ARP address som printservers and similar 'network boxes'? The thing I want
to accomplish is setting an ip-address on a Linux box, remotely, when the box is
first set up. (preinstalled Linuxsystem). On several print-server boxes you do this
by using arp (e.g. arp -s 192.168.17.42 ff:ff:ff:ff:ff:ff) If I could do this it
would be great! "

Not an answer, but a clarification of the question :
What the original poster describes is a 'clever' method used by Axis and other
manufacturers of embedded IP products.
What you do is force the IP address of the device into the arp cache of another
machine on the same network (using arp -s under Win32, arp pub under *nix). Then,
you put the new embedded system on the network and ping it from the machine whose
arp cache you stuffed. The embedded system, meanwhile, is listening for any
Ethernet frames with its MAC. When it sees them, it peels them apart and looks for
the destination IP. It assumes that the destination IP is its own, and configures
itself appropriately.
The reasons for this approach are simplicity, hardware reduction, and code size:
1) The user of the device doesn't need a DHCP server, and doesn't need to flip any
jumpers or anything.
2) The manufacturer doesn't have to write a DHCP client (which has a bunch of state
code that is no fun to code in asm), and doesn't have to add extra hardware to the
device just to support configuration (ie: switches, buttons, LCDs or LEDs or
whatever).
However, I do not know of an implementation for this trick under Linux. It's within
the realm of theoretical possibility, though I don't believe you'll find anyone in
the "big" Linux world rushing to implement it when DHCP is fairly easy to do.
You might have some success in the ucLinux world, but it sounds like you want to
use this to address workstations. What is your actual goal? What are your
constraints, and why? Perhaps we could suggest an alternative if we had more
background on the /actual/ problem, not the final technical issue.

Arp -s and Linux :
arp -s doesn't set a remote computer's address,
what it does is to pre-load the address cache of the local computer with the IP and
MAC address of the remote computer.
You will still have to set the IP address of the Linux machine, using ifconfig as
usual.
Newer Linux distributions are very easy to set up for networking - so really, even
if you are preloading Linux on a number of machines, issuing an IP address for them
on first boot isn't much work.

A brief summary of the possible ways to do it :
1 Set the IP manually, using keyboard and monitor
2 Use BOOTP or DHCP
3 Configure the server via floppy
4 Pre set the IP and make a static host route (and some ipfwadm scripting)
5 Hack the kernel
1) The crude and effective way out.
Works, but isn't a attractive solution, since it depends on the installer being
capable to handle more than a webbrowser...
2) I rather don't...
I don't want to interfer with the customers network to much, introdusing extra
network services is definitely one of those things that I should avoid...
3) making a simple win (or whatever) program to create a config file on a floppy
that are searched for at every new floppy is a easy way but is a obvious security
hazard.
4) It's a nice solution, and probably the most appealing yet, but wich address should
I use as a default, not anyone of the private internet's, many of our customers use
them now...
5) Could anyone give me a estimated time for making a module for this?
If You have the time and expertise to create this I could check for the financial
room to develop this and of cause release it GPL!
Are there any other approach that I have overseen?

Userland trickery :
Or you could bring up eth0 on a known fake address (pick something highly random in
10.0.0.0) and start up tcpdump -i eth0 -p -n -e, use perl to hunt for a matching
MAC address (available from ifconfig), then ifconfig your card back up using the
"real" IP. Ugly, but hey. Isn't this functionality what reverse-ARP is for?

Which IP address for solution 4 :
It should not matter a lot what IP address you use, if you want to be sure you
don't collide with a known private address just use a public one like
206.170.14.75.
This only means the installer's PC can't reach slashdot for a while (he can 'route
del' afterward and all will be well again). You probably could even use something
like 1.2.3.4. After the initial install the Linux server will stop using the
address anyway, so there should be no realistic chance of trouble because of this.

Solution with tcpdump and bash...

#!/bin/sh
MAC=`ifconfig eth0 |awk '/HWaddr/ {print $5}'`
IP=`tcpdump -nc1 ether dst $MAC and icmp[0]=8 |awk '/echo request/
{sub(":","",$4);print $4}'`
 echo $IP


Multiple IPs on same network device :
You have a machine at 192.168.10.1 on device eth0.
ifconfig eth0:1 192.168.10.2
route add -host 192.168.10.2 dev eth0:1
Then you can ping yourself at two different IPs. The process can be repeated with
eth0:2, :3, etc.

Follow-up :
| Previous | Next | Index of category | Main Index | Submit |


Appears in section(s) : net configuration FMTYWTK
Tip recorded : 16-05-1999 16:43:35
HTML page last changed : 27-07-1999 20:06:30