三层交换机与路由器互联

在这里插入图片描述

1. //配置路由器接口地址
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]ip add 10.0.0.1 24
[r1-GigabitEthernet0/0/0]int g0/0/1
[r1-GigabitEthernet0/0/1]ip add 20.0.0.1 24

2.  //配置交换机 vlan等信息
[sw1]vlan ba 2 3 10   
[sw1]int e 0/0/1
[sw1-Ethernet0/0/1]por l a 
[sw1-Ethernet0/0/1]po d v 10
[sw1]int Vlanif 10
[sw1-Vlanif10]ip add 10.0.0.2 24

[sw1-Ethernet0/0/1]int e 0/0/5
[sw1-Ethernet0/0/5]po l t
[sw1-Ethernet0/0/5]p t a v a


[sw2]int e0/0/1
[sw2-Ethernet0/0/1]por l a
[sw2-Ethernet0/0/1]po d v 20
[sw2-Ethernet0/0/1]int vlanif 20
[sw2-Vlanif20]ip add 20.0.0.2 24

[sw2]int e0/0/05
[sw2-Ethernet0/0/5]p l t
[sw2-Ethernet0/0/5]p t a v a


3./ 配置ETH-TRUNK
//sw2 
[sw2]int Eth-Trunk 1
[sw2-Eth-Trunk1]q    
[sw2]int Eth 0/0/3
[sw2-Ethernet0/0/3]eth-trunk 1
[sw2-Ethernet0/0/3]int e0/0/02
[sw2-Ethernet0/0/2]eth 1

[sw2]int Eth-Trunk 1
[sw2-Eth-Trunk1]port l t
[sw2-Eth-Trunk1]port t a v a

//sw1 
[sw1]int Eth-Trunk 1
[sw1]int e0/0/2
[sw1-Ethernet0/0/2]eth-trunk 1
[sw1-Ethernet0/0/2]int e0/0/03
[sw1-Ethernet0/0/3]eth-trunk 1

[sw1]int Eth-Trunk 1
[sw1-Eth-Trunk1]port l t
[sw1-Eth-Trunk1]port l trunk 
[sw1-Eth-Trunk1]port t a v a


4. //配置vrrp
[sw1]int vlan 2
[sw1-Vlanif2]ip add 12.2.2.1 24
[sw1-Vlanif2]vrrp vrid 2 virtual-ip 12.2.2.12
[sw1-Vlanif2]vrrp vr 2 priority 105
[sw1-Vlanif2]vrrp vrid 2 track interface Ethernet 0/0/1   //追踪上线接口状态,该接口断掉 自动降级(降10)

[sw1]int vlan 3
[sw1-Vlanif3]ip add 12.3.3.1 24
[sw1-Vlanif3]vrrp v 3 v
[sw1-Vlanif3]vrrp v 3 virtual-ip 12.3.3.12


[sw2]int vlan 2
[sw2-Vlanif2]ip add 12.2.2.2 24
[sw2-Vlanif2]vrrp vrid 2 virtual-ip 12.2.2.12 
[sw1-Vlanif2]vrrp vrid 2 track interface Eth 0/0/1   //追踪上线接口状态,该接口断掉 自动降级

[sw2-Vlanif2]int vlan 3           
[sw2-Vlanif3]ip add 12.3.3.2 24
[sw2-Vlanif3]vrrp vrid 3 virtual-ip 12.3.3.12
[sw2-Vlanif3]vrrp vr 3 priority 105



5. //配置动态路由协议  实现全vlan互通
[r1]ospf 1
[r1-ospf-1]are 0
[r1-ospf-1-area-0.0.0.0]net 10.0.0.0 0.0.0.255
[r1-ospf-1-area-0.0.0.0]net 20.0.0.0 0.0.0.255

[sw1]ospf 1
[sw1-ospf-1-area-0.0.0.0]net 10.0.0.1 0.0.0.255
[sw1-ospf-1-area-0.0.0.0]net 12.2.2.1 0.0.0.255
[sw1-ospf-1-area-0.0.0.0]net 12.3.3.1 0.0.0.255

[sw2-ospf-1]are 0
[sw2-ospf-1-area-0.0.0.0]net 12.2.2.2 0.0.0.255
[sw2-ospf-1-area-0.0.0.0]net 12.3.3.2 0.0.0.255
[sw2-ospf-1-area-0.0.0.0]net 20.0.0.2 0.0.0.255


6.//配置接入层交换机
[sw 3]vla b 2 3
[sw 3]int e0/0/1
[sw 3-Ethernet0/0/1]por l t 
[sw 3-Ethernet0/0/1]po t a v a

[sw 3]int e 0/0/2
[sw 3-Ethernet0/0/2]p l t
[sw 3-Ethernet0/0/2]p t a v a

[sw 3-Ethernet0/0/1]int e0/0/04
[sw 3-Ethernet0/0/4]port l a
[sw 3-Ethernet0/0/4]port d v 3

[sw 3]int e0/0/3
[sw 3-Ethernet0/0/3]po l a
[sw 3-Ethernet0/0/3]p d v 2
```
  • 6
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值