jump to navigation

Non hexadecimal ifconfig (Solaris 8, 9 & 10) August 6, 2007

Posted by claudio in Uncategorized.
Tags: , ,
trackback

Solaris is nice, but its ifconfig is pretty annoying. It gives you an hexadecimal netmask.This gives you two choices. One learn to decipher all those f’s or write a ridiculous small wrapper script. Guess what I did.

Here is what a typical ifconfig output looks like in Solaris:

root@labo:~# ifconfig -a
lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
hme0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet 10.0.81.9 netmask ffffff00 broadcast 10.0.81.255
ether 0:3:ba:10:aa:51
root@labo:~# ifconfig hme0
hme0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet 10.0.81.9 netmask ffffff00 broadcast 10.0.81.255
ether 0:13:bb:15:aa:11

This is what is looks like with the wrapper:

root@labo:~# ifconfig_new -a
lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
inet 127.0.0.1 netmask 255.0.0.0
hme0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet 10.0.81.9 netmask 255.255.255.0 broadcast 10.0.81.255
ether 0:3:ba:10:aa:51
root@labo:~# ifconfig_new hme0
hme0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet 10.0.81.9 netmask 255.255.255.0 broadcast 10.0.81.255
ether 0:13:bb:15:aa:11

The script is written in perl and it uses the Solaris shipped version. No additional modules where used.

You can download the script here. The checksum of the script is fb26efd3f1c804ed7019c4ced37c2563.

About these ads

Comments»

1. Anonymous - April 28, 2009

For reference, you could always just keep your netmasks in hex since they make more sense that way anyhow:

ifconfig hme0 10.0.81.9 netmask 0xffffff00 broadcast + up


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 145 other followers

%d bloggers like this: