如何在Linux环境创建GRE Tunnel
答案:1 悬赏:80 手机版
解决时间 2021-03-26 20:51
- 提问者网友:我没有何以琛的痴心不悔
- 2021-03-26 13:00
如何在Linux环境创建GRE Tunnel
最佳答案
- 五星知识达人网友:洒脱疯子
- 2021-03-26 14:04
. 创建步骤
环境如下:
host A : 121.207.22.123
host B: 111.2.33.28
在host A上面:
# ip tunnel add gre1 mode gre remote 111.2.33.28 local 121.207.22.123 ttl 255
# ip link set gre1 up
# ip addr add 10.10.10.1 peer 10.10.10.2 dev gre1
# ip tunnel add gre1 mode gre remote 111.2.33.28 local 121.207.22.123 ttl 255
# ip link set gre1 up
# ip addr add 10.10.10.1 peer 10.10.10.2 dev gre1
创建一个GRE类型隧道设备gre0, 并设置对端IP为111.2.33.28。隧道数据包将被从121.207.22.123也就是本地IP地址发起,其TTL字段被设置为255。隧道设备分配的IP地址为10.10.10.1,掩码为255.255.255.0。
在host B上面:
# ip tunnel add gre1 mode gre remote 121.207.22.123 local 111.2.33.28 ttl 255
# ip link set gre1 up
# ip addr add 10.10.10.2 peer 10.10.10.1 dev gre1
# ip tunnel add gre1 mode gre remote 121.207.22.123 local 111.2.33.28 ttl 255
# ip link set gre1 up
# ip addr add 10.10.10.2 peer 10.10.10.1 dev gre1
此时,host A 和 host B 建立起GRE隧道了。
4. 检测连通性
# ping 10.10.10.2 (host A)
PING 10.10.10.2 (10.10.10.2) 56(84) bytes of data.
64 bytes from 10.10.10.2: icmp_req=1 ttl=64 time=0.319 ms
64 bytes from 10.10.10.2: icmp_req=2 ttl=64 time=0.296 ms
64 bytes from 10.10.10.2: icmp_req=3 ttl=64 time=0.287 ms
# ping 10.10.10.2 (host A)
PING 10.10.10.2 (10.10.10.2) 56(84) bytes of data.
64 bytes from 10.10.10.2: icmp_req=1 ttl=64 time=0.319 ms
64 bytes from 10.10.10.2: icmp_req=2 ttl=64 time=0.296 ms
64 bytes from 10.10.10.2: icmp_req=3 ttl=64 time=0.287 ms
环境如下:
host A : 121.207.22.123
host B: 111.2.33.28
在host A上面:
# ip tunnel add gre1 mode gre remote 111.2.33.28 local 121.207.22.123 ttl 255
# ip link set gre1 up
# ip addr add 10.10.10.1 peer 10.10.10.2 dev gre1
# ip tunnel add gre1 mode gre remote 111.2.33.28 local 121.207.22.123 ttl 255
# ip link set gre1 up
# ip addr add 10.10.10.1 peer 10.10.10.2 dev gre1
创建一个GRE类型隧道设备gre0, 并设置对端IP为111.2.33.28。隧道数据包将被从121.207.22.123也就是本地IP地址发起,其TTL字段被设置为255。隧道设备分配的IP地址为10.10.10.1,掩码为255.255.255.0。
在host B上面:
# ip tunnel add gre1 mode gre remote 121.207.22.123 local 111.2.33.28 ttl 255
# ip link set gre1 up
# ip addr add 10.10.10.2 peer 10.10.10.1 dev gre1
# ip tunnel add gre1 mode gre remote 121.207.22.123 local 111.2.33.28 ttl 255
# ip link set gre1 up
# ip addr add 10.10.10.2 peer 10.10.10.1 dev gre1
此时,host A 和 host B 建立起GRE隧道了。
4. 检测连通性
# ping 10.10.10.2 (host A)
PING 10.10.10.2 (10.10.10.2) 56(84) bytes of data.
64 bytes from 10.10.10.2: icmp_req=1 ttl=64 time=0.319 ms
64 bytes from 10.10.10.2: icmp_req=2 ttl=64 time=0.296 ms
64 bytes from 10.10.10.2: icmp_req=3 ttl=64 time=0.287 ms
# ping 10.10.10.2 (host A)
PING 10.10.10.2 (10.10.10.2) 56(84) bytes of data.
64 bytes from 10.10.10.2: icmp_req=1 ttl=64 time=0.319 ms
64 bytes from 10.10.10.2: icmp_req=2 ttl=64 time=0.296 ms
64 bytes from 10.10.10.2: icmp_req=3 ttl=64 time=0.287 ms
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯