mercoledì 25 luglio 2012

The Meaning of 0.0.0.0 In Routing Table

The Meaning of 0.0.0.0 In Routing Table.

Each network host has a default route for each network card. 

This will create a 0.0.0.0 route for such card. The address 0.0.0.0 generally means "any address". 

If a packet destination doesn't match an individual address in the table, it must match a 0.0.0.0 gateway address. 

In other words, default gateway is always pointed by 0.0.0.0:

route -n

Sample outputs:

Kernel IP routing table
 
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.0.31.18      0.0.0.0         255.255.255.255 UH    0      0        0 ppp0
38.96.196.94    192.168.1.2     255.255.255.255 UGH   0      0        0 wlan0
192.168.84.0    0.0.0.0         255.255.255.0   U     0      0        0 vmnet8
192.168.1.0     0.0.0.0         255.255.255.0   U     2      0        0 wlan0
192.168.110.0   0.0.0.0         255.255.255.0   U     0      0        0 vmnet1
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 wlan0
10.0.0.0        0.0.0.0         255.0.0.0       U     0      0        0 ppp0
0.0.0.0         192.168.1.2     0.0.0.0         UG    0      0        0 wlan0

192.168.1.2 is my ISP router i.e. 
default gateway indicated by 0.0.0.0

Other destination such as 10.0.0.0/8 network use ppp0 interface as gateway. 

If you are MS-Windows user use route print command.

Flag G indicates path to route packets via a gateway. 

If you would like to visit yahoo.com from your computer you need to go via 192.168.1.1 gateway. 

This usually means that you have to set up a static route to the gateway beforehand. If you specify the address of one of your local interfaces, it will be used to decide about the interface to which the packets should be routed to. metric field used by routing daemons. This is required on large LAN and wan setups. The output of the kernel routing table is organized in the following columns:

  • Destination : The destination network or destination host.
  • Gateway : The gateway address or ’*’ if none set.
  • Genmask : The netmask for the destination net; 255.255.255.255 for a host destination and 0.0.0.0 for the default route.
  • Flags : Possible flags include
    • U (route is up)
    • H (target is a host)
    • G (use gateway)
    • R (reinstate route for dynamic routing)
    • D (dynamically installed by daemon or redirect)
    • M (modified from routing daemon or redirect)
    • A (installed by addrconf)
    • C (cache entry)
    • ! (reject route)
  • Metric : The distance to the target (usually counted in hops). It is not used by recent kernels, but may be needed by routing daemons.
  • Ref : Number of references to this route. (Not used in the Linux kernel.)
  • Use : Count of lookups for the route. Depending on the use of -F and -C this will be either route cache misses (-F) or hits (-C).
  • Iface : Interface to which packets for this route will be sent.
  • MSS : Default maximum segment size for TCP connections over this route.
  • Window : Default window size for TCP connections over this route.
  • irtt : Initial RTT (Round Trip Time). The kernel uses this to guess about the best TCP protocol parameters without waiting on (possibly slow) answers.
  • HH (cached only) : The number of ARP entries and cached routes that refer to the hardware header cache for the cached route. This will be -1 if a hardware address is not needed for the interface of the cached route (e.g. lo).
  • Arp (cached only) : Whether or not the hardware address for the cached route is up to date.
Your routing table is created automatically, based on the current TCP/IP configuration of your Linux / UNIX computer. You can manually add / modify / edit routing table using route and ip command. The types of entries in a routing table:
  • Network Route: A route (path) to a specific Network ID in the internetwork.
  • Host Route : A route to a specific internetwork address (Network ID and Host ID). Host routes allow intelligent routing decisions to be made for each network address. Host routes are used to create custom routes to control or optimize specific types of network traffic.
  • Default Route: A route that is used when no other routes for the destination are found in the routing table. If a router or end system (such as a PC running Microsoft Windows or Linux), cannot find a route for a destination, the default route is used. The default route is used if no other host or network route matches the destination address. Please see related FAQs below for more examples of route and ip command.

 

 

Nessun commento:

Posta un commento