29.3 Adding Routes

   

When two or more networks are connected, routes must be defined to send data traffic from one network to another. These routes may be static or dynamic in nature. Static routes are manually defined and are fixed until changes are made. Dynamic routes, on the other hand, are established on the fly, depending on network conditions and available network paths between the source and destination. In this chapter, we will discuss only static routes.

A static route may represent a host route or a network path. A host route represents a path to a single machine, while a network route represents a path to a complete network.

Networks are connected through routers. A router is called a gateway when defining routes. Static routes are defined using the route command in HP-UX. These routes are set up at system startup along with assignment of IP addresses to the LAN adapters. Static routes can also be configured in the /etc/rc.config.d/ netconf file. A default route is used to send IP packets for which no other route is available. The default route entry is present in the /etc/rc.config.d/netconf file, for example:

 ROUTE_GATEWAY[0]=192.168.2.1 ROUTE_COUNT[0]=1 ROUTE_DESTINATION[0]=default 

These lines are used to set a default route to a router having IP address 192.168.2.1. All routes are present in a data structure known as a routing table. The netstat command is also used to display the current routing table. The following command lists all routes.

 #  netstat -rn  Routing tables Dest/Netmask          Gateway            Flags  Refs    Use  Interface  Pmtu 127.0.0.1             127.0.0.1          UH       0     303  lo0        4136 192.168.3.1           192.168.3.1        UH       0       0  lan2       4136 192.168.2.11          192.168.2.11       UH       0     126  lan0       4136 192.168.2.0           192.168.2.11       U        2       0  lan0       1500 192.168.3.0           192.168.3.1        U        2       0  lan2       1500 127.0.0.0             127.0.0.1          U        0       0  lo0        4136 default               192.168.2.1        UG       0       0  lan0       1500 # 

Different fields in the output of the netstat -rn command are:

Dest/Netmask Route destination. This may be either a host or a network.
Gateway The host IP address that will be used to send packets for this destination.
Flags Shows type of route. A " U " is this field shows that the route is currently up. If only this character is present in this column, the route is for a network. The " H " character shows that this route is for a single host. The " G " character shows that the route is through a gateway.
Refs Shows current use of the route.
Use Shows the number of packets sent through the route.
Interface LAN interface that is being used by the route.
Pmtu Path MTU. Its minimum value is 68.

Creating a Route

Routes are created using the route command. You can add specific host or network routes with the help of this command. The following example creates a route for network 192.168.4.0 and its gateway is router 192.168.2.1.

 route add net 192.168.4.0 netmask 255.255.255.0 192.168.2.1 

After adding this route, any data packets going to the 192.168.4.0 network will be forwarded to gateway 192.168.2.1. To add a host specific route for 192.168.5.3 through the same gateway, use the following command.

 route add host 192.168.5.3 netmask 255.255.255.255 192.168.2.1 

Newly created routes can be displayed using the netstat -rn command.

Deleting a Route

A route is deleted using the route command. The following example deletes a network route through gateway 192.168.2.1.

 #  route delete net 192.168.4.0 192.168.2.1  delete net 192.168.4.0: gateway 192.168.2.1 # 

An entire routing table may be flushed using the route -f command.

Default Routes

A default route through gateway 192.168.2.1 is added with the following command.

 route add default 192.168.2.1 1 

   
Top


HP Certified
HP Certified: HP-UX System Administration
ISBN: 0130183741
EAN: 2147483647
Year: 2000
Pages: 390
Authors: Rafeeq Rehman

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net