1.所需设备
3台路由器R1、R2、R3,2台三层交换机S1、S2,两台二层交换机S3、S4,PC机5台,交叉线直连线各若干,DCE-DTE串行线一条。
2.拓扑结构图
3.组网
路由器R1启动OSPF路由协议并链接两个网络F0连接192.168.1.0 Area 1与S0连接192.168.2.0 Area 0,针对S0端口启动PPP PAP 认证。在F0端口启动ACL,允许IP为192.168.3.1-127的主机访问192.168.1.0网络,但不允许IP为192.168.3.128-254的主机访问。
? 路由器R2 启动OSPF协议及RIP协议,右端S0/1链接192.168.2.0 Area 0 路由协议为OSPF,左端F0链接192.168.3.0网络 路由协议为RIP2。
? 路由器R3启动RIP协议,上端F0/2连接192.168.3.0网络,左端F0/0连接192.168.4.0网络,右端F0/1链接192.168.5.0网络。针对F0/0、F0/1为入口F3为出口的网络通信启用NAT功能,将来自192.168.10.0网络的源IP地址动态的转换为192.168.3.1-127,来自192.168.20.0网络的源IP地址动态转换为192.168.3.128-254。
? R3下有vlan 10 、vlan 20。
? S1 、S2 都分别对两vlan起用vrrp组,vlan 10的vrrp虚拟IP为192.168.10.254,vlan 20的vrrp虚拟IP为192.168.20.254实现两组的业务的负载分担和备份。
? S1、S2、S3、S4 都起用 mstp多生成数协议,并且实例映射一致(vlan 10映射实例1、vlan 20映射实例2 其他vlan映射默认实例0)。
? Vlan 10以S1为根桥; vlan 20以S2为根桥;实现阻断网络环路,并能实现不同vlan数据流负载分担功能。
? PC1的默认网关为192.168.10.254,PC2的默认网关为192.168.20.254。
?NAT,MSTP,VRRP 实现
4.详细配置
R1的配置
En
进入特权模式
conf t
进入全局模式
int s 0/1
进入接口模式
ip address 192.168.2.2 255.255.255.0
给接口配置IP地址
no shutdown
启用接口
int f0/0
ip address 192.168.1.1 255.255.255.0
no shutdown
router OSPF 1
进入 OSPF协议模式,进程 号为1
network 192.168.2.0 0.0.0.255 area 0
network 192.168.1.0 0.0.0.255 area 1
声明本路由由器所知的网段,即路由器活动接口所在的网段
access-list 10 permit 192.168.3.127 0.0.0.127
设置标准访问控制列表,允许指定的网段
access-list 10 deny 192.168.3.128 0.0.0.127
拒绝指定的网段
interface fa 0
ip access-group 1 out
在接口模式下应用访问控制列表
username ruijie password 123
在路由器上建立 一个用户,并设置密码
interface seri 0
encapsulation ppp
ppp authentication pap
设置串行链路的认证模式为ppp+chap
R2的配置
configure terminal
interface fa 0
ip address 192.168.3.2 255.255.255.0
no shutdown
exit
interface Ser 0
ip address 192.168.2.1 255.255.255.0
clork rate 5600
no shutdown
exit
router ospf 1
network 192.168.2.0 0.0.0.255 area 0
exit
router rip
version 2
network 192.168.3.0
exit
router ospf 1
redistribute rip metric-type 1 metric 10 subnets
exit
router rip
redistribute ospf 1 metric 3
exit
inter ser 0
ppp pap sent-username ruijie password 123
exit
R3的配置
configure terminal
interface fa 0
ip address 192.168.4.2 255.255.255.0
no shutdown
exit
interface fa 1
ip address 192.168.5.2 255.255.255.0
no shutdown
exit
interface fa 2
ip address 192.168.3.1 255.255.255.0
no shutdown
exit
router rip
version 2
network 192.168.5.0
network 192.168.3.0
network 192.168.4.0
interface fastethernet 2
ip nat outside
exit
interface fastethernet 0
ip nat inside
exit
interface fastethernet 1
ip nat inside
exit
access-list 10 permit 192.168.10.0 0.0.0.255
ip nat pool abc 192.168.3.5 192.168.3.127 netmask 255.255.255.0
ip nat inside source list 10 pool abc overload
access-list 20 permit 192.168.20.0 0.0.0.255
ip nat pool cba 192.168.3.129 192.168.3.253 netmask 255.255.255.0
ip nat inside source list 20 pool cba overload
S1的配置
vlan 10
建立VLAN
exit
vlan 20
exit
inter range fa 0/1-2
switchport mode trunk
exit
设置指定的端口为trunk模式
inter range fa 0/1-2
port-group 1
exit
将端口加入到1号聚合组
inter range fa 0/3-4
switchport mode trunk
exit
spanning-tree
spanning-tree mode mstp
声明生成树协议模式为 MST
spanning-tree mst configuration
进入mst配置模式
name taishan
生成树名称和更新版本
revision 1
instance 1 vlan 10
instance 2 vlan 20
建立实例1和2,关联相关的VLAN
exit
spanning-tree mst 1 priority 8192
设置相应的实例的优先级,优先级值越小级别越高
inter fa 0/5
no switchport
将接口转换为路由模式
ip address 192.168.4.1 255.255.255.0
no shut
exit
inter vlan 10
进入vlan10的虚拟接口
ip address 192.168.10.1 255.255.255.0
standby 1 priority 120
设置vrrp的优先级 ,值越小级别越高,级别高的会成为主要转发的路由器
standby 1 ip 192.168.10.254
设置vrrp1的虚拟ip地址
exit
inter vlan 20
ip address 192.168.20.1 255.255.255.0
standby 2 ip 192.168.20.254
ip router rip
version 2
network 192.168.10.0
network 192.168.20.0
network 192.168.4.0
S2的配置
vlan 10
exit
vlan 20
exit
inter range fa 0/1-2
switchport mode trunk
exit
inter range fa 0/1-2
port-group 1
exit
inter range fa 0/3-4
switchport mode trunk
exit
以下设置MST,优先级与别外一台路由器相反,以达到互为主备的目的
spanning-tree
spanning-tree mode mstp
spanning-tree mst configuration
name taishan
revision 1
instance 1 vlan 10
instance 2 vlan 20
exit
spanning-tree mst 2 priority 8192
inter fa 0/5
no switchport
ip address 192.168.5.1 255.255.255.0
no shut
Exit
以下为设置VRRP,与上一台设置的优先级不同,形成互为主备的虚拟网关
inter vlan 10
ip address 192.168.10.1 255.255.255.0
standby 1 ip 192.168.10.254
exit
inter vlan 20
ip address 192.168.20.1 255.255.255.0
standby 2 priority 120
standby 2 ip 192.168.20.254
ip router rip
version 2
network 192.168.10.0
network 192.168.20.0
network 192.168.5.0
S3的配置
vlan 10
exit
vlan 20
exit
inter range fa 0/1-2
switchport mode trunk
exit
spanning-tree
spanning-tree mode mstp
spanning-tree mst configuration
name taishan
revision 1
instance 1 vlan 10
instance 2 vlan 20
exit
inter fa 0/5
switchport access vlan 10
exit
inter vlan 10
ip address 192.168.10.1 255.255.255.0
exit
inter vlan 20
ip address 192.168.20.1 255.255.255.0
S4的配置
vlan 10
exit
vlan 20
exit
inter range fa 0/1-2
switchport mode trunk
exit
spanning-tree
spanning-tree mode mstp
spanning-tree mst configuration
name taishan
revision 1
instance 1 vlan 10
instance 2 vlan 20
exit
inter fa 0/5
switchport access vlan 20
exit
inter vlan 10
ip address 192.168.10.1 255.255.255.0
exit
inter vlan 20
ip address 192.168.20.1 255.255.255.0
原文地址:https://blog.51cto.com/793906/2391131