如何在Linux环境创建GRE Tunnel
2016-12-14 10:27
399 查看
Question: I want to connect to remote networks by using a GRE tunnel. How can I create a GRE tunnel between two end points on Linux?
GRE tunnels are IP-over-IP tunnels which can encapsulate IPv4/IPv6 and unicast/multicast traffic. To create a GRE tunnel on Linux, you need
ip_gre kernel module, which is GRE over IPv4 tunneling driver.
So first make sure that ip_gre is loaded.
$ sudo modprobe ip_gre
$ lsmod | grep gre
Here, we assume that you want to create a GRE tunnel between two interfaces with the following IP addresses.
Host A: 192.168.233.204
Host B: 172.168.10.25
On host A, run the following command.
$ sudo ip tunnel add gre0 mode gre remote 172.168.10.25 local 192.168.233.204 ttl 255
$ sudo ip link set gre0 up
$ sudo ip addr add 10.10.10.1/24 dev gre0
In the above, we create a GRE-type tunnel device called gre0, and set its remote address to 172.168.10.25. Tunneling packets will be originating from 192.168.233.204 (local IP address), and their TTL field will be set to 255. The tunnel device is
assigned IP address 10.10.10.1 with netmask 255.255.255.0.
Now verify that route for the GRE tunnel is set up correctly:
$ ip route show
On host B, run similar commands as follows.
$ sudo ip tunnel add gre0 mode gre remote 192.168.233.204 local 172.168.10.25 ttl 255
$ sudo ip link set gre0 up
$ sudo ip addr add 10.10.10.2/24 dev gre0
At this point, a GRE tunnel should be established between host A and host B.
To verify that, from one tunneling end point, ping the other end point.
$ ping 10.10.10.2 (from host A)
If you want to tear down the GRE tunnel, run the following command from either end.
$ sudo ip link set gre0 down
$ sudo ip tunnel del gre0
转自:http://blog.csdn.net/jjw97_5/article/details/41747557
GRE tunnels are IP-over-IP tunnels which can encapsulate IPv4/IPv6 and unicast/multicast traffic. To create a GRE tunnel on Linux, you need
ip_gre kernel module, which is GRE over IPv4 tunneling driver.
So first make sure that ip_gre is loaded.
$ sudo modprobe ip_gre
$ lsmod | grep gre
ip_gre 22432 0 gre 12989 1 ip_gre
Here, we assume that you want to create a GRE tunnel between two interfaces with the following IP addresses.
Host A: 192.168.233.204
Host B: 172.168.10.25
On host A, run the following command.
$ sudo ip tunnel add gre0 mode gre remote 172.168.10.25 local 192.168.233.204 ttl 255
$ sudo ip link set gre0 up
$ sudo ip addr add 10.10.10.1/24 dev gre0
In the above, we create a GRE-type tunnel device called gre0, and set its remote address to 172.168.10.25. Tunneling packets will be originating from 192.168.233.204 (local IP address), and their TTL field will be set to 255. The tunnel device is
assigned IP address 10.10.10.1 with netmask 255.255.255.0.
Now verify that route for the GRE tunnel is set up correctly:
$ ip route show
default via 135.112.29.1 dev eth0 proto static 10.10.10.0/24 dev gre0 proto kernel scope link src 10.10.10.1
On host B, run similar commands as follows.
$ sudo ip tunnel add gre0 mode gre remote 192.168.233.204 local 172.168.10.25 ttl 255
$ sudo ip link set gre0 up
$ sudo ip addr add 10.10.10.2/24 dev gre0
At this point, a GRE tunnel should be established between host A and host B.
To verify that, from one tunneling end point, ping the other end point.
$ ping 10.10.10.2 (from 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.619 ms 64 bytes from 10.10.10.2: icmp_req=2 ttl=64 time=0.496 ms 64 bytes from 10.10.10.2: icmp_req=3 ttl=64 time=0.587 ms
If you want to tear down the GRE tunnel, run the following command from either end.
$ sudo ip link set gre0 down
$ sudo ip tunnel del gre0
转自:http://blog.csdn.net/jjw97_5/article/details/41747557
相关文章推荐
- 如何在Linux环境创建GRE Tunnel
- 如何在Linux环境创建GRE Tunnel
- 如何在Linux环境创建GRE Tunnel
- 如何在Linux环境创建GRE Tunnel
- 如何在Linux环境创建GRE Tunnel
- 如何在Linux环境创建GRE Tunnel
- 在Linux环境中使用DeVeDe工具如何创建视频DVD
- 如何在UNIX/LINUX环境中创建Oracle9i 数据库
- 如何在linux环境创建redis集群
- 如何在Linux桌面环境中使用DeVeDe工具创建视频DVD
- linux 环境 weblogic 12c 如何创建DOMAIN
- Linux环境下共享库(动态链接库)的简要介绍(如何创建共享库)
- 如何在linux创建python虚拟环境
- 收集整理的Linux下的小技巧(四) - 在Ubuntu创建自己的开发环境
- 如何创建SharePoint的开发环境
- 如何对动态创建控件进行验证以及在Ajax环境中的使用
- Ubuntu下arm交叉编译环境的创建及基于s3c2410的linux2.6.22移植(一)
- 【嵌入式Linux学习七步曲之第一篇 Linux主机开发环境】如何通过vnc图形界面远程控制Linux主机
- 如何创建本地Ubuntu Linux Mirror镜像
- 如何对动态创建控件进行验证以及在Ajax环境中的使用