Monday, August 29, 2011

How to set a static routes in AIX

You can use the route command to set a static route. But this way you don't get it back after reboot. 
To make a route persistent you need to change inet0. First check which routes are already set: 

 # lsattr -El inet0 -a route
 route net,-hopcount,0,,0,192.168.1.1 Route True
 route net,-hopcount,255.255.255.128,,,,,192.168.3.155,192.168.2.1 Route True

These routes would be set with: 
 # chdev -l inet0 -a route=net,-hopcount,0,,0,192.168.1.1
 # chdev -l inet0 -a route=net,-hopcount,255.255.255.128,,,,,192.168.3.155,192.168.2.1

To remove these specific static routes: 
 # chdev -l inet0 -a delroute=net,-hopcount,0,,0,192.168.1.1
 # chdev -l inet0 -a delroute=net,-hopcount,255.255.255.128,,,,,192.168.3.128,192.168.2.1

In this route string 255.255.255.128 is the netmask, 192.168.3.128 the destination net, and 192.168.2.1 the gateway. 
For hostroutes the keyword net has to be replaced with host.