0

I'm Looking at this routing table from netstat -r. routing table

How does the interface relate to the Gateway? the first entry has gateway 192.168.1.1 which is the gateway to the router. the Interface says 192.168.1.1 which is private IP in the 192.168.1.* network current. so I think any packet that doesn't match any other entry is sent to the router. My confusion is with an entry like the 5th one 192.168.1.0 with subnet mask 255.255.255.0 so a packet going to 192.168.1.32 for example is taken to Gateway On-link (not 100% sure what that means) and the interface is 192.168.1.11 which is the same interface as the default. so is this entry doing the same as the default? does the gateway make a difference?

so what happens when a packet wants to go to 192.168.1.32 does it go to the router 192.168.1.1 or does it mean that it just goes to 192.168.1.11 which is the same as just staying on the computer?

2

Welcome to Network Engineering.

The "Destination" is what's important here. Packets destined towards 192.168.1.0 in this case is on the same network as your network interface, which is why it's considered "On-link", which is why it has no gateway. You do not need to send traffic to a gateway when it's on the same network as you are.

Regarding "Interface" IP's, this is the IP Addresses of your network interface. You have two - 192.168.1.11 is your Network Adapter, and the 127.0.0.1 is your loopback adapter. All computers have an invisible loopback adapter. The Interface will show which interface is being used to send the traffic to the destination network.

A "gateway" is a router - when you need to send traffic to anywhere else not listed (0.0.0.0), then it will send the traffic to the gateway IP Address, so that it can route the traffic accordingly.

4
  • Hi, So the gateway and interface are basically saying we are sending this packet to this gateway from this interface. also, where are these packets that are being routed coming from. are these packets created by the computer itself? or are they just coming in from other devices and the computer routes them to the specified interface(if on-link) or to a gateway(like a router) from a specific interface. May 8 at 14:07
  • The answer depends on what kind of device it is. If the device needs to send a packet it uses the routing table to determine which interface to use.
    – Ron Trunk
    May 8 at 15:00
  • 1
    The packets are coming from your own computer. Windows machines will not by default do any routing of its own, so all traffic sourced will be from your own computer. For example, if it's doing windows updates, it needs to reach Microsoft, so it will use your default gateway. If you have a local printer like 192.168.1.50 - then it will send the traffic out using the On-Link line 5 that you mentioned.
    – KeyszerS
    May 9 at 7:57
  • Thanks, I think this makes sense now. May 9 at 16:49
0

How does the interface relate to the Gateway?

The gateway needs to be connected to the interface through a data-link-layer network (e.g. Ethernet). Both must share a common IP subnet (here that's 192.168.1.0/24).

The first entry 0.0.0.0/0 matches any address due to its zero-length mask. It's called the default route and its gateway the default gateway.

The entry 192.168.1.0/255.255.255.0 is for the locally connected subnet. Those hosts are on-link and can be talked to without a gateway (sometimes the local interface is displayed as the gateway as well).

In your case, there's only one interface and one gateway beyond the network connected there - the most simple case. Your host could have multiple interfaces (multi-homed) with multiple subnets on-link. In any of those subnets there could be gateways connecting elsewhere - to route to these 'elsewhere' networks, specific routes are required. Without those routes, the default gateway would be used.

what happens when a packet wants to go to 192.168.1.32? does it go to the router 192.168.1.1?

No. 192.168.1.32 matches the route destination 192.168.1.0/255.255.255.0 which says On-Link. Accordingly, the destination IP is sent to directly (for a MAC-based network, the destination IP is resolved to a MAC address using ARP and the packet is encapsulated by a frame addressed to that MAC). No gateway is used.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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