目录
- 实验条件
- 配置实现
实验条件
网络拓朴
需求
- PC1属于VLAN10,PC2属于VLAN20,PC3属于VLAN30,DHCP Server属于VLAN40,PC1、PC2、PC3的IP地址均采用DHCP方式获取;
- VLAN10、20的网关为MSW1对应的SVI,VLAN30、40的网关为MSW2对应的SVI;
- 所有5台交换机之间线路均为Trunk,其中MSW1和MSW2之间E0/0-1需使用EtherChannel进行捆绑,组ID为12,模式为on;
- 所有5台交换机均启用Rapid-PVST(RSTP),其中MSW1为VLAN10、20的根桥,MSW2为备份根桥,MSW2为VLAN30、40的根桥,MSW1为备份根桥;
- 配置DHCP Server,创建3个地址池,分别为Sales:192.168.10.0/24,网关为192.168.10.254、Product:192.168.20.0/24,网关为192.168.20.254、Services:192.168.30.0/24,网关为192.168.30.254,VLAN10、20、30的网关配置DHCP中继至DHCP Server;
- OR、MSW1、MSW2之间运行OSPF,进程ID:100,Area ID:0,OR下发默认路由仅当本身存在默认路由时;
- OR配置PPPoE,用户名:SPOTO 密码:SPOTO123,ISP没有告知使用哪种认证方式,拨号成功后自动获取IP信息,以及本地自动生成一条默认路由指向ISP;
- OR配置端口复用NAT,使得内网PC1~3能成功ping通ISP上的8.8.8.8;
- PC1 ping 8.8.8.8时,手动关闭SW1的E0/1口模拟线路故障,观察PC1的数据通信情况。
配置实现
1. 配置PC1~3, DHCP_Server的vlan
需求: PC1属于VLAN10,PC2属于VLAN20,PC3属于VLAN30,DHCP Server属于VLAN40,PC1、PC2、PC3的IP地址均采用DHCP方式获取
SW1 & SW2 & SW3
SW1(config)#int e0/0
SW1(config-if)#switchport mode access
SW1(config-if)#switchport access vlan 10
SW1(config-if)#no shutdown
MSW1 & MSW2
MSW1(config)#vlan 10,20,30,40
MSW1(config-vlan)#exit
MSW2(config)#vlan 10,20,30,40
MSW2(config-vlan)#exit
MSW2(config)#int e1/2
MSW2(config-if)#switchport mode access
MSW2(config-if)#switchport access vlan 40
MSW2(config-if)#no shutdown
PC1 & PC2 & PC3
PC1(config)#no ip routing
PC1(config)#int e0/0
PC1(config-if)#ip address dhcp
PC1(config-if)#no shutdown
PC1(config-if)#
DHCP_Server
要注意: 配置好no ip routing 并配置ip default-gateway或者,给路由表添加一条默认的路由指向网关, 否则,其它vlan的客户端请求ip时DHCP_Server没有办法给客户端单播返回offer包和ack包, 导致客户端IP请求地址失败!!!!!!
DHCP_Server(config)#no ip routing
DHCP_Server(config)#int e0/0
DHCP_Server(config-if)#ip address 192.168.40.1 255.255.255.0
DHCP_Server(config-if)#no shutdown
DHCP_Server(config-if)#duplex full
DHCP_Server(config-if)#exit
DHCP_Server(config)#ip default-gateway 192.168.40.254
2. VLAN10、20的网关为MSW1对应的SVI,VLAN30、40的网关为MSW2对应的SVI;
MSW1
MSW1(config)#vlan 10,20,30,40
MSW1(config-vlan)#exit
MSW1(config)#int vlan 10
MSW1(config-if)#ip address 192.168.10.254 255.255.255.0
MSW1(config-if)#no shutdown
MSW1(config-if)#int vlan 20
MSW1(config-if)#ip address 192.168.20.254 255.255.255.0
MSW1(config-if)#no shutdown
MSW1(config-if)#
此时的SVI接口down状态.因为没有配置Trunk或是有归属于10,20的vlan, 所以svi没有办法up, 下一步创建trunk的时候,就可以正常了
MSW2
MSW2(config-if)#vlan 10,20,30,40
MSW2(config-vlan)#exit
MSW2(config)#int vlan 30
MSW2(config-if)#ip address 192.168.30.254 255.255.255.0
MSW2(config-if)#no shutdown
MSW2(config-if)#int vlan 40
MSW2(config-if)#ip address 192.168.40.254 255.255.255.0
MSW2(config-if)#no shutdown
3. 配置5台交换机之间线路均为Trunk
所有5台交换机之间线路均为Trunk,其中MSW1和MSW2之间E0/0-1需使用EtherChannel进行捆绑,组ID为12,模式为on;
MSW1
配置
MSW1(config)#int range ethernet 0/0-3, e1/0
MSW1(config-if-range)#switchport trunk encapsulation dot1q
MSW1(config-if-range)#switchport mode trunk
MSW1(config-if-range)#exit
MSW1(config)#int range e0/0-1
MSW1(config-if-range)#channel-group 12 mode on
Creating a port-channel interface Port-channel 12
MSW1(config-if-range)#
MSW2
配置
MSW2(config)#int range e0/0-3,e1/0
MSW2(config-if-range)#switchport trunk encapsulation dot1q
MSW2(config-if-range)#switchport mode trunk
MSW2(config-if-range)#exit
MSW2(config)#int range e0/0-1
MSW2(config-if-range)#channel-group 12 mode on
Creating a port-channel interface Port-channel 12
MSW2(config-if-range)#
查询结果
MSW1(config-if-range)#do show etherchannel summary
Flags: D - down P - bundled in port-channel
I - stand-alone s - suspended
H - Hot-standby (LACP only)
R - Layer3 S - Layer2
U - in use N - not in use, no aggregation
f - failed to allocate aggregator
M - not in use, minimum links not met
m - not in use, port not aggregated due to minimum links not met
u - unsuitable for bundling
w - waiting to be aggregated
d - default port
A - formed by Auto LAG
Number of channel-groups in use: 1
Number of aggregators: 1
Group Port-channel Protocol Ports
------+-------------+-----------+-----------------------------------------------
12 Po12(SU) - Et0/0(P) Et0/1(P)
MSW1(config-if-range)#do show int trunk
Port Mode Encapsulation Status Native vlan
Et0/2 on 802.1q trunking 1
Et0/3 on 802.1q trunking 1
Et1/0 on 802.1q trunking 1
Po12 on 802.1q trunking 1
Port Vlans allowed on trunk
Et0/2 1-4094
Et0/3 1-4094
Et1/0 1-4094
Po12 1-4094
Port Vlans allowed and active in management domain
Et0/2 1,10,20,30,40
Et0/3 1,10,20,30,40
Et1/0 1,10,20,30,40
Po12 1,10,20,30,40
Port Vlans in spanning tree forwarding state and not pruned
Et0/2 1,10,20,30,40
Et0/3 1,10,20,30,40
Et1/0 1,10,20,30,40
Port Vlans in spanning tree forwarding state and not pruned
Po12 1,10,20,30,40
MSW1(config-if-range)#
SW1 & SW2 & SW3
配置
SW1(config)#int range e0/1-2
SW1(config-if-range)#switchport trunk encapsulation dot1q
SW1(config-if-range)#switchport mode trunk
SW1(config-if-range)#no shutdown
SW1(config-if-range)#
4. 配置5台交换机均启用Rapid-PVST(RSTP)
所有5台交换机均启用Rapid-PVST(RSTP),其中MSW1为VLAN10、20的根桥,MSW2为备份根桥,MSW2为VLAN30、40的根桥,MSW1为备份根桥;
SW1 & SW2 & SW3
SW1(config)#spanning-tree mode rapid-pvst
配置MSW1为VLAN10、20的根桥, MSW2为备份根桥
MSW1(config)#spanning-tree mode rapid-pvst
MSW1(config)#spanning-tree vlan 10,20 priority 0
MSW1(config)#spanning-tree vlan 30,40 priority 4096
配置MSW2为VLAN30、40的根桥, MSW1为备份根桥
MSW2(config)#spanning-tree mode rapid-pvst
MSW2(config)#spanning-tree vlan 30,40 priority 0
MSW2(config)#spanning-tree vlan 10,20 priority 4096
5. 配置DHCP Server,创建3个地址池
配置DHCP Server,创建3个地址池,分别为Sales:192.168.10.0/24,网关为192.168.10.254、Product:192.168.20.0/24,网关为192.168.20.254、Services:192.168.30.0/24,网关为192.168.30.254,VLAN10、20、30的网关配置DHCP中继至DHCP Server;
DHCP_Server配置
DHCP_Server(config)#service dhcp
// sales地址池
DHCP_Server(config)#ip dhcp pool Sales
DHCP_Server(dhcp-config)#network 192.168.10.0 255.255.255.0
DHCP_Server(dhcp-config)#default-router 192.168.10.254
DHCP_Server(dhcp-config)#dns-server 8.8.8.8
// product地址池
DHCP_Server(dhcp-config)#ip dhcp pool Product
DHCP_Server(dhcp-config)#network 192.168.20.0 255.255.255.0
DHCP_Server(dhcp-config)#default-router 192.168.20.254
DHCP_Server(dhcp-config)#dns-server 8.8.8.8
// services地址池
DHCP_Server(dhcp-config)#ip dhcp pool Services
DHCP_Server(dhcp-config)#network 192.168.30.0 255.255.255.0
DHCP_Server(dhcp-config)#default-router 192.168.30.254
DHCP_Server(dhcp-config)#dns-server 8.8.8.8
DHCP_Server(dhcp-config)#
MSW1配置
MSW1(config)#interface vlan 10
MSW1(config-if)#ip helper-address 192.168.40.1
MSW1(config-if)#interface vlan 20
MSW1(config-if)#ip helper-address 192.168.40.1
MSW1(config-if)#
MSW2配置
MSW2(config)#interface vlan 30
MSW2(config-if)#ip helper-address 192.168.40.1
6. 配置动态路由OSPF
OR、MSW1、MSW2之间运行OSPF,进程ID:100,Area ID:0,OR下发默认路由仅当本身存在默认路由时
注:
default-information originate [always]
带always
参数: 不管下发默认路由的路由器本身有没有默认路由,都可以作为默认路由下发者
不带always
参数: 下发默认路由的路由器本身必须要有默认路由;
配置OR
OR(config)#int e0/1
OR(config-if)#ip address 10.1.1.1 255.255