AIX, Networking↑ Adding and deleting a static network route using the command line

There are two commands that can be used to add a route on an AIX system.

The first one is route, and can be used to temporarily add a route to an AIX system. Meaning, if the system is rebooted, after the route has been added, the route will be lost again after the reboot.

The second command is chdev -l inet0 that can be used to permanently add a route on an AIX system. When this command is used, the route will persist during reboots, as this command writes to information of the route in to the ODM of AIX.

Let's say you have a need to add a route on a system to network And that network uses a netmask of (or "24" for the short mask notation). Finally, the gateway that can be used to access this network is Obviously, please adjust this to your own situation.

To temporarily add a route on a system for this network, use the following route command:

# route add -net -netmask

After running this command, you can use the netstat -nr command to confirm that the route indeed has been set up:

# netstat -nr | grep
172.30.224/24   UG   0   0   en1   -   -

To remove that route again, simply change the route command from "add" to "delete":

# route delete -net -netmask

Again, confirm with the netstat -nr command that the route indeed has been removed.

Now, as mentioned earlier, the route command will only temporarily (until the next reboot) add a route on the AIX system. To make things permanent, use the chdev command. This command takes the following form:

chdev -l inet0 -a route=net,-netmask,[your-netmask-goes-here],-static,[your-network-address-goes-here],[your-gateway-goes-here]

For example:

# chdev -l inet0 -a route=net,-netmask,,-static,,
inet0 changed

This time, again, you can confirm with the netstat -nr command that the route has been set up. But now you can also confirm that the route has been added to the ODM, by using this command:

# lsattr -El inet0 -a route | grep
route net,-netmask,,-static,, Route True

At this point, you can reboot the system, and you'll notice that the route is still there, by repeating the netstat -nr and lsattr -El inet0 commands.

To remove this permanent route from the AIX system, simply change the chdev command above from "route" to "delroute":

# chdev -l inet0 -a delroute=net,-netmask,,-static,,
inet0 changed

Finally, again confirm using the netstat -nr and lsattr -El inet0 commands that the route indeed has been removed.

0 (0)
Article Rating (No Votes)
Rate this article
There are no attachments for this article.
There are no comments for this article. Be the first to post a comment.
Full Name
Email Address
Security Code Security Code
Related Articles RSS Feed
Topics: AIX, Networking, System Admin
Viewed 549 times since Fri, Apr 19, 2019
AIX: How to identify the program listening in the given port
Viewed 536 times since Mon, Jun 11, 2018
Script to download TL and SP for AIX using NIM and SUMA
Viewed 655 times since Thu, Feb 21, 2019
Configure log file for cron daemon on AIX
Viewed 649 times since Thu, Feb 21, 2019
AIX disk queue depth tuning for performance
Viewed 392 times since Thu, Jan 16, 2020
AIX ODM for MPIO User Guide 09
Viewed 1031 times since Mon, Dec 31, 2018
AIX: Error code 0516-1339, 0516-1397 0516-792: cannot extendvg with a previous Oracle ASM disk
Viewed 659 times since Wed, Feb 6, 2019
Using Shell Redirection: All About the Here-Doc
Viewed 1256 times since Wed, May 30, 2018
0516-404 allocpThis system cannot fulfill the allocation
Viewed 502 times since Thu, Sep 20, 2018
List of 10 Must Know Oracle Database Parameters for Database Administrator
Viewed 6042 times since Thu, Jun 21, 2018