Understanding Routing table entry

前端 未结 3 1118
温柔的废话
温柔的废话 2021-01-30 02:39

I want to ask a question about route command in Linux. I have enter following command in Linux terminal

> route

and got the output:

3条回答
  •  时光取名叫无心
    2021-01-30 03:09

    • Destination = the address of the network that the packet is headed to

    The "default" means that if the destination is not found in any of the other rules than use this rule.

    • Genmask = The subnet mask

    If there is more than one address in the routing table that works for the outgoing packet, the rule with the higher subnet mask will be used. If those are tied, then metric comes into play but that will be different based on what protocol is being used.

    • Interface = On-board connection

    For example, the laptop I am on currently has three interfaces:

    1. Ethernet card
    2. Wireless card
    3. Bluetooth

    Routers generally have at least 2 interfaces for each side, 1 for each network they are a part of. For most home routers, 1 interface is part of your home network and the other is part of the external network headed toward your ISP.

    • Gateway = Next hop

    This is where the packet will be sent if the destination is not on the same network as the sender.

    If the value is in "*" or "On-link" or the address of the current device... these all mean the same thing. It means that the packet is addressed to a device that is directly reachable by the current host. In other words, they're on the same network so the gateway won't actually be used because the host will know the data link layer (MAC) address of the destination and be able to send it directly there. These values are just used for human readability in this case.

    As for the process of sending a packet:

    • Destination and Genmask are used to figure out which rules are a match for the destination address of the outgoing packet.
    • Interface is used to decide what communication device on the machine to send it through.
    • Gateway is the address of the device on the same network that it will send the packet to (through).

提交回复
热议问题