您的位置:首页 > 理论基础 > 计算机网络

TCP/IP 详解 卷1 ch9 IP Routing

2010-11-08 22:34 323 查看
1. For the host which is not configured as router, datagrams received through the network interfaces that are not ours are dropped.

2. the steps that IP performs when it searches its routing table.

1) Search for a matching host address.

2) Search for a matching network address.

3) Search for a default entry. (The default entry is normally specified in the routing table as a network entry, with a network ID of 0.)

A matching host address is always used before a matching network address.

先匹配主机地址,然后匹配网络地址

3. netstat -rn

/home/a/j/nomad2:netstat -r
Routing Table: IPv4
Destination           Gateway           Flags  Ref   Use   Interface
-------------------- -------------------- ----- ----- ------ ---------
192.168.1.0          x4100.unix-center.net U         1   5016 e1000g0
224.0.0.0            x4100.unix-center.net U         1      0 e1000g0
default              192.168.1.1          UG        1  31181
localhost            localhost            UH        2   1581 lo0
Routing Table: IPv6
Destination/Mask            Gateway                   Flags Ref   Use   If
--------------------------- --------------------------- ----- --- ------ -----
fe80::/10                   fe80::214:4fff:fe45:f196    U       1      0 e1000g0
ff00::/8                    fe80::214:4fff:fe45:f196    U       1      0 e1000g0
default                     fe80::214:4fff:fe45:f196    U       1      0 e1000g0
localhost                   localhost                   UH      1    843 lo0
/home/a/j/nomad2:netstat -n
TCP: IPv4
Local Address        Remote Address    Swind Send-Q Rwind Recv-Q    State
-------------------- -------------------- ----- ------ ----- ------ -----------
192.168.1.10.22      123.185.162.221.36531 16448      0 50400      0 ESTABLISHED
192.168.1.10.22      120.82.220.22.53947  261528      0 49980      0 ESTABLISHED
192.168.1.10.823     192.168.2.5.2049     64128      0 49640      0 ESTABLISHED
192.168.1.10.38284   192.168.2.5.389      32640      0 49640      0 ESTABLISHED
192.168.1.10.22      192.168.1.18.61797   65535      0 49640      0 ESTABLISHED
192.168.1.10.22      123.185.162.221.38773 16448      0 50400      0 LAST_ACK
192.168.1.10.57425   192.168.2.5.389      393728      0 49640      0 ESTABLISHED
192.168.1.10.22      123.185.162.221.35909 16448      0 50400      0 ESTABLISHED
192.168.1.10.22      117.88.79.188.51905  64980      0 50400      0 ESTABLISHED
192.168.1.10.22      221.215.188.13.3721  15816     35 49284      0 ESTABLISHED
192.168.1.10.48229   192.168.2.5.389       6912      0 49640      0 TIME_WAIT
192.168.1.10.48230   192.168.2.5.389       6912      0 49640      0 TIME_WAIT
192.168.1.10.48231   192.168.2.5.389       6912      0 49640      0 TIME_WAIT
192.168.1.10.48232   192.168.2.5.389       6912      0 49640      0 TIME_WAIT
192.168.1.10.48233   192.168.2.5.389       6912      0 49640      0 TIME_WAIT
192.168.1.10.48234   192.168.2.5.389       6912      0 49640      0 TIME_WAIT
192.168.1.10.48235   192.168.2.5.389       6912      0 49640      0 TIME_WAIT
192.168.1.10.48236   192.168.2.5.389       6912      0 49640      0 TIME_WAIT
192.168.1.10.48237   192.168.2.5.389       6912      0 49640      0 TIME_WAIT
192.168.1.10.48238   192.168.2.5.389       6912      0 49640      0 TIME_WAIT
192.168.1.10.22      120.82.220.80.32140  261352      0 49980      0 ESTABLISHED
Active UNIX domain sockets
Address  Type          Vnode     Conn  Local Addr      Remote Addr
fffffe913273a760 stream-ord 0000000 0000000
ffffffffad9b8750 stream-ord 0000000 0000000
ffffffffacadf748 stream-ord ffffffff9c8f5d40 0000000 /tmp/ssh-OgS27674/agent.27674
ffffffff95203900 stream-ord 0000000 0000000
ffffffff8777e398 stream-ord 0000000 0000000
ffffffff8777ec80 stream-ord ffffffff8777fbc0 0000000 /var/run/.inetd.uds
/home/a/j/nomad2:netstat -rn
Routing Table: IPv4
Destination           Gateway           Flags  Ref   Use   Interface
-------------------- -------------------- ----- ----- ------ ---------
192.168.1.0          192.168.1.10         U         1   5016 e1000g0
224.0.0.0            192.168.1.10         U         1      0 e1000g0
default              192.168.1.1          UG        1  31181
127.0.0.1            127.0.0.1            UH        2   1581 lo0
Routing Table: IPv6
Destination/Mask            Gateway                   Flags Ref   Use   If
--------------------------- --------------------------- ----- --- ------ -----
fe80::/10                   fe80::214:4fff:fe45:f196    U       1      0 e1000g0
ff00::/8                    fe80::214:4fff:fe45:f196    U       1      0 e1000g0
default                     fe80::214:4fff:fe45:f196    U       1      0 e1000g0
::1                         ::1                         UH      1    843 lo0


for a given route, the flag is like following,

U The route is up.
G The route is to a gateway (router). If this flag is not set, the destination is directly connected.
H The route is to a host, that is, the destination is a complete host address. If this flag is not set, the route
is to a network, and the destination is a network address: a net ID, or a combination of a net ID and a
subnet ID.
D The route was created by a redirect (Section 9.5).
M The route was modified by a redirect <br>


4. indirect route VS. direct route

A packet going out a direct route has both the IP address and the link-layer address specifying the destination (without G flag);

When a packet is sent out an indirect route, the IP address specifies the final destination but the link-layer address specifies the gateway (that is, the next-hop router).

5. The H flag, however, specifies that the destination address (the first column of netstat output) is a complete host address. The absence of the H flag means the destination address is a network address (the host ID portion will be 0).

如果没有H,说明是一个网络号,例如3中的最后一条

6. The ICMP "host unreachable" error message is sent by a router when it receives an IP datagram that it cannot deliver or forward.

for example,

/home/a/j/nomad2:ping 192.82.14.1
ICMP Communication Administratively Prohibited from gateway 75.101.32.66
for icmp from x4100.unix-center.net (192.168.1.10) to 192.82.14.1
no answer from 192.82.14.1


7. ICMP Redirect Errors

ICMP redirects allow TCP/IP hosts to be dumb when it comes to routing, with all the intelligence in the routers
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: