文章目录
题目:
一题目分析
1.地址规划
左边的vlan2和vlan3基于192.168.1.0/24划分
右边的vlan2和vlan3基于192.168.2.0/24划分,这样以便于汇总写路由
二. 实验步骤
1.拓扑搭建
2.创建vlan接口划分
[sw1]vlan 2
[sw1-vlan2]port GigabitEthernet 1/0/2 (注意接口是1/0/2而不是显示的0/2)
[sw1]vlan 3
[sw1-vlan3]port GigabitEthernet 1/0/3
[sw2]vlan 2
[sw2-vlan2]port g1/0/2
[sw2-vlan2]port g1/0/3
[sw2-vlan2]quit
[sw2]vlan 3
[sw2-vlan3]port g1/0/4
[sw2-vlan3]port g1/0/5
[sw3]vlan 2
[sw3-vlan2]port g1/0/1
[sw3-vlan2]quit
[sw3]vlan 3
[sw3-vlan3]port g1/0/2
3.trunk干道
[sw1]int g1/0/1
[sw1-GigabitEthernet1/0/1]port link-type trunk
[sw1-GigabitEthernet1/0/1]port trunk permit vlan 2 to 3
[sw2]int g1/0/6
[sw2-GigabitEthernet1/0/6]port link-type trunk
[sw2-GigabitEthernet1/0/6]port trunk permit vlan 2 to 3
[sw2-GigabitEthernet1/0/6]int g1/0/1
[sw2-GigabitEthernet1/0/1]port link-type trunk
[sw2-GigabitEthernet1/0/1]port trunk permit vlan 2 to 3
[sw3]int g1/0/3
[sw3-GigabitEthernet1/0/3]port link-type trunk
[sw3-GigabitEthernet1/0/3]port trunk permit vlan 2 to 3
4.vlan间路由(路由器上的子接口)
(1)配置接口地址
[r1]int g 0/0
[r1-GigabitEthernet0/0]ip ad 192.168.0.1 30
[r2]int g0/1
[r2-GigabitEthernet0/1]ip ad 192.168.0.2 30
(2)创建子接口
[r1]int g0/1.1
[r1-GigabitEthernet0/1.1]vlan-type dot1q vid 2
[r1-GigabitEthernet0/1.1]ip ad 192.168.1.1 25
[r1]int g0/1.2
[r1-GigabitEthernet0/1.2]vlan-type dot1q vid 3
[r1-GigabitEthernet0/1.2]ip ad 192.168.1.129 25
[r2]int g0/0.1
[r2-GigabitEthernet0/0.1]vlan-type dot1q vid 2
[r2-GigabitEthernet0/0.1]ip ad 192.168.2.1 25
[r2]int g0/0.2
[r2-GigabitEthernet0/0.2]vlan-type dot1q vid 3
[r2-GigabitEthernet0/0.2]ip ad 192.168.2.129 25
(3)启用dhcp
[r1]dhcp server en
[r1]dhcp server ip-pool yzyss
[r1-dhcp-pool-yzyss]gateway-list 192.168.1.1
[r1-dhcp-pool-yzyss]network 192.168.1.0 25
[r1-dhcp-pool-yzyss]dns-list 114.114.114.114 8.8.8.8
[r1-dhcp-pool-yzyss]quit
[r1]int g0/1.1
[r1-GigabitEthernet0/1.1]dhcp select server (子接口需要启用DHCP,物理接口不需要)
[r1]dhcp server ip-pool xx
[r1-dhcp-pool-xx]network 192.168.1.128 25
[r1-dhcp-pool-xx]gateway-list 192.168.1.129
[r1-dhcp-pool-xx]dns-list 114.114.114.114 8.8.8.8
[r1-dhcp-pool-xx]quit
[r1]int g0/1.2
[r1-GigabitEthernet0/1.2]dhcp select server
(4)静态路由和空接口
[r1]ip route-static 192.168.2.0 24 192.168.0.2
[r1]ip route-static 192.168.2.0 24 NULL 0
[r2]ip route-static 192.168.1.0 24 192.168.0.1
[r2]ip route-static 192.168.1.0 24 NULL 0
测试:
三.实验总结
1.同一个vlan并不是同一个网段
2.sw1和sw2上面连接路由器的接口也需要修改接口类型为trunk并且定义允许列表(这点常常忽略)
3.配置时路由器接口和显示的是一样的,交换机接口和显示的不一样。
到这里整个实验就完成了。