一、搭建实验拓扑
二、规划IP
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 192.168.0.17/28 up up
GigabitEthernet0/0/1 192.168.0.98/28 up up
GigabitEthernet0/0/2 unassigned down down
LoopBack0 192.168.0.1/30 up up(s)
LoopBack1 192.168.0.5/30 up up(s)
LoopBack2 192.168.0.9/30 up up(s)
NULL0 unassigned up up(s)
[R1-GigabitEthernet0/0/1]
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 192.168.0.18/28 up up
GigabitEthernet0/0/1 192.168.0.33/28 up up
GigabitEthernet0/0/2 unassigned down down
NULL0 unassigned up up(s)
<R2>
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 192.168.0.34/28 up up
GigabitEthernet0/0/1 192.168.0.81/28 up up
GigabitEthernet0/0/2 192.168.0.49/28 up up
GigabitEthernet4/0/0 192.168.0.66/28 up up
GigabitEthernet4/0/1 unassigned down down
GigabitEthernet4/0/2 unassigned down down
GigabitEthernet4/0/3 unassigned down down
NULL0 unassigned up up(s)
<R3>
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 192.168.0.82/28 up up
GigabitEthernet0/0/1 192.168.0.97/28 up up
GigabitEthernet0/0/2 unassigned up down
GigabitEthernet0/0/2.1 192.168.0.113/28 up up
GigabitEthernet0/0/2.2 192.168.0.129/28 up up
NULL0 unassigned up up(s)
[R4]
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 192.168.0.50/28 up up
GigabitEthernet0/0/1 192.168.0.65/28 up up
GigabitEthernet0/0/2 unassigned up down
NULL0 unassigned up up(s)
<R5>
[R5]interface g0/0/2
[R5-GigabitEthernet0/0/2]ip add 100.1.1.1 24
[ISP]int g0/0/0
[ISP-GigabitEthernet0/0/0]ip add 100.1.1.2 24
三、划分VLAN
[R4-GigabitEthernet0/0/1]int g0/0/2.1
[R4-GigabitEthernet0/0/2.1]dot1q termination vid 2
[R4-GigabitEthernet0/0/2.1]ip add 192.168.0.113 28
Jul 18 2022 12:33:48-08:00 R4 %%01IFNET/4/LINK_STATE(l)[2]:The line protocol IP on the interface GigabitEthernet0/0/2.1 has entered the UP state.
[R4-GigabitEthernet0/0/2.1]arp broadcast enable
[R4-GigabitEthernet0/0/2.1]q
[R4]int g0/0/2.2
[R4-GigabitEthernet0/0/2.2]dot1q termination vid 3
[R4-GigabitEthernet0/0/2.2]ip add 192.168.0.129 28
[R4-GigabitEthernet0/0/2.2]arp broadcast enable
四、DHCP
[R4]ip pool xixi
Info: It's successful to create an IP address pool.
[R4-ip-pool-xixi]network 192.168.0.112 mask 255.255.255.24
[R4-ip-pool-xixi]gateway-list 192.168.0.113
[R4-ip-pool-xixi]dns-list 8.8.8.8
[R4-ip-pool-xixi]ip pool haha
Info: It's successful to create an IP address pool.
[R4-ip-pool-haha]network 192.168.0.128 mask 255.255.255.240
[R4-ip-pool-haha]gateway-list 192.168.0.129
[R4-ip-pool-haha]dns-list 8.8.8.8
[R4]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[R4]int g0/0/2.1
[R4-GigabitEthernet0/0/2.1]dhcp select global
[R4-GigabitEthernet0/0/2.1]q
[R4]int g0/0/2.2
[R4-GigabitEthernet0/0/2.2]dhcp select global
[R4-GigabitEthernet0/0/2.2]q
五、VLAN配置
[SW1]vlan batch 2 3
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW1]int g0/0/4
[SW1-GigabitEthernet0/0/4]port link-type trunk
[SW1-GigabitEthernet0/0/4]port trunk allow-pass vlan all
[SW1-GigabitEthernet0/0/4]int g0/0/3
[SW1-GigabitEthernet0/0/3]port link-type access
[SW1-GigabitEthernet0/0/3]undo port link-type
[SW1-GigabitEthernet0/0/3]port link-type trunk
[SW1-GigabitEthernet0/0/3]port trunk allow-pass vlan all
[SW1-GigabitEthernet0/0/3]int g0/0/1
[SW1-GigabitEthernet0/0/1]port link-type access
[SW1-GigabitEthernet0/0/1]port default vlan 2
[SW1-GigabitEthernet0/0/1]int g0/0/2
[SW1-GigabitEthernet0/0/2]port link-type access
[SW1-GigabitEthernet0/0/2]port default vlan 3
[SW2]vlan batch 2 3
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW2]interface g0/0/3
[SW2-GigabitEthernet0/0/3]port link-type trunk
[SW2-GigabitEthernet0/0/3]port trunk allow-pass vlan all
[SW2-GigabitEthernet0/0/3]int g0/0/1
[SW2-GigabitEthernet0/0/1]port link-type access
[SW2-GigabitEthernet0/0/1]port default vlan 2
[SW2-GigabitEthernet0/0/1]int g0/0/2
[SW2-GigabitEthernet0/0/2]port link-type access
[SW2-GigabitEthernet0/0/2]port default vlan 3
六、PC1-PC4通过DHCP获取IP
七、静态路由
#
ip route-static 192.168.0.32 255.255.255.240 192.168.0.18
ip route-static 192.168.0.48 255.255.255.240 192.168.0.18
ip route-static 192.168.0.64 255.255.255.240 192.168.0.18
ip route-static 192.168.0.80 255.255.255.240 192.168.0.97
ip route-static 192.168.0.112 255.255.255.240 192.168.0.97
ip route-static 192.168.0.128 255.255.255.240 192.168.0.97
#
return
[R1]
[R2]ip route-static 192.168.0.96 255.255.255.240 192.168.0.17
[R2]ip route-static 192.168.0.48 255.255.255.240 192.168.0.34
[R2]ip route-static 192.168.0.64 255.255.255.240 192.168.0.34
[R2]ip route-static 192.168.0.80 255.255.255.240 192.168.0.34
[R2]ip route-static 192.168.0.112 255.255.255.240 192.168.0.34
[R2]ip route-static 192.168.0.128 255.255.255.240 192.168.0.34
[R2]ip route-static 192.168.0.0 28 192.168.0.17
[R2
[R5]ip route-static 192.168.0.96 255.255.255.240 192.168.0.49
[R5]ip route-static 192.168.0.16 255.255.255.240 192.168.0.49
[R5]ip route-static 192.168.0.32 255.255.255.240 192.168.0.49
[R5]ip route-static 192.168.0.80 255.255.255.240 192.168.0.49
[R5]ip route-static 192.168.0.112 255.255.255.240 192.168.0.49
[R5]ip route-static 192.168.0.128 255.255.255.240 192.168.0.49
[R5]
[R5]ip route-static 192.168.0.0 28 192.168.0.49
[R5]
[R3]ip route-static 192.168.0.96 255.255.255.240 192.168.0.82
[R3]ip route-static 192.168.0.16 255.255.255.240 192.168.0.33
[R3]ip route-static 192.168.0.112 255.255.255.240 192.168.0.82
[R3]ip route-static 192.168.0.128 255.255.255.240 192.168.0.82
[R3]
[R3]ip route-static 192.168.0.0 28 192.168.0.33
[R3]ip route-static 192.168.0.0 28 192.168.0.82
[R3]
[R4]ip route-static 192.168.0.16 255.255.255.240 192.168.0.98
[R4]ip route-static 192.168.0.32 255.255.255.240 192.168.0.98
[R4]ip route-static 192.168.0.48 255.255.255.240 192.168.0.81
[R4]ip route-static 192.168.0.64 255.255.255.240 192.168.0.81
[R4]
[R4]ip route-static 192.168.0.0 28 192.168.0.98
[R4]
测试
[R5]ping 192.168.0.1
PING 192.168.0.1: 56 data bytes, press CTRL_C to break
Request time out
Request time out
Reply from 192.168.0.1: bytes=56 Sequence=3 ttl=253 time=40 ms
Reply from 192.168.0.1: bytes=56 Sequence=4 ttl=253 time=20 ms
Reply from 192.168.0.1: bytes=56 Sequence=5 ttl=253 time=40 ms
--- 192.168.0.1 ping statistics ---
5 packet(s) transmitted
3 packet(s) received
40.00% packet loss
round-trip min/avg/max = 20/33/40 ms
[R5]ping 192.168.0.5
PING 192.168.0.5: 56 data bytes, press CTRL_C to break
Reply from 192.168.0.5: bytes=56 Sequence=1 ttl=253 time=40 ms
Reply from 192.168.0.5: bytes=56 Sequence=2 ttl=253 time=30 ms
Reply from 192.168.0.5: bytes=56 Sequence=3 ttl=253 time=20 ms
Reply from 192.168.0.5: bytes=56 Sequence=4 ttl=253 time=30 ms
Reply from 192.168.0.5: bytes=56 Sequence=5 ttl=253 time=40 ms
--- 192.168.0.5 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/32/40 ms
[R5]ping 192.168.0.9
PING 192.168.0.9: 56 data bytes, press CTRL_C to break
Reply from 192.168.0.9: bytes=56 Sequence=1 ttl=253 time=40 ms
Reply from 192.168.0.9: bytes=56 Sequence=2 ttl=253 time=20 ms
Reply from 192.168.0.9: bytes=56 Sequence=3 ttl=253 time=30 ms
Reply from 192.168.0.9: bytes=56 Sequence=4 ttl=253 time=30 ms
Reply from 192.168.0.9: bytes=56 Sequence=5 ttl=253 time=30 ms
--- 192.168.0.9 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/30/40 ms
[R5]
八、空接口,防环
[R1]ip route-static 192.168.0.0 28 NULL 0
[R1]
九、缺省路由
[R1]ip route-static 0.0.0.0 0 192.168.0.18
[R1]ip route-static 0.0.0.0 0 192.168.0.97
[R1]
[R2]ip route-static 0.0.0.0 0 192.168.0.34
[R2]
[R4]ip route-static 0.0.0.0 0 192.168.0.81
[R4]
十、修改优先级
[R3]ip route-static 0.0.0.0 0 192.168.0.50 preference 80
[R3]
[R3]ip route-static 0.0.0.0 0 192.168.0.65
测试
[R5]ip route-static 0.0.0.0 0 100.1.1.2
[R5]
十一、ACL
[R5]acl 2000
[R5-acl-basic-2000]rule 1 permit source any
[R5-acl-basic-2000]int g0/0/2
[R5-GigabitEthernet0/0/2]nat outbound 2000
[R5-GigabitEthernet0/0/2]