Cisco 路由器的动态路由加上GRE隧道,R1和R4路由器通过Gre实现内部网络的通信,不通过R2和R3路由器进行通信。
一、基础配置
1、配置各路由器的lo 0 口IP地址
R1 lo 0 1.1.1.1
R2 lo 0 2.2.2.2
R3 lo 0 3.3.3.3
R4 lo 0 4.4.4.4
2、配置设备互联IP地址。
R1-R2 12.1.1.1/24 --------- 12.1.1.2/24
R2-R3 23.1.1.2/24 --------- 23.1.1.3/24
R3-R4 34.1.1.3/24 --------- 34.1.1.4/24
3、配置ospf
R1 路由器:
interface Loopback0
ip address 1.1.1.1 255.255.255.255
!
interface Ethernet0/0
ip address 12.1.1.1 255.255.255.0
duplex auto
!
router ospf 100
router-id 1.1.1.1
network 1.1.1.1 0.0.0.0 area 0
network 12.1.1.0 0.0.0.255 area 0
!
R2 路由器:
interface Loopback0
ip address 2.2.2.2 255.255.255.255
!
interface Ethernet0/0
ip address 12.1.1.2 255.255.255.0
duplex auto
!
interface Ethernet0/1
ip address 23.1.1.1 255.255.255.0
duplex auto
!
router ospf 100
router-id 2.2.2.2
network 2.2.2.2 0.0.0.0 area 0
network 12.1.1.0 0.0.0.255 area 0
network 23.1.1.0 0.0.0.255 area 0
!
R3 路由器:
interface Loopback0
ip address 3.3.3.3 255.255.255.255
!
interface Ethernet0/0
ip address 23.1.1.3 255.255.255.0
duplex auto
!
interface Ethernet0/1
ip address 34.1.1.3 255.255.255.0
duplex auto
!
router ospf 100
router-id 3.3.3.3
network 3.3.3.3 0.0.0.0 area 0
network 23.1.1.0 0.0.0.255 area 0
network 34.1.1.0 0.0.0.255 area 0
!
R4 路由器:
interface Loopback0
ip address 4.4.4.4 255.255.255.255
!
interface Ethernet0/0
ip address 34.1.1.4 255.255.255.0
duplex auto
router ospf 100
router-id 4.4.4.4
network 4.4.4.4 0.0.0.0 area 0
network 34.1.1.0 0.0.0.255 area 0
!
二、R1和R4 配置GRE 隧道
R1:
interface Tunnel1
ip address 172.16.1.2 255.255.255.0
keepalive 5 3
tunnel source 12.1.1.1 //本地出口地址
tunnel destination 34.1.1.4 //对端出口地址
R4:
interface Tunnel1
ip address 172.16.1.1 255.255.255.0
keepalive 5 3
tunnel source 34.1.1.4 //本地出口地址
tunnel destination 12.1.1.1 //对端出口地址