---
description: GRE
---

# 20191022

{% embed url="https://www.jannet.hk/zh-Hant/post/generic-routing-encapsulation-gre/" %}

![](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LrmTbPhciziyqyR61bR%2F-LrmU7Y_czXTz63hgAaq%2Fimage.png?alt=media\&token=ca3246a9-f603-41f5-bcec-d74a8a1cfd34)

```
R1 ip設定:
int lo 1
ip addr 192.168.1.1 255.255.255.0
no shut
int e0/0
ip addr 10.0.14.1 255.255.255.0
no shut
R2 ip設定:
int lo 1
ip addr 192.168.2.2 255.255.255.0
no shut
int e0/0
ip addr 10.0.24.2 255.255.255.0
no shut
R4 ip設定:
int e0/0
ip addr 10.0.14.4 255.255.255.0
no shut
int e0/1
ip addr 10.0.24.4 255.255.255.0
no shut
R1 ping R4-R1的bridge確認是否有成功，可以發現成功。
do ping 10.0.14.4
而R1在去 ping R4-R2的bridge發現無法ping 的情況。
do ping 10.0.24.4
會發現R1沒有新增路由表往R4-R2的bridge ip，所以我們增加:
ip route 0.0.0.0 0.0.0.0 10.0.14.4
do ping 10.0.24.4
這時就會成功了。
R1在去ping 10.0.24.2會發現無法ping，原因是因為R2的路由表沒有R1的ip，所以在R2去做:
ip route 0.0.0.0 0.0.0.0 10.0.24.4
do ping 10.0.14.4
成功。
```

```
R1 ping R2的部分
R1:
do ping 192.168.2.2 source 192.168.1.1
此時發現ping不過去，請做:
R1:
int tunnel 12 
ip addr 172.16.12.1 255.255.255.0
tunnel source 10.0.14.1
tunnel destination 10.0.24.2
R2:
int tunnel 12
ip addr 172.16.12.2 255.255.255.0
tunnel source 10.0.24.2
tunnel destination 10.0.14.1
R1:
do ping 192.168.2.2 source 192.168.1.1 (不成功)
do ping 172.16.12.2 source 172.16.12.1 (成功)
上面ping不成功的部分是因為R1路由表沒有對方的ip，因此:
ip route 192.168.2.0 255.255.255.0 172.16.12.2
R2也要增設:
ip route 192.168.1.0 255.255.255.0 172.16.12.1
再去做do ping 就可以成功。(R1-R2)
```

![](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LrmTbPhciziyqyR61bR%2F-LrmTfSD6P5UJfFo1PW-%2Fimage.png?alt=media\&token=609a60ad-f71d-440e-a2c9-afd900eead0f)

![](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LrmTbPhciziyqyR61bR%2F-LrmUkrvlXs484ff8cZl%2Fimage.png?alt=media\&token=6d7d9a61-91d4-4a14-a647-d2b4dde40650)

```
增設R1-R3與上述R1-R2作法相同。
R2-R3
```
