如何在Linux环境创建linux 多gre tunnell

查看:2782|回复:0
助理工程师
系统为RH5.0
[root@localhost ~]# /sbin/iptunnel add tunl0 mode gre remote 192.168.186.100
ioctl: No buffer space available
创建不tunnel口
[root@localhost ~]# ip tunnel del tunl0
ioctl: Operation not permitted
也删除不了
[root@localhost ~]# ip tunnel show
sit0: ipv6/ip&&remote any&&local any&&ttl 64&&nopmtudisc
tunl0: ip/ip&&remote any&&local any&&ttl inherit&&nopmtudisc
gre0: gre/ip&&remote any&&local any&&ttl inherit&&nopmtudisc
刚接触linux建gre,有人知道怎么解决吗?Linux Ip/gre tunnel互通隧道配置-红联Linux系统门户
您的位置:
&& 查看内容 - - -
Linux Ip/gre tunnel互通隧道配置
Dragoncity发布于
&&字号: &&&&(网友评论&0&条)&
说明:通过ip/gre tunnel能够通过多个tunnel网关将公司内网和机房互通
一、公司:
UPIP:221.224.0.1
网关:192.168.1.1/24
network 公司
二、机房A:
UPIP:221.224.1.1
network 机房A
网关:10.30.1.1/24
三、机房B:
UPIP:221.224.2.1
网关:172.16.1.1/24
1、公司网关配置:
modprobe ipip
modprobe ip_gre
#tunnel for 机房A
ip tunnel add 机房A mode gre remote 221.224.1.1 local 221.224.0.1 ttl 255
ip link set 机房A up
ip addr add 192.168.1.1 dev 机房A
ip route add 10.30.1.0/24 dev 机房A
#tunnel for 机房B
ip tunnel add 机房B mode gre remote 221.224.2.1 local 221.224.0.1 ttl 255
ip link set 机房B up
ip addr add 192.168.1.1 dev 机房B
ip route add 172.16.1.0/24 dev 机房B
2、机房A网关配置:
ip tunnel add 机房A mode gre remote 221.224.0.1 local 221.224.1.1 ttl 255
ip link set 机房A up
ip addr add 10.30.1.1 dev 机房A
ip route add 192.168.1.0/24 dev 机房A
3、机房B网关配置:
ip tunnel add 机房B mode gre remote 221.224.0.1 local 221.224.2.1 ttl 255
ip link set 机房B up
ip addr add 172.16.1.1 dev 机房B
ip route add 192.168.1.0/24 dev 机房B
发表评论,与各位同人交流。回复请点击下方的我要评论按钮(游客可回复),要发表贴子请点击
Linux教程下载?“”(请点击),Linux教程免费下载。
求助Linux问题?论坛有39版块,覆盖所有Linux技术层面。前往“”
 |  |  |  |  |  |  |  |  |  |  |  | 
&2015 红联 Powered by SupSitelinux - Cannot Delete GRE Tunnel - Server Fault
to customize your list.
Server Fault is a question and answer site for system and network administrators. J it only takes a minute:
Here's how it works:
Anybody can ask a question
Anybody can answer
The best answers are voted up and rise to the top
I am configuring a GRE tunnel in Linux 2.6.26 and I've been facing a very strange problem for which I could not find any solution.
I have created a GRE tunnel called gre0, but no matter what I do, I am simply unable to delete this tunnel. The command ip tunnel del gre0 fails with the response ioctl: Operation not permitted. Any attempt to change the addresses of the tunnel also fails.
The following commands illustrate the problem:
# ip tunnel del gre0
ioctl: Operation not permitted
# ip tunnel change gre0
# ip tunnel change gre0 remote &some address& local &some address&
ioctl: No such file or directory
I can create, change and delete other tunnels without any problem, but gre0 just sticks there and does not go away, even if I reboot or take the interfaces down.
If I remove the ip_gre module, the tunnel disappears. As soon as I insert the module again, gre0 reappears and the problem continues.
I have two questions:
What can I do to get rid of this pesky tunnel? I suspect this might be a kernel or a module bug.
Where such persistent data (in this case, the information for gre0, but this applies to any other setup I may be even unaware of) is stored?
If any other information is needed, please let me know.
Thanks a lot for any help.
I believe I've found myself an answer to this problem.
After tinkering for a while, I decided to reproduce the problem in a clean installation.
The ip_gre module is not inserted by default in the kernel after installing Debian. ip tunnel show does not display any tunnel. After inserting the ip_gre module, but without creating any tunnel, gre0 appears and is undeletable and unchangeable as expected. Thus gre0 seems to be a dummy tunnel created by default by the ip_gre module.
The frustrating part is that this 'feature' is totally undocumented, and is even an unexpected one, since it might be natural to attempt to create a gre0 tunnel as the first (and only) GRE tunnel in a system.
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Server Fault works best with JavaScript enabled聚合国内IT技术精华文章,分享IT技术精华,帮助IT从业人士成长
>> 技术文章 >> 正文
关于 OVS GRE tunnel
浏览: 15406 次
在 korg 内核的 openvswitch 支持 GRE 之前,我们都是,而现在, korg 内核中的 openvswitch 也已经支持 GRE tunnel 了。有兴趣的可以看
这两个 commit。
其实在 OVS 中添加 GRE 很简单,它无非就是把对 GRE 头和外部 IP 头的一些操作从原来的代码中抽象出来,做成内核“库函数”的形式,然后 OVS 中就可以直接调用它们了。难的是要从旧的 ip_gre 模块代码中抽象出这些“库函数”。详见
值得注意的是,OVS GRE tunnel 没有注册网络设备,也就是说你无法通过 `ip link` 看到它,它只是一个 vport 而已,所以能通过 ovs-vsctl show 可以看到。这是故意这么设计的,虽然这简化了用户的操作,但刚注意到时难免会感觉有些奇怪。
网上最流行的一篇讲解 OVS GRE tunnel 配置的教程是,根据它我做了如下配置:
ovs-vsctl add-br grebr0
ovs-vsctl add-br phybr0
ovs-vsctl add-port phybr0 p1p1
ovs-vsctl add-port phybr0 tep0 -- set Interface tep0 type=internal
ifconfig tep0 192.168.88.1/24
ifconfig p1p1 0.0.0.0
ovs-vsctl add-port grebr0 vnet0
ovs-vsctl add-port grebr0 gre1 -- set Interface gre1 type=gre options:remote_ip=192.168.88.2
但是仔细分析一下,其实完全没有必要使用两个 bridge,通过 gre1 的包其实可以直接进入 p1p1,即最后的物理网卡。所以优化后的配置如下:
ovs-vsctl add-br grebr0
ifconfig p1p1 192.168.88.1/24
ovs-vsctl add-port grebr0 vnet0
ovs-vsctl add-port grebr0 gre1 -- set Interface gre1 type=gre options:remote_ip=192.168.88.2
通过 GRE tunnel 的包是重新注入网络栈中的,所以它们会直接流向 p1p1,最终流向物理层。
注意,这并没有结束。虽然通过这个配置你已经可以 ping 通对方 host 上的 VM 了,但是,如果你运行 netperf 测试的话,你会发现吞吐量非常低。这也是网络上的教程没有提到的地方。
这里的原因是从 vnet0 里出来数据包很多是 MTU 的大小,我这里是1500。而经过 GRE tunnel 后外面又添加了 GRE 头和外层的 IP 头,所以包就会大于 1500。而物理网卡的 MTU 也是 1500!并且,这些包本身并不是 GSO 的,所以这些包最终会被 IP 层分片(fragment),所以性能非常差!
这里有两种解决方法:
1) 把 VM 里的网卡 MTU 调小,比如 1400,这样 host 上的 GRE 加上额外的头也不会超过 1500;
2) 让 VM 里发出来的包依旧维持 GSO,这样 host 上收到的包也是 GSO,它们最终会被分段(segment),而不是分片(fragment)。这个可以通过给 qemu 传递 vnet_hdr=on 来完成(我没有试过,仅分析了源代码)。
关于这个问题的进一步讨论可以看。
本页关键字

我要回帖

更多关于 linux gre tunnel 的文章

 

随机推荐