C.4 Using route for Routing Information

   


C.4 Using route for Routing Information

The route command serves to set and manage routing information in a computer. The route command knows exactly two options; one to set, and one to delete, static routes. Dynamic routes are set by routing protocols.

Syntax

route add [-A family] [-net| -host] address [gw gateway] [netmask mask]             [mss MSS] [dev interface] route del address

  • -A family specifies the address family (inet, inet6, etc.).

  • -n shows addresses in dotted decimal notation and does not attempt to resolve them into DNS names.

  • -e specifies the routing table in netstat format.

  • -ee shows all information of the routing table.

  • -net means that the specified address denotes a (sub)network and not a computer.

  • -host shows that the address denotes a computer.

  • -F shows the Forwarding Information Base (routing table). The options -e and -ee can be used to specify a format for the output.

  • -C shows the current routing cache of the kernel.

  • del deletes the specified route.

  • add adds a route to the routing table.

  • address specifies the route destination. This can be a (sub)network or a computer. The address can be written in dotted decimal notation or as a DNS name.

  • netmask mask is the network mask for the new route.

  • gw gateway specifies a gateway (router). All packets on this route are sent over this router, which knows the further path. Before it can be used as gateway for some destination, a computer has to know the route to it; either we must previously have set a static route, or the destination should be reachable over the default route.

  • metric metric sets the metrics for this entry in the routing table.

  • mss MSS sets the maximum segment size of TCP to MSS bytes. The default value is 536 bytes.

  • dev interface specifies that packets on this route should always be output over the specified network device. If no device is specified, then the kernel attempts to find a network device to be used from other routes.

  • default denotes the default route for all routes that do not have a matching entry in the routing table.

The output of the route command corresponds largely to the output of netstat. (See Section C.3.)

Examples

  • root@tux # route add -net 127.0.0.0.

    sets the entry for the loopback network device. Because no network mask was specified, the default network mask for a class-A network is assumed (255.0.0.0).

  • root@tux # route add -net 129.13.42.0 netmask 255.255.255.0 dev eth0

    forwards the route for all addresses in network 129.13.42.0 to the network eth0. Packets are sent directly to the computers in network 129.13.42, not over a router.

  • root@tux # route add default gw router-icsi.Berkeley.edu

    sets the default route to router router-icsi. All packets that have no matching route in the routing table are sent over this gateway. In IP computers, a default gateway should always be specified, because no computer stores the routes to all computers in the Internet.


       


    Linux Network Architecture
    Linux Network Architecture
    ISBN: 131777203
    EAN: N/A
    Year: 2004
    Pages: 187

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