R1
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]ip add 192.168.1.1 30
[r1-GigabitEthernet0/0/0]int g0/0/1
[r1-GigabitEthernet0/0/1]ip add 192.168.1.22 30
R2
[r2]INT G0/0/0
[r2-GigabitEthernet0/0/0]ip add 192.168.1.1 30
[r2-GigabitEthernet0/0/0]int g0/0/1
[r2-GigabitEthernet0/0/1]ip add 192.168.1.5 30
R3
[r3]int g0/0/1
[r3-GigabitEthernet0/0/1]ip add 192.168.1.18 30
[r3-GigabitEthernet0/0/1]int g0/0/0
[r3-GigabitEthernet0/0/0]ip add 192.168.1.21 30
R4
[r4]int g0/0/0
[r4-GigabitEthernet0/0/0]ip add 192.168.1.6 30
[r4-GigabitEthernet0/0/0]int g0/0/2
[r4-GigabitEthernet0/0/2]ip add 192.168.1.9 30
[r4-GigabitEthernet0/0/2]int g0/0/3
[r4-GigabitEthernet0/0/3]ip add 192.168.1.14 30
[r4-GigabitEthernet0/0/3]int g0/0/1
[r4-GigabitEthernet0/0/1]ip add 192.168.1.17 30
R5
[r5]int g0/0/0
[r5-GigabitEthernet0/0/0]ip add 192.168.1.10 30
[r5-GigabitEthernet0/0/0]int g0/0/2
[r5-GigabitEthernet0/0/2]ip add 192.168.1.13 30
[r5-GigabitEthernet0/0/2]int g0/0/1
[r5-GigabitEthernet0/0/1]ip add 12.1.1.1 24
R6
[r6]int g0/0/0
[r6-GigabitEthernet0/0/0]ip add 12.0.0.2 24
[r6-GigabitEthernet0/0/0]int loopback0
[r6-LoopBack0]ip add 1.1.1.1 24
R3下的两台PC通过DHCP自动获取IP地址
先创建VLAN,然后划分到 2 台PC上
[Huawei]vlan batch 2 3
[Huawei]int g0/0/2
[Huawei-GigabitEthernet0/0/2]port link-type access
[Huawei-GigabitEthernet0/0/2]port default vlan 2
[Huawei-GigabitEthernet0/0/2]q
[Huawei]int g0/0/3
[Huawei-GigabitEthernet0/0/3]port link-type access
[Huawei-GigabitEthernet0/0/3]port default vlan 3
在R3上
[r3]int g0/0/2.1
[r3-GigabitEthernet0/0/2.1]ip add 192.168.1.161 28
[r3-GigabitEthernet0/0/2.1]dot1q termination vid 2
[r3-GigabitEthernet0/0/2.1]arp broadcast enable
[r3-GigabitEthernet0/0/2.1]q
[r3]int g0/0/2.2
[r3-GigabitEthernet0/0/2.2]ip add 192.168.1.177 28
[r3-GigabitEthernet0/0/2.2]dot1q termination vid 3
[r3-GigabitEthernet0/0/2.2]arp broadcast enable
[r3]ip pool class_A
Info:It's successful to create an IP address pool.
[r3-ip-pool-class_A]network 192.168.1.160 mask 28
[r3-ip-pool-class_A]gateway-list 192.168.1.161
[r3-ip-pool-class_A]dns-list 8.8.8.8
[r3-ip-pool-class_A]q
[r3]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[r3]int g0/0/2.1
[r3-GigabitEthernet0/0/2.1]dhcp select global
[r3-GigabitEthernet0/0/2.1]q
[r3]ip pool class_B
Info:It's successful to create an IP address pool.
[r3-ip-pool-class_B]dns-list 8.8.8.8network 192.168.1.76
[r3-ip-pool-class_B]dns-list 8.8.8.8gateway-list 192.168.1.177
[r3-ip-pool-class_B]dns-list 8.8.8.8
[r3]int g0/0/2.2
[r3-GigabitEthernet0/0/2.2]dhcp select global
[Huawei]int g0/0/1
[Huawei-GigabitEthernet0/0/1]port link-type trunk
[Huawei-GigabitEthernet0/0/1]port trunk allow-pass vlan all
pc端结果显示:
静态路由的配置:
R1
[r1]ip route-static 192.168.1.64 27 192.168.1.2
[r1]ip route-static 192.168.1.96 27 192.168.1.2
[r1]ip route-static 192.168.1.128 27 192.168.1.2
[r1]ip route-static 192.168.1.128 27 192.168.1.21
[r1]ip route-static 192.168.1.160 27 192.168.1.21
[r1]ip route-static 192.168.1.4 30 192.168.1.2
[r1]ip route-static 192.168.1.8 30 192.168.1.2
[r1]ip route-static 192.168.1.12 30 192.168.1.21
[r1]ip route-static 192.168.1.16 30 192.168.1.21
R2
[r2]ip route-static 192.168.1.32 27 192.168.1.1
[r2]ip route-static 192.168.1.96 27 192.168.1.6
[r2]ip route-static 192.168.1.128 27 192.168.1.6
[r2]ip route-static 192.168.1.160 27 192.168.1.1
[r2]ip route-static 192.168.1.8 30 192.168.1.6
[r2]ip route-static 192.168.1.12 30 192.168.1.6
[r2]ip route-static 192.168.1.16 30 192.168.1.6
[r2]ip route-static 192.168.1.20 30 192.168.1.1
R3
[r3]ip route-static 192.168.1.32 27 192.168.1.22
[r3]ip route-static 192.168.1.64 27 192.168.1.22
[r3]ip route-static 192.168.1.64 27 192.168.1.17
[r3]ip route-static 192.168.1.96 27 192.168.1.17
[r3]ip route-static 192.168.1.128 27 192.168.1.17
[r3]ip route-static 192.168.1.0 30 192.168.1.22
[r3]ip route-static 192.168.1.4 30 192.168.1.17
[r3]ip route-static 192.168.1.8 30 192.168.1.17
[r3]ip route-static 192.168.1.12 30 192.168.1.17
R4
[r4]ip route-static 192.168.1.32 27 192.168.1.5
[r4]ip route-static 192.168.1.32 27 192.168.1.18
[r4]ip route-static 192.168.1.64 27 192.168.1.5
[r4]ip route-static 192.168.1.128 27 192.168.1.10
[r4]ip route-static 192.168.1.128 27 192.168.1.13
[r4]ip route-static 192.168.1.160 27 192.168.1.18
[r4]ip route-static 192.168.1.0 30 192.168.1.5
[r4]ip route-static 192.168.1.20 30 192.168.1.18
R5
[r5]ip route-static 192.168.1.32 27 192.168.1.9
[r5]ip route-static 192.168.1.32 27 192.168.1.14
[r5]ip route-static 192.168.1.64 27 192.168.1.9
[r5]ip route-static 192.168.1.96 27 192.168.1.9
[r5]ip route-static 192.168.1.96 27 192.168.1.14
[r5]ip route-static 192.168.1.160 27 192.168.1.14
[r5]ip route-static 192.168.1.0 30 192.168.1.9
[r5]ip route-static 192.168.1.0 30 192.168.1.14
[r5]ip route-static 192.168.1.4 30 192.168.1.14
[r5]ip route-static 192.168.1.4 30 192.168.1.9
[r5]ip route-static 192.168.1.16 30 192.168.1.14
[r5]ip route-static 192.168.1.20 30 192.168.1.14
ping通
ping R5失败
设置缺省使得R1-R5可访R6
[r1]ip route-static 0.0.0.0 0 192.168.1.2
[r1]ip route-static 0.0.0.0 0 192.168.1.21
[r2]ip route-static 0.0.0.0 0 192.168.1.6
[r3]ip route-static 0.0.0.0 0 192.168.1.17
[r4]ip route-static 0.0.0.0 0 192.168.1.10
[r4]ip route-static 0.0.0.0 0 192.168.1.13