文章目录
- GRE隧道(通用路由封装,Generic Routing Encapsulation)协议号47
- 实验:
- 思科:
- 开始实施:
- 华为:
- 开始实施:
- eBGP实施
- 思科:
- 华为:
GRE隧道(通用路由封装,Generic Routing Encapsulation)协议号47
GRE也属于一种VPN(虚拟私有网络,Virtual Private Network)但默认不加密,加密的话与IPSec合用
实验:
首先两个路由器和Internet的四个接口都配好地址(.252)或(/30)后
思科:
R1(config)# ip route 0.0.0.0 0.0.0.0 202.100.1.2 #在R1上配置静态路由
R2(config)# ip route 0.0.0.0 0.0.0.0 202.100.1.6 #在R2上配置静态路由
开始实施:
R1(config)# interface tunnel 0 #R1建立隧道 / R2也是
R1(config-if)# tunnel source 202.100.1.1 #源IP / R2的目的IP
R1(config-if)# tunnel destination 202.100.1.5 #目的IP / R2的源IP
R1(config-if)# ip add 12.1.1.1 255.255.255.252 #设置隧道本端IP / R2是12.1.1.2
R2# ping 12.1.1.1 #测试通
华为:
[R1] ip route-static 0.0.0.0 0.0.0.0 202.100.1.2 #在R1上配置静态路由
[R2] ip route-static 0.0.0.0 0.0.0.0 202.100.1.6 #在R2上配置静态路由
开始实施:
[R1] interface tunnel 0/0/0 #R1建立隧道 / R2也是
[R1-Tunnel0/0/0] tunnel-protocol gre #协议配置为GRE / R2也是
[R1-Tunnel0/0/0] source 202.100.1.1 #源IP / R2的目的IP
[R1-Tunnel0/0/0] destination 202.100.1.5 #目的IP / R2的源IP
[R1-Tunnel0/0/0] ip add 12.1.1.1 30 #设置隧道本端IP / R2是12.1.1.2
[R2] ping 12.1.1.1 #测试通
eBGP实施
在配置了GRE之后
思科:
R1(config)# router bgp 1 #创建bgp进程,AS号为1 / R2 AS号为2
R1(config-router)# bgp router-id 1.1.1.1 #命名router-id / R2为2.2.2.2
R1(config-router)# neighbor 12.1.1.2 remote-as 2 #与as2建立邻居 / R2为与as1建立邻居IP为12.1.1.1
R2# show ip bgp summary #查看bgp邻居
R2# show ip bgp #查看bgp路由表,发现没有路由表
R2(config)# router bgp 2 #然后进入r2的bgp进程
R2(config-router)# network 10.1.20.0 mask 255.255.255.224
R2(config-router)# network 10.1.30.0 mask 255.255.255.224 #把R2的单臂路由两个网段宣告进来
R1(config)# router bgp 1 #进入r1的bgp进程
R1(config-router)# redistribute ospf 110 #把与r1相连的ospf整个进程重分布进bgp
R2# show ip bgp #查看bgp路由表 这次路由都进来了
R1(config)# router ospf 110 #ospf内的其他设备还没有外面的路由
#R1(config-router)# redistribute bgp 1 subnets #同样路由器ospf也要重分布bgp的路由,非主类路由需加subnets,但不建议这种方法,因为实际工作中bgp中的路由表过于庞大。建议用ospf下放默认路由,方法见NAT实验
华为:
[R1] bgp 1 #创建bgp进程,AS号为1 / R2 AS号为2
[R1-bgp] router-id 1.1.1.1 #命名router-id / R2为2.2.2.2
[R1-bgp] peer 12.1.1.2 as-number 2 #与as2建立邻居 / R2为与as1建立邻居IP为12.1.1.1
[R2-bgp] display bgp peer #查看bgp邻居
[R2-bgp] display bgp routing-table #查看bgp路由表,发现没有路由表
[R2] bgp 2 #然后进入e2的bgp进程
[R2-bgp] network 10.1.20.0 27
[R2-bgp] network 10.1.30.0 27 #把R2的单臂路由的两个网段宣告进来
[R1] bgp 1 #进入r1的bgp进程
[R1-bgp] import-route ospf 10 #把与r1相连的ospf整个进程引入进bgp
[R2-bgp] display bgp routing-table #查看bgp路由表 这次路由都进来了
[R1] ospf 10 #ospf内的其他设备还没有外面的路由
#[R1-ospf-10] import-route bgp #同样路由器ospf也需要引入bgp的路由,但不建议这种方法,因为实际工作中bgp中的路由表过于庞大。建议用ospf下放默认路由,方法见NAT实验