TimeLinux1

Monday, September 27, 2010

Linux HowTo: Routing Basics

What is a Router?

In the simplest terms, a Router is a network device sitting between two networks and permitting communication between them. It is sometimes also referred to as a 'gateway' although a gateway is really a special router that does routing + network address translation.
     ie gateway = router + nat

-note:      typically during a network communication, sending hosts dont know their destn, they just know the nearest router (which they find out from their routing table).
-routing is basically the act of 'ip forwarding' [ not to be confused this with port forwarding, which is ssh tunnelling ]

-'route' cmd is used to define routes for a host:
-eg:    # route  add    -net    default  gw    192.168.1.1    dev    eth0            [ set the default route for eth0 ]
          # route  del    192.168.2.50                            [ delete route for 192.168.2.50 ]

-The routing table for a host can be displayed using one of the foll cmds:
        -route
        -netstat
        -ip route
eg:    # route  -n                      [ doesnt try to do hostname resolution ie shows numeric IP addr ]
        # netstat -nr                    [ r=route, n=no hostname resolution ie shows numeric IP addr ]
        # ip route show table main        [ shows the main table, linux can have multiple route tables ]

-Linux can act as a full featured router. Many commercial routers run the linux kernel.
-A standard pc with afew network cards can act as a basic router.
-To set routing (ie ip forwarding on), do this:
        # echo "1"    >    /proc/sys/net/ipv4/ip_forward

No comments:

Post a Comment