getif

For a linux init-script I needed to get the IP-address of an interface. Obviously ifconfig does the job, but the resulting output is very long, and you need to write nontrivial sed-scripts to extract the simple IP-address.

The IP-address is also nowhere in the /proc-filesystem, so I have written getif, which just extracts the necessary information and nothing else.

getif supports the following arguments:

  • -a return interface name, MAC-address, IP-address, network mask and broadcast address of all active interfaces.
  • -i <if> return IP-address of interface <if>.
  • -n <if> return network mask of interface<if>.
  • -b <if> return broadcast address of interface <if>.
  • -h <if> return MAC-address of interface <if>.
  • -v version information.
The source code is in the file getif.c.

To compile getif just type make getif and copy the executable to your favority directory. There are no special permissions necessary.

Zur Einstiegsseite
Linkliste
letzte Änderung: 08.10.2002 00:45     © Felix Müri