要求
拓扑
首先从二层交换开始配置
SW1
[SW1]vlan batch 2 3
[SW1]interface GigabitEthernet 0/0/2
[SW1-GigabitEthernet0/0/2]port link-type access 与PC相连的是access链路
[SW1-GigabitEthernet0/0/2]port default vlan 2
[SW1]interface GigabitEthernet 0/0/3
[SW1-GigabitEthernet0/0/3]port link-type access 与PC相连的是access链路
[SW1-GigabitEthernet0/0/3]port default vlan 3
[SW1]interface GigabitEthernet 0/0/1
[SW1-GigabitEthernet0/0/1]port link-type trunk
[SW1-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 to 3
[SW1]interface GigabitEthernet 0/0/4
[SW1-GigabitEthernet0/0/4]port link-type trunk TRUNK类型的链路接口划分VLAN
[SW1-GigabitEthernet0/0/4]port trunk allow-pass vlan 2 to 3
SW2
[SW2]vlan batch 2 3
[SW2]interface GigabitEthernet 0/0/2
[SW2-GigabitEthernet0/0/2]port link-type access 与PC相连的是access链路
[SW2-GigabitEthernet0/0/2]port default vlan 2
[SW2]interface GigabitEthernet 0/0/3
[SW2-GigabitEthernet0/0/3]port link-type access 与PC相连的是access链路
[SW2-GigabitEthernet0/0/3]port default vlan 3
[SW2]interface GigabitEthernet 0/0/1
[SW2-GigabitEthernet0/0/1]port link-type trunk TRUNK类型的链路接口划分VLAN
[SW2-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 to 3
配置R4接口IP
[R4]interface GigabitEthernet0/0/2.1
[R4-GigabitEthernet0/0/2.1]dot1q termination vid 2 让路由器的子接口服务某个VLAN
[R4-GigabitEthernet0/0/2.1]arp broadcast enable 开启ARP广播
[R4]interface GigabitEthernet0/0/2.2
[R4-GigabitEthernet0/0/2.2]dot1q termination vid 3 让路由器的子接口服务某个VLAN
[R4-GigabitEthernet0/0/2.2]arp broadcast enable 开启ARP广播
R4配置DHCP
[R4]dhcp enable
[R4]ip pool 1
[R4-ip-pool-1]network 192.168.0.128 mask 29
[R4-ip-pool-1]gateway-list 192.168.0.129
[R4-ip-pool-1]dns-list 114.114.114.114
[R4]interface GigabitEthernet 0/0/2.1
[R4-GigabitEthernet0/0/2.1]dhcp select global
[R4]dhcp enable
[R4]ip pool 2
[R4-ip-pool-2]network 192.168.0.192 mask 29
[R4-ip-pool-2]gateway-list 192.168.0.193
[R4-ip-pool-2]dns-list 114.114.114.114
[R4]interface GigabitEthernet 0/0/2.2
[R4-GigabitEthernet0/0/2.2]dhcp select global
查看PC1 PC2 PC3 PC4 的IP 地址
PC1
PC2
PC3
PC4
PC1 ping PC2
PC3 ping PC4
二层配置完毕!
配置三层路由器
配置接口IP
R1
R2
R3
R4
R5
ISP
配置静态路由
R1
[R1]ip route-static 192.168.0.64 27 192.168.0.6
[R1]ip route-static 192.168.0.12 30 192.168.0.6
[R1]ip route-static 192.168.0.128 29 192.168.0.6
[R1]ip route-static 192.168.0.192 29 192.168.0.6
[R1]ip route-static 192.168.0.16 30 192.168.0.6 preference 61 100m通讯改变优先级(默认60)
[R1]ip route-static 192.168.0.20 30 192.168.0.6
[R1]ip route-static 192.168.0.8 30 192.168.0.2
[R1]ip route-static 192.168.0.16 30 192.168.0.2 preference 61
[R1]ip route-static 192.168.0.20 30 192.168.0.2
[R1]ip route-static 0.0.0.0 0 192.168.0.2 缺省路由
[R1]ip route-static 0.0.0.0 0 192.168.0.6 缺省路由
[R1]ip route-static 192.168.0.32 29 NULL 0 空接口
R2
[R2]ip route-static 192.168.0.32 29 192.168.0.1
[R2]ip route-static 192.168.0.96 29 192.168.0.1
[R2]ip route-static 192.168.0.160 29 192.168.0.1
[R2]ip route-static 192.168.0.4 30 192.168.0.1
[R2]ip route-static 192.168.0.64 27 192.168.0.1
[R2]ip route-static 192.168.0.128 29 192.168.0.1
[R2]ip route-static 192.168.0.192 29 192.168.0.1
[R2]ip route-static 192.168.0.12 30 192.168.0.10
[R2]ip route-static 192.168.0.16 30 192.168.0.10 preference 61
[R2]ip route-static 192.168.0.20 30 192.168.0.10
[R2]ip route-static 192.168.0.64 27 192.168.0.10
[R2]ip route-static 192.168.0.128 29 192.168.0.10
[R2]ip route-static 192.168.0.192 29 192.168.0.10
[R2]ip route-static 0.0.0.0 0 192.168.0.1
[R2]ip route-static 0.0.0.0 0 192.168.0.10
[R2]ip route-static 0.0.0.0 0 NULL 0
R3
[R3]ip route-static 192.168.0.32 29 192.168.0.9
[R3]ip route-static 192.168.0.96 29 192.168.0.9
[R3]ip route-static 192.168.0.160 29 192.168.0.9
[R3]ip route-static 192.168.0.32 29 192.168.0.13
[R3]ip route-static 192.168.0.96 29 192.168.0.13
[R3]ip route-static 192.168.0.160 29 192.168.0.13
[R3]ip route-static 192.168.0.4 30 192.168.0.13
[R3]ip route-static 192.168.0.64 27 192.168.0.13
[R3]ip route-static 192.168.0.128 29 192.168.0.13
[R3]ip route-static 192.168.0.192 29 192.168.0.13
[R3]ip route-static 192.168.0.0 30 192.168.0.9
[R3]ip route-static 0.0.0.0 0 192.168.0.9
[R3]ip route-static 0.0.0.0 0 192.168.0.13
R4
[R4]ip route-static 192.168.0.32 29 192.168.0.5
[R4]ip route-static 192.168.0.96 29 192.168.0.5
[R4]ip route-static 192.168.0.160 29 192.168.0.5
[R4]ip route-static 192.168.0.0 30 192.168.0.5
[R4]ip route-static 192.168.0.8 30 192.168.0.14
[R4]ip route-static 192.168.0.16 30 192.168.0.14 preference 61
[R4]ip route-static 192.168.0.20 30 192.168.0.14
[R4]ip route-static 0.0.0.0 0 192.168.0.5
[R4]ip route-static 0.0.0.0 0 192.168.0.14
R5
[R5]ip route-static 192.168.0.8 30 192.168.0.17 preference 61
[R5]ip route-static 192.168.0.12 30 192.168.0.17 preference 61
[R5]ip route-static 192.168.0.0 30 192.168.0.17 preference 61
[R5]ip route-static 192.168.0.4 30 192.168.0.17 preference 61
[R5]ip route-static 192.168.0.32 29 192.168.0.17 preference 61
[R5]ip route-static 192.168.0.96 29 192.168.0.17 preference 61
[R5]ip route-static 192.168.0.160 29 192.168.0.17 preference 61
[R5]ip route-static 192.168.0.128 29 192.168.0.17 preference 61
[R5]ip route-static 192.168.0.192 29 192.168.0.17 preference 61
[R5]ip route-static 192.168.0.64 27 192.168.0.17 preference 61
[R5]ip route-static 192.168.0.8 30 192.168.0.21
[R5]ip route-static 192.168.0.12 30 192.168.0.21
[R5]ip route-static 192.168.0.0 30 192.168.0.21
[R5]ip route-static 192.168.0.4 30 192.168.0.21
[R5]ip route-static 192.168.0.32 29 192.168.0.21
[R5]ip route-static 192.168.0.96 29 192.168.0.21
[R5]ip route-static 192.168.0.160 29 192.168.0.21
[R5]ip route-static 192.168.0.128 29 192.168.0.21
[R5]ip route-static 192.168.0.192 29 192.168.0.21
[R5]ip route-static 192.168.0.64 27 192.168.0.21
[R5]ip route-static 0.0.0.0 0 192.168.0.17 preference 61
[R5]ip route-static 0.0.0.0 0 192.168.0.21
[R5]ip route-static 0.0.0.0 0 192.168.0.26
创建NAT
[R5]nat address-group 0 100.1.1.1 100.1.1.2 创建nat地址池
[R5]acl 2000 创建ACL
[R5-acl-basic-2000]rule permit source 192.168.0.0 0.0.0.255 抓取流量
[R5]interface GigabitEthernet 0/0/1
[R5-GigabitEthernet0/0/1]nat outbound 2000 address-group 0 no-pat 接口调用
ISP不做配置
配置完成
R1 ping ISP
PC1 ping ISP
PC4 ping ISP
全网可达!!!