sys
sys R3
int g0/0/0
ip add 13.0.0.2 30
int g0/0/1
ip add 23.0.0.2 30
int lo 3
ip add 3.3.3.3 32
sys
sys R1
dhcp enable
ip route-static 0.0.0.0 0 13.0.0.2
acl 2000
rule 10 permit so 192.168.10.0 0.0.0.255
int g0/0/0
ip add 13.0.0.1 30
nat outbound 2000
int g0/0/1
ip add 192.168.10.254 24
dhcp select interface
int t0/0/0
tunnel-protocol gre
source 13.0.0.1
destination 23.0.0.1
ip add 192.168.20.1 24
keepalive p 1 r 5
ip route-static 172.16.20.0 24 t0/0/0
ip route-static 172.16.10.0 24 t0/0/0
sys
sys R2
dhcp enable
ip route-static 0.0.0.0 0 23.0.0.2
acl 2000
rule 10 permit so 172.16.0.0 0.0.0.255
int g0/0/0
ip add 23.0.0.1 30
nat outbound 2000
int g0/0/1
ip add 172.16.0.254 24
dhcp select interface
int t0/0/0
tunnel-protocol gre
source 23.0.0.1
destination 13.0.0.1
ip add 172.16.20.1 24
keepalive p 1 r 5
ip route-static 192.168.20.0 24 t0/0/0
ip route-static 192.168.10.0 24 t0/0/0
keepalive p 1 r 5
用於隧道檢測,檢測間隔1s,超過5s無響應介面down掉
GRE隧道兩端IP地址不是同一網段,所以需要新增靜態路由
GRE可以封裝組播,所以也可以選擇OSPF、RIPv2代替靜態路由
ip route-static 172.16.20.0 24 t0/0/0
ip route-static 172.16.10.0 24 t0/0/0
R1可以將靜態路由替換為OSPF
ospf 1 router-id 1.1.1.1
a 0
net 192.168.10.0 0.0.0.255
net 192.168.20.0 0.0.0.255
ip route-static 192.168.20.0 24 t0/0/0
ip route-static 192.168.10.0 24 t0/0/0
R2可以將靜態路由替換為OSPF
ospf 1 router-id 2.2.2.2
a 0
net 172.16.0.0 0.0.0.255
net 172.16.20.0 0.0.0.255