Route, Routing, Routing Table

Here’s some information about routing from a Unix (Solaris) box. Got this request from one of the Network people to add a static route on a server.

The command

# netstat -rn

show the routing table on a *nix machine .

The ‘route’ command manually manipulates the network routing table on a Unix box.

The add and delete sub-commands have the following syntax:

route [ -fnvq ] cmd destination gateway [metric/netmask]

So to display server1’s routing table,

 [root@server1]# netstat -rn
Routing Table: IPv4
Destination           Gateway           Flags  Ref   Use   Interface
——————– ——————– —– —– —— ———
10.122.23.0           10.122.23.32         U        11340517  ce0
224.0.0.0               10.122.23.32         U        1      0  ce0
default                    10.122.23.1          UG       1 687333
127.0.0.1                127.0.0.1             UH       1  27928  lo0

Another example:

If we wanted to reach 192.168.1.0 network passing through 10.122.23.32 we could add the network by using the ‘route’ command:

 [root@server1]# route add 192.168.1.0 10.122.23.32 1

Checking routing table:

 [root@server1]# netstat -rn
Routing Table: IPv4
Destination           Gateway           Flags  Ref   Use   Interface
——————– ——————– —– —– —— ———
10.122.23.0           10.122.23.32         U        11340517  ce0
224.0.0.0               10.122.23.32         U        1      0  ceo
192.168.1.0            10.122.23.32         UGH  1
default                    10.122.23.1          UG       1 687333
127.0.0.1                127.0.0.1             UH       1  27928  lo0

The only problem with this is that if the server is rebooted, the manually added static route will be gone. If order to retain that route, it has to be added in one of the startup script.

You could create a  script in one of the RC directory, name it something relevant like, say S90StaticRoutes or something and add the ‘route add’ line we did above.

Leave a Reply

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