1.全网可达
分别给r1 r2 r3 r4 r5配置ip地址,通过ping检验直连是否通
[r1]interface g0/0/1
[r1-GigabitEthernet0/0/1]ip ad
[r1-GigabitEthernet0/0/1]ip address 12.1.1.1 24
[r2]interface g0/0/0
[r2-GigabitEthernet0/0/0]ip ad
[r2-GigabitEthernet0/0/0]ip address 12.1.1.2 24
[r2]interface g0/0/1
[r2-GigabitEthernet0/0/1]ip ad
[r2-GigabitEthernet0/0/1]ip address 23.1.1.1 24
[r2]interface g0/0/2
[r2-GigabitEthernet0/0/2]ip ad
[r2-GigabitEthernet0/0/2]ip address 32.1.1.1 24
[r3]interface g0/0/0
[r3-GigabitEthernet0/0/0]ip ad
[r3-GigabitEthernet0/0/0]ip address 23.1.1.2 24
[r3]interface g0/0/1
[r3-GigabitEthernet0/0/1]ip ad
[r3-GigabitEthernet0/0/1]ip address 32.1.1.2 24
[r4]interface g0/0/0
[r4-GigabitEthernet0/0/0]ip ad
[r4-GigabitEthernet0/0/0]ip address 34.1.1.2 24
[r4]interface g0/0/2
[r4-GigabitEthernet0/0/2]ip ad
[r4-GigabitEthernet0/0/2]ip address 46.1.1.1 24
下一跳写法实现全网可达,并用display ip routing-table检验
[r1]ip route-static 23.1.1.0 24 12.1.1.2
[r1]ip route-static 34.1.1.0 24 12.1.1.2
[r1]ip route-static 46.1.1.0 24 12.1.1.2
[r1]ip route-static 32.1.1.0 24 12.1.1.2
[r1]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 14 Routes : 14
Destination/Mask Proto Pre Cost Flags NextHop Interface
12.1.1.0/24 Direct 0 0 D 12.1.1.1 GigabitEthernet
0/0/1
12.1.1.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
12.1.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
23.1.1.0/24 Static 60 0 RD 12.1.1.2 GigabitEthernet
0/0/1
32.1.1.0/24 Static 60 0 RD 12.1.1.2 GigabitEthernet
0/0/1
34.1.1.0/24 Static 60 0 RD 12.1.1.2 GigabitEthernet
0/0/1
46.1.1.0/24 Static 60 0 RD 12.1.1.2 GigabitEthernet
0/0/1
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
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
172.16.1.0/24 Direct 0 0 D 172.16.1.1 GigabitEthernet
0/0/0
172.16.1.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
172.16.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
[r5]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 18 Routes : 18
Destination/Mask Proto Pre Cost Flags NextHop Interface
12.1.1.0/24 Static 60 0 RD 46.1.1.1 GigabitEthernet
0/0/0
23.1.1.0/24 Static 60 0 RD 46.1.1.1 GigabitEthernet
0/0/0
32.1.1.0/24 Static 60 0 RD 46.1.1.1 GigabitEthernet
0/0/0
34.1.1.0/24 Static 60 0 RD 46.1.1.1 GigabitEthernet
0/0/0
46.1.1.0/24 Direct 0 0 D 46.1.1.2 GigabitEthernet
0/0/0
46.1.1.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
46.1.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/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
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
2.pc1和pc2获取指定ip地址
分别给pc1 pc2配置好指定地址后,在pc1,2上选dhcp应用,再在
命令行ipconfig进行检验
<Huawei>sy
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sy
[Huawei]sysname dhcp
[dhcp]in
[dhcp]info-center
[dhcp]interface g0/0/0
[dhcp-GigabitEthernet0/0/0]ip ad
[dhcp-GigabitEthernet0/0/0]ip address 172.16.1.1 24
Nov 13 2022 23:28:06-08:00 dhcp %%01IFNET/4/LINK_STATE(l)[0]:The line protocol I
P on the interface GigabitEthernet0/0/0 has entered the UP state.
[dhcp-GigabitEthernet0/0/0]qu
[dhcp-GigabitEthernet0/0/0]quit
[dhcp]dhcp en
[dhcp]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[dhcp]ip poo
[dhcp]ip pool 1
Info: It's successful to create an IP address pool.
[dhcp-ip-pool-1]net
[dhcp-ip-pool-1]netbios-type
[dhcp-ip-pool-1]network 172.16.1.0 m
[dhcp-ip-pool-1]network 172.16.1.0 mask 24
[dhcp-ip-pool-1]ga
[dhcp-ip-pool-1]gateway-list 172.16.1.1
[dhcp-ip-pool-1]dns
[dhcp-ip-pool-1]dns-list 8.8.8.8 114.114.114.114
[dhcp-ip-pool-1]st
[dhcp-ip-pool-1]static-bind ip
[dhcp-ip-pool-1]static-bind ip-address 172.16.1.11 ma
[dhcp-ip-pool-1]static-bind ip-address 172.16.1.11 mac-address 5489-9817-0CD5
[dhcp-ip-pool-1]st
[dhcp-ip-pool-1]static-bind ip
[dhcp-ip-pool-1]static-bind ip-address 172.16.1.13 ma
[dhcp-ip-pool-1]static-bind ip-address 172.16.1.13 mac-address 5489-9877-178B
[dhcp-ip-pool-1]qui
[dhcp-ip-pool-1]quit
[dhcp]in
[dhcp]info-center
[dhcp]interface g0/0/0
[dhcp-GigabitEthernet0/0/0]dhcp se
[dhcp-GigabitEthernet0/0/0]dhcp select g
[dhcp-GigabitEthernet0/0/0]dhcp select global
[dhcp-GigabitEthernet0/0/0]
PC>ipconfig
Link local IPv6 address...........: fe80::5689:98ff:fe17:cd5
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 172.16.1.11
Subnet mask.......................: 255.255.255.0
Gateway...........................: 172.16.1.1
Physical address..................: 54-89-98-17-0C-D5
DNS server........................: 8.8.8.8
114.114.114.114
PC>ipconfig
Link local IPv6 address...........: fe80::5689:98ff:fe77:178b
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 172.16.1.13
Subnet mask.......................: 255.255.255.0
Gateway...........................: 172.16.1.1
Physical address..................: 54-89-98-77-17-8B
DNS server........................: 8.8.8.8
114.114.114.114
3.pc3和pc4不能获取250-254的地址
给pc3 pc4分配好地址后,用excluded-ip-address+不能获取的地址排除250-254,dhcp应用,再在
命令行ipconfig进行检验
[dhcp]dhcp en
[dhcp]dhcp enable
[dhcp]ip po
[dhcp]ip policy-based-route
[dhcp]ip pool 1
[dhcp-ip-pool-1]excluded-ip-address 192.168.1.250 192.168.1.254
[dhcp-ip-pool-1]excluded-ip
[dhcp-ip-pool-1]qu
[dhcp-ip-pool-1]quit
[dhcp]in
[dhcp]info-center
[dhcp]interface g0/0/1
[dhcp-GigabitEthernet0/0/1]dhcp se
[dhcp-GigabitEthernet0/0/1]dhcp select g
[dhcp-GigabitEthernet0/0/1]dhcp select global
PC>ipconfig
Link local IPv6 address...........: fe80::5689:98ff:fe31:6527
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.1.248
Subnet mask.......................: 255.255.255.0
Gateway...........................: 192.168.1.1
Physical address..................: 54-89-98-31-65-27
DNS server........................: 8.8.8.8
114.114.114.114
PC>ipconfig
Link local IPv6 address...........: fe80::5689:98ff:fe38:6474
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.1.249
Subnet mask.......................: 255.255.255.0
Gateway...........................: 192.168.1.1
Physical address..................: 54-89-98-38-64-74
DNS server........................: 8.8.8.8
114.114.114.114
4.32.1.1.0/24为备份路径
浮动静态路由,值越小越优
[r2]ip r
[r2]ip rd-filter
[r2]ip relay
[r2]ip route
[r2]ip route-static 34.1.1.0 24 23.1.1.2 pr
[r2]ip route-static 34.1.1.0 24 23.1.1.2 preference 61
Info: Succeeded in modifying route.
[r2]dis
[r2]display ip r
[r2]display ip rd-filter
[r2]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 14 Routes : 14
Destination/Mask Proto Pre Cost Flags NextHop Interface
12.1.1.0/24 Direct 0 0 D 12.1.1.2 GigabitEthernet
0/0/0
12.1.1.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
12.1.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
23.1.1.0/24 Direct 0 0 D 23.1.1.1 GigabitEthernet
0/0/1
23.1.1.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
23.1.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
32.1.1.0/24 Direct 0 0 D 32.1.1.1 GigabitEthernet
0/0/2
32.1.1.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/2
32.1.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/2
34.1.1.0/24 Static 60 0 RD 32.1.1.2 GigabitEthernet
0/0/2
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
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
5.尽量减少路由条目pc1访问pc3456时使用汇总路由
[r5]ip r
[r5]ip rd-filter
[r5]ip relay
[r5]ip route
[r5]ip route-static 192.168.0.0 22 192.168.1.2
[r5]dis
[r5]display ip r
[r5]display ip rd-filter
[r5]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 18 Routes : 18
Destination/Mask Proto Pre Cost Flags NextHop Interface
12.1.1.0/24 Static 60 0 RD 46.1.1.1 GigabitEthernet
0/0/0
23.1.1.0/24 Static 60 0 RD 46.1.1.1 GigabitEthernet
0/0/0
32.1.1.0/24 Static 60 0 RD 46.1.1.1 GigabitEthernet
0/0/0
34.1.1.0/24 Static 60 0 RD 46.1.1.1 GigabitEthernet
0/0/0
46.1.1.0/24 Direct 0 0 D 46.1.1.2 GigabitEthernet
0/0/0
46.1.1.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
46.1.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/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
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.0.0/22 Static 60 0 RD 192.168.1.2 GigabitEthernet
0/0/1
192.168.1.0/24 Direct 0 0 D 192.168.1.1 GigabitEthernet
0/0/1
192.168.1.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
192.168.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
192.168.2.0/24 Direct 0 0 D 192.168.2.1 GigabitEthernet
0/0/2
192.168.2.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/2
192.168.2.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/2
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
[r5]ip r
[r5]ip rd-filter
[r5]ip relay
[r5]ip route
[r5]ip route-static 192.168.0.0 22 192.168.1.2
[r5]dis
[r5]display ip r
[r5]display ip rd-filter
[r5]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 18 Routes : 18
Destination/Mask Proto Pre Cost Flags NextHop Interface
12.1.1.0/24 Static 60 0 RD 46.1.1.1 GigabitEthernet
0/0/0
23.1.1.0/24 Static 60 0 RD 46.1.1.1 GigabitEthernet
0/0/0
32.1.1.0/24 Static 60 0 RD 46.1.1.1 GigabitEthernet
0/0/0
34.1.1.0/24 Static 60 0 RD 46.1.1.1 GigabitEthernet
0/0/0
46.1.1.0/24 Direct 0 0 D 46.1.1.2 GigabitEthernet
0/0/0
46.1.1.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
46.1.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/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
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.0.0/22 Static 60 0 RD 192.168.1.2 GigabitEthernet
0/0/1
192.168.1.0/24 Direct 0 0 D 192.168.1.1 GigabitEthernet
0/0/1
192.168.1.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
192.168.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
192.168.2.0/24 Direct 0 0 D 192.168.2.1 GigabitEthernet
0/0/2
192.168.2.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/2
192.168.2.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/2
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0