2

There are two entries in this table. From my understanding first is used for all outgoing traffic (local address of my modem is 192.168.1.1 ), and part of OS which is responsible for networking just passes packet to modem which send it to ISP etc. But, I am not sure what is second entry for. At first I thought that it is used for incoming traffic but destination address seems wrong since local address of host is 192.168.1.3 according to ifconfig

Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0

ifconfig:

eth0      Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx  
          inet addr:192.168.1.3  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:592510 errors:0 dropped:0 overruns:0 frame:0
          TX packets:398904 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 

So, am I wrong about first entry? What is purpose of second one?

0

2 Answers 2

2

The first entry with the destination of 0.0.0.0 with a mask of 0.0.0.0 means that any IPv4 packets which don't match any other entries will be sent to the gateway 192.168.1.1.

The second entry of 192.168.1.0 with a mask of 255.255.255.0 means that any IPv4 packets withing the range of 192.168.1.0/24 will be sent on the same link as this host.

In other words, any packets destined for the local network will use ARP (or the ARP cache) to build a frame for the local network. Any other packets will ARP (or use the ARP cache) for the gateway MAC address to build the frame.

2
  • Thanks. But how packets sent from host connected with ethernet packets get to 802.11 devices in same network. (ie. my phone is connected to modem with 802.11 and have address 192.168.1.2, PC is connected with ethernet to same modem and have IP 192.168.1.3. Since they are not physically connected phone can't respond to PC ARP broadcast message. Do modem mimic phone and responds instead it?)
    – not joe
    Dec 27, 2015 at 20:06
  • 1
    The WAP is a translating bridge. It takes ethernet frames and translates them to Wi-Fi frames, and vice versa. If the wired and wireless are on the same network, they are treated as the same layer-2 domain, even though they really are not, since Wi-Fi and ethernet are different layer-1 and layer-2 media and protocols.
    – Ron Maupin
    Dec 27, 2015 at 23:52
4

What route -n (or netstat -rn) is showing you needs a bit of interpretation - a "gateway" of 0.0.0.0 means that the next hop for any packet sent to this subnet is the actual destination host, not a router. If the "gateway" is not 0.0.0.0, then all packets destined for this subnet will actually be sent to the MAC address of the gateway (which will then handle their next-hop forwarding). So, in your case, your routing table has a route for the locally attached segment, and then a route for "everything else".

The general flow of IP packet forwarding from any host is shown in this flow chart:

Host IP Packet Flow

The general gist of this is that the host (on ethernet or wifi) ultimately is trying to find the MAC address to send this packet to, and the routing table will help it decide (either the MAC of the actual destination host, if it's on the same segment, or the MAC address of the router for this segment).

As to your question in another answer about how does your host see an ARP - ARP requests are transmitted using a broadcast destination MAC, which means they will be seen by every host in the same broadcast domain, regardless of whether they are attached to the same bridge or not. A router will not forward them into another broadcast domain, but a bridge (like your wireless AP in this case) will transmit the ARP across your local network.

Not the answer you're looking for? Browse other questions tagged or ask your own question.