About the route command - Networking

This is a discussion on About the route command - Networking ; I've a doubt with route. I get this output when I run "route -n" : Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo Shouldn't be the flag UH ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: About the route command

  1. About the route command

    I've a doubt with route. I get this output when I run "route -n" :

    Kernel IP routing table
    Destination Gateway Genmask Flags Metric Ref
    Use Iface
    127.0.0.0 0.0.0.0 255.0.0.0 U
    0 0 0 lo

    Shouldn't be the flag UH instead?, since localhost is a host, isn't
    it?
    TIA


  2. Re: About the route command

    On 22 Apr 2007, in the Usenet newsgroup comp.os.linux.networking, in article
    <1177248396.294458.100750@o5g2000hsb.googlegroups.c om>, Neroku wrote:

    >I've a doubt with route. I get this output when I run "route -n" :
    >
    >Kernel IP routing table
    >Destination Gateway Genmask Flags Metric Ref Use Iface
    >127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo


    OK - pretty standard

    >Shouldn't be the flag UH instead?, since localhost is a host, isn't
    >it?


    'localhost' (or more accurately, the loopback) is a slightly different
    in that any address in the range 127.0.0.0 to 127.255.255.255 is "this"
    computer. The loopback interface is a memory location with two names -
    'loopback transmit' and 'loopback receive', and any packet put into the
    transmit queue appears (at the same time) in the receive queue. The
    _name_ localhost is defined in /etc/hosts (but is also hardcoded in
    some aspects of the networking code) and if you want to be exact then
    localhost is 127.0.0.1. But that's not what the routing table is
    showing you. Try the same command without the -n, and you'll get the
    same display unless you've identified th 127.0.0.0/8 _network_ in one
    of the configuration files. But you can prove that the network route
    is correct by trying to ping addresses in that range:

    [compton ~]$ ping -c1 127.0.0.0
    PING 127.0.0.0 (127.0.0.0): 56 data bytes
    64 bytes from 127.0.0.0: icmp_seq=0 ttl=64 time=0.4 ms

    --- 127.0.0.0 ping statistics ---
    1 packets transmitted, 1 packets received, 0% packet loss
    round-trip min/avg/max = 0.4/0.4/0.4 ms
    [compton ~]$ ping -c1 127.255.255.255
    PING 127.255.255.255 (127.255.255.255): 56 data bytes
    64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.4 ms

    --- 127.255.255.255 ping statistics ---
    1 packets transmitted, 1 packets received, 0% packet loss
    round-trip min/avg/max = 0.4/0.4/0.4 ms
    [compton ~]$

    Assuming you have a server of some kind listening to localhost...
    telnet is a simple ony to use as a demonstration, you can then
    telnet to _any_ IP address in that 127.0.0.0/8 range and get the
    same results.

    Now, the H Flag is set based on the supplied network mask information,
    and as the mask is not 255.255.255.255, this is not a Host route.

    Another thing to look at is the output of the '/sbin/ifconfig' command.
    Look at the 'packets' count for transmit and receive, and they will be
    equal. The counts will also show that any packets going to "this"
    computer _from_ "this" computer will use the loopback interface even
    if you have an Ethernet interface that is "up". If your 'eth0' interface
    is 192.168.1.1, then when you 'ping' that address, the packets will use
    the loopback interface - why clutter up the wires when you are only
    "talking" to yourself? The kernel knows all IP addresses of "this"
    computer, and does the routing automagically.

    Old guy

  3. Re: About the route command

    On Apr 22, 6:26 am, Neroku wrote:
    > I've a doubt with route. I get this output when I run "route -n" :
    >
    > Kernel IP routing table
    > Destination Gateway Genmask Flags Metric Ref
    > Use Iface
    > 127.0.0.0 0.0.0.0 255.0.0.0 U
    > 0 0 0 lo
    >
    > Shouldn't be the flag UH instead?, since localhost is a host, isn't
    > it?
    > TIA


    You are confusing 127.0.0.1 (localhost) with 127.0.0.0/8 (localnet).
    Localhost is a host, but this is localnet, which is a network.

    DS


+ Reply to Thread