[dev] ipaddr - script friendly ifconfig/ip replacement

From: Sean MacLennan <seanm_AT_seanm.ca>
Date: Sun, 26 Mar 2023 13:08:28 -0400

I started writing ipaddr almost 20 years ago after the umpteenth
time trying to parse ifconfig (and later ip) output in scripts. The
original version was get only and Linux only.

It now supports Linux, QNX, and most BSDs. However, I rarely use BSD
these days... so the set functions may not work 100%.

I thought there might be somebody in the suckless community that finds
it helpful.

You need just the ip address of eth0?
% ipaddr eth0

Nice simple output. All error output goes to stderr, so you can get
just the IP or nothing. No awk/sed/cut needed.

Also need the bitmask?
% ipaddr -b eth0

Maybe the netmask instead?
% ipaddr -im eth0

It can also be used to setup an interface:
% ipaddr eth0

Will set the ip, netmask and default gateway. I could have also
specified the netmask the old way:

You can see ipaddr.c on github:

I can email the file to anybody who wants it. It is only 6k gzipped.

Received on Sun Mar 26 2023 - 19:08:28 CEST

This archive was generated by hypermail 2.3.0 : Sun Mar 26 2023 - 19:24:38 CEST