Bookmark and Share

Recent Posts

Some Familiar and Not So Familiar Uses of ifconfig

September 12, 2017

In our line of work, you never stop learning. But I also believe it's important to refresh one's memory by revisiting some basics from time to time.

For instance, we should all know the OSI model, which is described here.

How well do you know your ifconfig commands? Here are some examples:

When do we use ‘ALIAS’? Consider the following command:

# ifconfig en0 <ip address> <subnet mask> alias

What is the function of ‘alias’ here? Alias is basically used to assign more than 1 ip address to a single interface.

For eg:
# ifconfig en0 alias

This command will assign 2 ip addresses to a single interface en0.

If no ‘alias’ is used:
# ifconfig en0

This command will replace the earlier ip address for the interface en0 with a new ip address.
So, by using ‘alias’, we can assign 255 ip addresses to a single interface.

Or maybe you want to remove the TCP/IP configuration on a host:

The rmtcpip command removes TCP/IP configuration on a host machine. The basic functions of this command is:

* Removes the network interface configurations.
* Restores /etc/rc.tcpip to the initial installed state.
* Restores /etc/hosts to the initial installed state.
* Removes the /etc/resolv.conf file.
* Removes the default and static routes.
* Sets the hostname to localhost.
* Sets the hostid to
* Resets configuration database to the initial installed state.

Like I said though, you never stop learning. As it pertains to ifconfig, awhile ago I become aware of an interesting option that I hadn't tried. Chris Gibson tweeted about it:

Move IP address seamlessly from one interface to another. # ifconifg en0 transfer en1

He included this link from the IBM Knowledge Center:

transfer tointerface
* Transfers an address and its related static routes from interface to tointerface. For IPv6, this command works only for addresses added by using the ifconfig command.
* ifconfig interface addressfamily address transfer tointerface

Note: If you want to transfer an IP address from one interface to another, and if the destination interface is not part of the virtual LAN (VLAN) to which the IP address belongs, you must add the VLAN to the adapter on which the destination interface is configured.

This is certainly handy. Did know it was available? Have you used it?

Posted September 12, 2017| Permalink

Post a Comment

Note: Comments are moderated and will not appear until approved

comments powered by Disqus