The pptpvpn client behind the LINUX gateway connects to the vpn
Source: Internet
Author: User
The pptpvpn client behind the LINUX gateway connects to the vpn-Linux Enterprise Application-Linux server application information. The following is a detailed description. Patch iptables with pptp-conntrack-nat
There seems to be no latest article about the pptp client connect vpn server and 2.6.14.2 kernel after iptables 1.3.4 nat.
Pptp adopts GRE encapsulation. GRE header does not contain tcp, and udp contains port numbers. If pptp is not selected in netfilter during kernel compilation, iptables does not recognize pptp. protocol field "unkown ". after compilation, remember modprobe ip_nat_pptp. It is not loaded by default. I don't know how to load it by default.
Add again:
Iptables-t nat-I PREROUTING-p gre-d natserveripaddress-j DNAT -- to pptp-client-ip-addres
The above means to forward all GRE packets from the vpn server to the pptp client.
The iptables 1.3.4 and 2.6.14.2 kernels already support pptp and do not have to patch-o-magic.
Multiple pptp vpn clients connect to the VPN Server through the LINUX Gateway
Pptp vpn uses the GRE protocol, which is the same as TCP/UDP. Because the GRE protocol does not have a port concept, LINUX cannot disguise IP addresses like TCP/UDP. Therefore, the pptp vpn Client behind the LINUX gateway will always encounter this problem when connecting to the vpn.
Therefore, when only one client connects to the VPN through the linux gateway, the simplest way is to use iptables to forward all the GRE protocol packets to the client. For example, if the ip address of the client is 192.168.0.2 and the iptables command is
The above command is very strange. When this rule is entered, even if it is deleted immediately, it still takes effect and it takes a long time to be disconnected.
Of course, if the vpn IP addresses connected by the client are different from each other, you can also use the source IP address DNAT. However, when multiple machines need to connect to the same pptp vpn Server, the problem arises. Simple DNAT rules cannot take effect because they are all GRE protocols. Only the Class ID in the GRE package can be distinguished. This ID is not supported on the default linux firewall. There are two solutions:
1. Use iptables later than Version 2.0, which has built-in ip_nat_gre modules to support ip spoofing of gre packets. This solution is complex and has a huge project. We need to patch the kernel. It will be more troublesome to update the kernel in the future.
2. Use pptp proxy, which is a gre packet forwarding tool in the user space. You only need to download the source code and compile it to obtain pptpproxy. For example, if your linux gateway Intranet ip address is 192.168.0.254 and the vpn Server is 202.202.202.202, run
Pptpproxy-p 202.202.202.202
You can.
In this case, the vpn Client only needs to use 192.168.0.254 as the IP address of the vpn Server.
Of course, let pptp listen at 127.0.0.1, and then cooperate with some iptables forwarding rules, and even make a transparent pptpproxy proxy.
Pptpproxy also supports multiple vpn server proxies.
If you are running * BSD or MAC, frickin may better meet your needs.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service