Hello everyone, today I will learn the configuration of Huawei routers, so that you can easily master the network construction. If you think it's useful, you can quickly like and collect it!
Read the table of contents
- Basic router configuration
- Configure static routes
- RIP dynamic routing
- OSPF Dynamic Routing
Router (Router), is connected to the Internet in the local area network, wide area network equipment, it will automatically select and set the route according to the situation of the channel, with the best path, in order to send signals, the router works in the network layer, used to communicate across network segments, the router has the function of judging the network address and selecting the IP path, it can establish a flexible connection in the multi-network interconnection environment, and can connect various subnets with completely different data grouping and media access methods, The router only accepts the information of the origin server or other routers, and is an interconnection device at the network layer, so the router is one of the indispensable network devices in the Internet.
Router, its most important function is routing, routing refers to the router receives the data when choosing the best path to transmit the data through the network to the destination address behavior, each router is responsible for its own local data routing or forwarding, through a plurality of routers in turn relay the data will finally be delivered to the target host, the routing workflow includes routing selection and routing forwarding two aspects.
01. Basic router configuration
The router is different from the switch, the switch does not need to be configured to work normally, but the router must be configured before it can be used normally, the login mode of the router is basically the same as the switch, the following will use an instance to implement the basic configuration of the router, including configuring the hostname, password, console port, WAN interface and LAN interface of the router, etc., to achieve a basic routing structure.
First of all, we prepare two routers (routers), what needs to be noted is the type of line selected for the connection between the devices, generally the router and the PC use a crossover line, and the two routers are connected to use a serial line, which can be configured into the following topology:
Configure WAN interface: The router is connected to the Internet through the WAN interface, and the common WAN interface is a serial interface, which will be configured according to the interface in the above figure.
#----在Router1上操作-------------------------
<R1> system-view
[R1] interface Serial 0/0/0 // 选择外网接口
[R1-Serial0/0/0]
[R1-Serial0/0/0] ip address 10.10.10.10 255.255.255.0 // 配置外网地址
#----在Router2上操作-------------------------
<R2> system-view
[R2] interface Serial 0/0/0
[R2-Serial0/0/0]
[R2-Serial0/0/0] ip address 10.10.10.20 255.255.255.0
Configure LAN interface: The LAN interface is used to specify the address of the internal network communication, and then configure the two routers separately.
#----在Router1上操作-------------------------
<R1> system-view
[R1]interface Ethernet 0/0/0
[R1-Ethernet0/0/0]
[R1-Ethernet0/0/0] ip address 192.168.1.1 255.255.255.0
#----在Router2上操作-------------------------
<R2> system-view
[R2]interface Ethernet 0/0/0
[R2-Ethernet0/0/0]
[R2-Ethernet0/0/0]ip address 192.168.1.1 255.255.255.0
查看路由表: 最后可以使用display ip routing-table命令,查看路由器的路由信息,确定网络是否正确连接.
[R1] display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.10.10.0/24 Direct 0 0 D 10.10.10.10 Serial0/0/0
10.10.10.10/32 Direct 0 0 D 127.0.0.1 Serial0/0/0
10.10.10.20/32 Direct 0 0 D 10.10.10.20 Serial0/0/0
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.1.0/24 Direct 0 0 D 192.168.1.1 Ethernet0/0/0
192.168.1.1/32 Direct 0 0 D 127.0.0.1 Ethernet0/0/0
Check the interface information: You can also use the display ip interface brief command to view the interface information of the router.
[R1] display ip interface brief
Interface IP Address/Mask Physical Protocol
Ethernet0/0/0 192.168.1.1/24 up up
Ethernet0/0/1 unassigned down down
GigabitEthernet0/0/0 unassigned down down
NULL0 unassigned up up(s)
Serial0/0/0 10.10.10.10/24 up up
Serial0/0/1 unassigned down down
Finally, test the communication: R1 can ping R2 on router R1, and each host can also ping router on its own network segment.
[R1] ping 10.10.10.20
PING 10.10.10.20: 56 data bytes, press CTRL_C to break
Reply from 10.10.10.20: bytes=56 Sequence=1 ttl=255 time=30 ms
Reply from 10.10.10.20: bytes=56 Sequence=2 ttl=255 time=40 ms
Reply from 10.10.10.20: bytes=56 Sequence=3 ttl=255 time=70 ms
Reply from 10.10.10.20: bytes=56 Sequence=4 ttl=255 time=30 ms
Reply from 10.10.10.20: bytes=56 Sequence=5 ttl=255 time=30 ms
The above small experiment is successfully configured here, but there is a question left here, that is, PC0PingPC1 cannot communicate, which involves the problem that the router does not have the corresponding route entry, and these problems will be explained in the later small experiment.
02. Configure static routes
Static routes need to be manually configured by the administrator according to the actual needs, the router will not automatically generate the required static routes, the static routes include the IP address of the destination node or the target network, and can also include the next hop IP address, as well as the packet outbound interface when the static route is used on the router, etc., but the manual configuration of static routes requires the administrator to understand the topology of the network very well to complete the configuration, and it also takes a lot of experience and time to maintain when the network is large. Therefore, not all networks are suitable for static routing.
In general, static routes can be used in the following situations:
1. The topology of the network is relatively simple, for example, in the case of a router and switch, static routes can be used.
2. The network confidentiality requirements are high, and the network administrator needs to control the link or control the routing table, then the static route can be used.
3. The network only connects to the Internet through a single ISP, then the ISP is the only exit of the network, so there is no need to configure static routes.
4. The routing resources are limited and the routing protocol cannot be run, in this case, the route entries need to be manually configured to update the routing table data.
Next, an example is used to describe the configuration process of static routes, select 3 routers in the Cisco simulator, build a network according to the following network topology, and then configure static routes for each router to achieve data exchange between different networks.
Configure the router: Configure the router according to the above topology diagram, and configure the IP address for each interface of the router through the ip address.
#----在R1上操作-------------------------
<Huawei> system-view
[Huawei] interface Ethernet 0/0/0
[Huawei-Ethernet0/0/0] ip address 192.168.1.1 255.255.255.0
[Huawei-Ethernet0/0/0] quit
[Huawei] interface Ethernet 0/0/1
[Huawei-Ethernet0/0/1] ip address 10.10.10.1 255.255.255.0
[Huawei-Ethernet0/0/1] quit
#----在R2上操作-------------------------
<Huawei> system-view
[Huawei] interface Ethernet 0/0/0
[Huawei-Ethernet0/0/0] ip address 10.10.10.2 255.255.255.0
[Huawei-Ethernet0/0/0] quit
[Huawei] interface Ethernet 0/0/1
[Huawei-Ethernet0/0/1] ip address 20.20.20.2 255.255.255.0
[Huawei-Ethernet0/0/1] quit
#----在R3上操作-------------------------
<Huawei> system-view
[Huawei] interface Ethernet 0/0/0
[Huawei-Ethernet0/0/0] ip address 192.168.2.1 255.255.255.0
[Huawei-Ethernet0/0/0] quit
[Huawei] interface Ethernet 0/0/1
[Huawei-Ethernet0/0/1] ip address 20.20.20.3 255.255.255.0
[Huawei-Ethernet0/0/1] quit
Check the configuration result: After configuring the IP address of the router, we test whether the adjacent interfaces are reachable on each router.
[R1] ping 10.10.10.2
PING 10.10.10.2: 56 data bytes, press CTRL_C to break
Reply from 10.10.10.2: bytes=56 Sequence=1 ttl=255 time=130 ms
[R2] ping 20.20.20.3
PING 20.20.20.3: 56 data bytes, press CTRL_C to break
Reply from 20.20.20.3: bytes=56 Sequence=1 ttl=255 time=110 ms
Configure static routes: Next, we need to configure route entries on the two routers separately, use the ip route-static command to configure, if you want to delete the route, you can use the undo ip route command to delete the specified route entry.
#----在R1上操作-------------------------
<Huawei> system-view
[目的网络] [目的掩码] [下一跳地址]
[Huawei] ip route-static 192.168.2.0 255.255.255.0 10.10.10.2
[Huawei] display ip routing-table
#----在R2上操作-------------------------
<Huawei> system-view
[Huawei] ip route-static 192.168.2.0 255.255.255.0 20.20.20.3
[Huawei] ip route-static 192.168.1.0 255.255.255.0 10.10.10.1
[Huawei] display ip routing-table
#----在R1上操作-------------------------
<Huawei> system-view
[Huawei] ip route-static 192.168.1.0 255.255.255.0 20.20.20.2
[Huawei] display ip routing-table
Test Phase: Finally, Ping on host PC1 to test PC2 and find that the packets can be delivered normally.
PC1> ping 192.168.2.2 -t
Ping 192.168.2.2: 32 data bytes, Press Ctrl_C to break
From 192.168.2.2: bytes=32 seq=1 ttl=125 time=125 ms
--- 192.168.2.2 ping statistics ---
1 packet(s) transmitted
1 packet(s) received
0.00% packet loss
round-trip min/avg/max = 125/125/125 ms
The above routing configuration method is suitable for small network environment, in large network environment, this static routing configuration method is not suitable for maintenance, once there are too many devices, you may not be able to figure it out, so in the production environment, we will use dynamic routing to achieve the configuration of routers, and then continue to learn the configuration of dynamic routing.
03. RIP dynamic routing
Dynamic routing is based on a certain protocol, and the common routing protocols are Interior Gateway Protocol (IGP) and Border Gateway Protocol (BGP), among which the Interior Gateway Protocol is divided into Routing Information Protocol (RIP) and Open Shortest Path First Protocol (OSPF) protocol.
RIP uses hops to measure the distance to the destination address, which refers to the number of routers that data passes from the source address to the destination address. The number of hops from the router to the network connected directly is defined as 1, and the value increases by 1 for each router, and the maximum number of hops allowed by RIP is 15 hops, and the network beyond 15 hops will not be reachable, so RIP is suitable for small network environments.
By default, the RIP protocol will broadcast its own routing table with other connected networks every 30 seconds, and the router that receives the broadcast will compare the received information with its own routing table to determine whether to add the route entries to its own routing table, at present, RIP has 3 versions, RIPv1, RIPv2, RIPng, where RIPng is used in IPv6 network environment, RIPv1 is a class-based routing protocol, and RIPv2 is a classless routing protocol.
Configure the routers: First, configure the IP addresses of the four routers on the corresponding interfaces according to the figure above.
#----在R1上操作-------------------------
<Huawei> system-view
[Huawei] interface Serial 0/0/0
[Huawei-Serial0/0/0] ip address 192.168.10.1 255.255.255.0
[Huawei-Serial0/0/0] quit
#----在R2上操作-------------------------
<Huawei> system-view
[Huawei] interface Serial 0/0/0
[Huawei-Serial0/0/0] ip address 192.168.10.2 255.255.255.0
[Huawei-Serial0/0/0] quit
[Huawei] interface Serial 0/0/1
[Huawei-Serial0/0/1] ip address 192.168.20.1 255.255.255.0
[Huawei-Serial0/0/1] quit
#----在R3上操作-------------------------
<Huawei> system-view
[Huawei] interface Serial 0/0/0
[Huawei-Serial0/0/0] ip address 192.168.20.2 255.255.255.0
[Huawei-Serial0/0/0] quit
[Huawei] interface Serial 0/0/1
[Huawei-Serial0/0/1] ip address 192.168.30.1 255.255.255.0
[Huawei-Serial0/0/1] quit
#----在R4上操作-------------------------
<Huawei> system-view
[Huawei] interface Serial 0/0/0
[Huawei-Serial0/0/0] ip address 192.168.30.2 255.255.255.0
[Huawei-Serial0/0/0] quit
Configure and enable RIP routing: Next, we enable and configure RIP dynamic routing on each router and specify the direct network number.
#----在R1上启用RIP路由协议并配置-------------------
<Huawei> system-view
[Huawei] rip 1 // 启动RIP进程1
[Huawei-rip-1] version 2 // 指定使用RIP版本为RIPv2
[Huawei-rip-1] network 192.168.10.0 // 声明与R1直连的网络号
[Huawei-rip-1] quit
#----在R2上启用RIP路由协议并配置-------------------
<Huawei> system-view
[Huawei] rip 1 // 启动RIP进程1
[Huawei-rip-1] version 2 // 指定使用RIP版本为RIPv2
[Huawei-rip-1] network 192.168.10.0 // 声明与R2直连的网络号
[Huawei-rip-1] network 192.168.20.0 // 声明与R3直连的网络号
[Huawei-rip-1] quit
#----在R3上启用RIP路由协议并配置-------------------
<Huawei> system-view
[Huawei] rip 1 // 启动RIP进程1
[Huawei-rip-1] version 2 // 指定使用RIP版本为RIPv2
[Huawei-rip-1] network 192.168.20.0 // 声明与R3直连的网络号
[Huawei-rip-1] network 192.168.30.0 // 声明与R4直连的网络号
[Huawei-rip-1] quit
#----在R4上启用RIP路由协议并配置-------------------
<Huawei> system-view
[Huawei] rip 1 // 启动RIP进程1
[Huawei-rip-1] version 2 // 指定使用RIP版本为RIPv2
[Huawei-rip-1] network 192.168.30.0 // 声明与R4直连的网络号
[Huawei-rip-1] quit
Check the configuration information: After the configuration is complete, RIP will automatically generate route entries, and you can run the display ip routing-table to query the configuration result.
[Huawei] display ip routing-table
------------------------------------------------------------------------------
Destination/Mask Proto Pre Cost Flags NextHop Interface
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.10.0/24 Direct 0 0 D 192.168.10.2 Serial0/0/0
192.168.10.1/32 Direct 0 0 D 192.168.10.1 Serial0/0/0
192.168.10.2/32 Direct 0 0 D 127.0.0.1 Serial0/0/0
192.168.20.0/24 Direct 0 0 D 192.168.20.1 Serial0/0/1
192.168.20.1/32 Direct 0 0 D 127.0.0.1 Serial0/0/1
192.168.20.2/32 Direct 0 0 D 192.168.20.2 Serial0/0/1
192.168.30.0/24 RIP 100 1 D 192.168.20.2 Serial0/0/1
Test Connectivity: At this time, we are able to communicate with R1 router Ping router R4, which means that the configuration is successful.
[R1] ping 192.168.30.2
PING 192.168.30.2: 56 data bytes, press CTRL_C to break
Reply from 192.168.30.2: bytes=56 Sequence=1 ttl=253 time=100 ms
Reply from 192.168.30.2: bytes=56 Sequence=2 ttl=253 time=80 ms
04. OSPF dynamic routing
In the above configuration test, we completed the data communication between a router by using the RIP protocol, but the RIP protocol only supports a maximum of 15 routing nodes, although these nodes are enough in small and medium-sized networks, but in some large enterprises often need more hops, it is because of this demand that our OSPF protocol was born.
OSPF (Open Shortest Path First), this protocol is a protocol specification based on the link state, so it can also be called the link state protocol, the same as the RIP protocol, the OSPF protocol also uses hops to measure the path overhead, but unlike RIP, the OSPF protocol is not limited by the physical hop number, and its path overhead is related to the link overhead in the network.
The OSPF protocol uses the FPS algorithm to calculate the number of shortest paths, the SPF algorithm uses each route as the root to calculate the distance between its packets to each destination router, and each router calculates the topology of the routing domain according to a unified database LSDB, which is very much like a tree, so it is called the shortest path tree.
Advantages of the OSPF protocol:
1. OSPF adopts SPF algorithm, which can well avoid the generation of router loops.
2. Although the OSPF protocol also uses hop count as the unit of measurement, it is not limited by the physical hop number.
3. When the network link status changes, OSPF can quickly capture and apply, with fast convergence and small routing information traffic.
4. OSPF routing protocol supports routing authentication system, and can also define different authentication methods, which improves network security.
5. The OSPF protocol provides better load balancing, and its data update is more intelligent, which reduces the bandwidth of network traffic.
In the following configuration experiment, you will see a network number such as 0.0.0.255, which is called the wildcard mask, usually the wildcard mask can be obtained by subtracting the current 255.255.255.255.0 (subnet mask) from the current 255.255.255.255.0 (subnet mask).
Next, let's get down to business, we still use the same topology of RIP routing and the configuration of IP addresses, but here when configuring dynamic routing, we use OSPF to configure, the process is as follows:
Configure the routers: First, configure the IP addresses of the four routers on the corresponding interfaces according to the figure above.
#----在R1上操作-------------------------
<Huawei> system-view
[Huawei] interface Serial 0/0/0
[Huawei-Serial0/0/0] ip address 192.168.10.1 255.255.255.0
[Huawei-Serial0/0/0] quit
#----在R2上操作-------------------------
<Huawei> system-view
[Huawei] interface Serial 0/0/0
[Huawei-Serial0/0/0] ip address 192.168.10.2 255.255.255.0
[Huawei-Serial0/0/0] quit
[Huawei] interface Serial 0/0/1
[Huawei-Serial0/0/1] ip address 192.168.20.1 255.255.255.0
[Huawei-Serial0/0/1] quit
#----在R3上操作-------------------------
<Huawei> system-view
[Huawei] interface Serial 0/0/0
[Huawei-Serial0/0/0] ip address 192.168.20.2 255.255.255.0
[Huawei-Serial0/0/0] quit
[Huawei] interface Serial 0/0/1
[Huawei-Serial0/0/1] ip address 192.168.30.1 255.255.255.0
[Huawei-Serial0/0/1] quit
#----在R4上操作-------------------------
<Huawei> system-view
[Huawei] interface Serial 0/0/0
[Huawei-Serial0/0/0] ip address 192.168.30.2 255.255.255.0
[Huawei-Serial0/0/0] quit
Configure and enable OSPF routing: Enable and configure OSPF dynamic routing on each router.
#----在R1上启用OSPF路由协议并配置-------------------
[Huawei] ospf 1 // 启用OSPF路由,并设置进程号为1
[Huawei-ospf-1] area 0.0.0.0 // 为R1配置RID编号
[Huawei-ospf-1-area-0.0.0.0]
[Huawei-ospf-1-area-0.0.0.0] network 192.168.10.0 0.0.0.255 // 声明与R1直连的网络号
[Huawei-ospf-1-area-0.0.0.0] quit
#----在R2上启用OSPF路由协议并配置-------------------
[Huawei] ospf 1 // 启用OSPF路由,并设置进程号为1
[Huawei-ospf-1] area 0.0.0.0 // 为R2-R3配置RID编号
[Huawei-ospf-1-area-0.0.0.0]
[Huawei-ospf-1-area-0.0.0.0] network 192.168.10.0 0.0.0.255 // 声明与R2直连的网络号
[Huawei-ospf-1-area-0.0.0.0] network 192.168.20.0 0.0.0.255 // 声明与R3直连的网络号
[Huawei-ospf-1-area-0.0.0.0] quit
#----在R3上启用OSPF路由协议并配置-------------------
[Huawei] ospf 1 // 启用OSPF路由,并设置进程号为1
[Huawei-ospf-1] area 0.0.0.0 // 为R3-R4配置RID编号
[Huawei-ospf-1-area-0.0.0.0]
[Huawei-ospf-1-area-0.0.0.0] network 192.168.20.0 0.0.0.255 // 声明与R3直连的网络号
[Huawei-ospf-1-area-0.0.0.0] network 192.168.30.0 0.0.0.255 // 声明与R4直连的网络号
[Huawei-ospf-1-area-0.0.0.0] quit
#----在R4上启用OSPF路由协议并配置-------------------
[Huawei] ospf 1 // 启用OSPF路由,并设置进程号为1
[Huawei-ospf-1] area 0.0.0.0 // 为R1配置RID编号
[Huawei-ospf-1-area-0.0.0.0]
[Huawei-ospf-1-area-0.0.0.0] network 192.168.30.0 0.0.0.255 // 声明与R4直连的网络号
[Huawei-ospf-1-area-0.0.0.0] quit
Check the configuration information: After the configuration is complete, RIP will automatically generate route entries, and you can run the display ip routing-table to query the configuration result.
[Huawei] display ip routing-table
------------------------------------------------------------------------------
Destination/Mask Proto Pre Cost Flags NextHop Interface
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.10.0/24 Direct 0 0 D 192.168.10.2 Serial0/0/0
192.168.10.1/32 Direct 0 0 D 192.168.10.1 Serial0/0/0
192.168.10.2/32 Direct 0 0 D 127.0.0.1 Serial0/0/0
192.168.20.0/24 Direct 0 0 D 192.168.20.1 Serial0/0/1
192.168.20.1/32 Direct 0 0 D 127.0.0.1 Serial0/0/1
192.168.20.2/32 Direct 0 0 D 192.168.20.2 Serial0/0/1
192.168.30.0/24 OSPF 10 3124 D 192.168.20.2 Serial0/0/1
Test Connectivity: At this time, we are able to communicate with R1 router Ping router R4, which means that the configuration is successful.
[R1] ping 192.168.30.2
PING 192.168.30.2: 56 data bytes, press CTRL_C to break
Reply from 192.168.30.2: bytes=56 Sequence=1 ttl=253 time=100 ms
Reply from 192.168.30.2: bytes=56 Sequence=2 ttl=253 time=80 ms
Pay attention to the best of the industry: IT operation and maintenance base camp, and get 60 G of "Network Engineering System Gift Package" + 1000 pages of Linux learning notes
Reprint: https://www.cnblogs.com/LyShark/p/11152943.html
If you plan to study and study the certificate, consult customer service