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 10.0.0.0. And that network uses a netmask of 255.255.255.0 (or "24" for the short mask notation). Finally, the gateway that can be used to access this network is 192.168.0.1. 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 10.0.0.0 -netmask 255.255.255.0 192.168.0.1

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

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

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

# route delete -net 10.0.0.0 -netmask 255.255.255.0 192.168.0.1

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,255.255.255.0,-static,10.0.0.0,
192.168.0.1
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 192.168.0.1
route net,-netmask,255.255.255.0,-static,10.0.0.0,192.168.0.1 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,255.255.255.0,-static,10.0.0.0,
192.168.0.1
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
Attachments
There are no attachments for this article.
Comments (1)
Comment By Arif Shaikh - Mon, Oct 5th, 2020 12:12 AM
hi
Full Name
Email Address
Security Code Security Code
Related Articles RSS Feed
Ethernet tunning for VIOS and AIX for 10 Gib/sec environtement.
Viewed 10595 times since Thu, Feb 21, 2019
Using Kerberos security with Server for NFS
Viewed 9704 times since Wed, Jun 27, 2018
AIX snap - Prevent dump collection
Viewed 12338 times since Mon, Sep 17, 2018
bootlist multiple boot logical volume found
Viewed 2776 times since Tue, Apr 16, 2019
This document discusses a new feature implemented for JFS2 filesystems to prevent simultaneous mounting.
Viewed 2906 times since Sat, Jun 1, 2019
0516-787 extendlv: Maximum allocation for logical volume error
Viewed 9045 times since Tue, Mar 12, 2019
Remove disk from volumegroup in AIX
Viewed 6965 times since Tue, Apr 16, 2019
AIX Undocumented AIX command lquerypv
Viewed 3676 times since Tue, Jul 17, 2018
Top 4 Reasons for Node Reboot or Node Eviction in Real Application Cluster (RAC) Environment
Viewed 98918 times since Thu, Jun 21, 2018
AIX - How to extend JFS filesystem
Viewed 19193 times since Fri, Jun 8, 2018