Finding the Subnet Mask on AIX

Posted by

This is something DB2 DBAs may need to do as a part of setting up TSAMP. Nearly every server I’ve done before has had a subnet mask of 255.255.255.0, but I ran into a server recently that wasn’t, and thought I would share how I figured out what it should be (alone, in the middle of the night, during an upgrade).

Command

This command is probably familiar. It is used to get network adapter and IP address information on AIX:

> ifconfig -a
en0: flags=1e084863,480
        inet 192.0.2.236 netmask 0xfffffc00 broadcast 192.0.2.255
         tcp_sendspace 262144 tcp_recvspace 262144 rfc1323 1
lo0: flags=e08084b,c0
        inet 127.0.0.1 netmask 0xff000000 broadcast 127.255.255.255
        inet6 ::1%1/0
         tcp_sendspace 131072 tcp_recvspace 131072 rfc1323 1

Conversion

The value that represents the subnet mask there is netmask 0xfffffc00. As my Windows-oriented husband said when I discussed it with him “Why the heck is it in HEX?!?!?”. To convert that to an actual value like you would feed into db2haicu, you can use a table like this. Looking at that table, my value of 0xfffffc00 corresponds to a subnet mask of 255.255.252.0:
subnetmask

Ember is always curious and thrives on change. She has built internationally recognized expertise in IBM Db2, and is now pivoting to focus on learning MySQL. Ember shares both posts about her core skill set and her journey learning MySQL. Ember lives in Denver and work from home

2 comments

  1. Very nice, thanks! On AIX, you could also user the lsattr command to view the subnet mask of a given network interface e.g.

    $ lsattr -El en0 -a netmask
    netmask 255.255.255.224 Subnet Mask True

  2. If you are on AIX the fastet way to see the netmask in regular notation is using smitty mktcpip and navigate tot the interface in question, granted that not being root would not allow you to change it, but it will show the current values, and netmask for smitty is show as 4 octects dot separated.

    The reality is that netmask are bits, AIX does it
    differently than others on the ifconfig, but it is naive to think the netmask can only be presented in 4 octects.
    There is a common notation that uses the sum of the enabled bits on the netmask, thus 255.255.255 or ffffff00 is actually /24
    a quick way to convert them is understanding that each octect is a byte (the reason no IPv4 address can not have any number higher to 255 on their octets)

    A byte in hex is represented by two digits, thus 255 equals ff (or 8 bits on) so fc is 255 -3 ( the 3 comes from counting the letter needed to move from c to f)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.