Static routing and default route explain

Introduction: Understanding the concept of the concept of routing, the routing table. Learn how to manually configure the routing, namely static and default routing.

One: router works

1.1 routing explained

The router in the network layer of the OSI reference model, it is important role in selecting the best route for the packet, the final destination.

Routing: forwarding process from the source host to the target host.

Routing: To improve network access speed as much as possible, it is necessary to have a method to determine the best path to reach the destination host from the source host passes so as to perform data forwarding.

mark

Works 1.2 router

Internet routers can be understood as a transit point, the network packet is forwarded by a router to a destination network.

Router forwards packets by the routing table, select the best path to reach the destination network, the best path refers to an interface address of the next hop router or routers. That view the routing table of the target segment, select the corresponding interface out.

"Destination unreachable" forwarding packets procedure: forward the packet process, if the destination address of the packet is not found in the routing table, the forwarding according to the configuration of the router to the default interface or return "destination address to a user is not up "message.

mark

II: formation of a routing table

2.1 routing table explains

Set of routing entries in the routing table router is really maintained, routers make routing according to the routing table.

Forming the routing table 2.2

We understand by directly connected network segments and non-directly connected network segment.

Directly connected network segment: When we configure the IP address of the interface on the router, and interface status is "UP", the direct route of entry appears in the routing table.

In GNS3 software, we can practice it. R3 - R1 is a segment of the network segment 192.168.10.0, R1 - R2 is 192.168.20.0 subnet segment.

mark

mark

Non-directly connected network segment: see the figure! Is not directly connected to the router network segment are non-directly connected network segment. Non-directly connected network segment in the routing table, we need to achieve through static routing or dynamic routing.

mark

Three: static and default routing

3.1 Static Routing explanation

Static routes are manually configured, is one-way (if you want to achieve two-way communication, communication must be configured in both the static routing), lack of flexibility.

3.2 default route explain

The default route is a special static routing, routing entries when the router can not find the destination network in the routing table, the router sent the request to the default routing interface. If there is no default route, then the destination address does not match the packet routing entries in the routing table are discarded.

3.3 problems: routing priority

当路由表中同时存在静态路由和默认路由的时候,静态路由优先级最高,匹配上了立刻进行转发,如果没有匹配上静态路由,则交由默认路由转发。

3.4交换与路由对比

mark

四:路由器转发数据包的封装过程

mark

4.1环境介绍

存在不同网段中的两台初始化主机(只知道自己的IP和MAC地址和其他人的IP地址,但是不知道其他人的MAC地址),两台初始化的路由器(只知道自己的IP和MAC地址和其他人的IP地址,但是不知道其他人的MAC地址)。

4.2路由器转发数据包的封装过程

路由器转发原则:IP不变,MAC始终在变。

第一过程:想要实现主机A和主机B的互联互通,因为两台主机不在同一网段,所以主机A发送数据包给主机B必然经过路由器,所以需要经过路由器A转发。但是因为都是初始化机器,所以主机A并不知道路由器A的E0接口的MAC地址,所以主机A需用通过ARP广播请求来获得路由器A 的E0接口的MAC地址。那么此时,主机A发送给主机B的数据包中,源IP为192.168.1.2,源MAC是00-11-12-21-11-11,目标IP是192.168.2.2,目标MAC<u>为00-11-12-21-22-22</u>,此时目标MAC变成主机A的E0接口的MAC了。

第二过程:路由器A的E0接口接收到数据帧后,将数据帧的MAC头部解封,查看目标ip地址发现是192.168.2.2,所以路由器A会查找自己的路由表,然后将数据包转发到E1接口,到此,发现不知道路由器B的E1接口的MAC,找不到目标,所以此时这个数据包被丢弃。

第三过程:现在需要知道路由器B的E1接口的MAC,需要路由器A发送ARP广播请求。得到路由器B的E1接口的MAC后,主机A再次发送数据包。

第四过程:数据包到达路由器B的E1接口,先进行解封,检查目标IP和自己的路由表对应,将数据从自己的E0接口发出。此时,发现不知道主机B的MAC,所以这个数据包再次被丢弃。

Fifth process: ARP broadcast by router B, host B MAC is obtained, then the A when the host sends packets again to reach Host B directly.

One problem: ARP requests from Host A Why only get MAC E0 A router interface it?

A: ARP is a broadcast, each interface on the router is a broadcast domain, broadcast router is isolated, it can not pass through the router ARP.

Five: static and default routing configuration

5.1 Static Routing Configuration

mark

network: destination network address

mask: Subnet Mask

address: address of the next hop router interface to reach the destination network passes

interface: reach the destination network address of the local interface

5.2 default routing configuration

mark

"0.0.0.0 0.0.0.0": on behalf of any network, any network that is sent to the data packets are forwarded to the next router interface address specified in the order.

address: address of the next hop router interface to reach the destination network segment passes.

5.3 next-hop address

Address of the receiving opening with connected devices.

5.4 Static Routing experiment I wrote a blog alone, self-interested view.

Guess you like

Origin blog.51cto.com/14557670/2444896