大网数据广告活动
服务器运维问答

Allow GRE (IP protocol 47) over Linux router NAT for a subnet

· 52CE 我爱测

I have network setup as shown below: The VPN server running is windows 2012 server default VPN, which uses GRE protocol. I am able to have VPN connection to that remote vpn server, from my intranet single IP only. But I am not ab…

问题原文

原帖链接 · Shyamkkhadka · CC BY-SA 4.0

I have network setup as shown below:

The VPN server running is windows 2012 server default VPN, which uses GRE protocol. I am able to have VPN connection to that remote vpn server, from my intranet single IP only. But I am not able to connect for range of intranet IP 172.16.14.0/24. The problem is with linux router, which is doing NAT. My iptable for nat table looks like this for working vpn connection (for single IP), allowing gre protocol:

 iptables -I PREROUTING -t nat -p 47 --src 202.xx.yy.abc  -j DNAT --to-destination 172.16.14.15
 iptables -I POSTROUTING -p 47 -t nat --src 172.16.14.15  -j SNAT --to-source 202.xx.yy.zz
 iptables -t nat -A POSTROUTING -o eth2 -j MASQUERADE 
 iptables -A INPUT -p 47 -j ACCEPT

This rule works fine for single IP 172.16.14.15. How can I make this works for whole 172.16.14.0/24 range so that I can have VPN connection to the remote VPN server ?

社区高分解答

原帖链接 · Shyamkkhadka · CC BY-SA 4.0

I found the solution.

I did this:

 sysctl -w net.netfilter.nf_conntrack_helper=1

Then add

modprobe ip_nat_pptp

I was using Ubuntu 18.04.2 LTS, kernel version 4.15.0-45-generic. There was no need to do anything related with GRE protocol inside iptables PREROUTING, POSTROUTING tables. Adding just above two lines worked.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-11-22)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。