Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
docs:guide-user:services:vpn:pptp:server [2020/10/16 13:28] – update vgaeteradocs:guide-user:services:vpn:pptp:server [2023/03/14 13:32] – consolidate variable naming vgaetera
Line 1: Line 1:
 ====== PPTP server ====== ====== PPTP server ======
-{{section>meta:infobox:howto_links#cli_skills&noheader&nofooter&noeditbutton}}+{{section>meta:infobox:howto_links#basic_skills&noheader&nofooter&noeditbutton}}
  
 ===== Introduction ===== ===== Introduction =====
   * This how-to describes the method for setting up [[wp>Point-to-Point_Tunneling_Protocol|PPTP]] server on OpenWrt.   * This how-to describes the method for setting up [[wp>Point-to-Point_Tunneling_Protocol|PPTP]] server on OpenWrt.
-  * Follow [[docs:guide-user:services:vpn:pptp:client|PPTP client]] to set up PPTP server and [[docs:guide-user:services:vpn:pptp:extras|PPTP extras]] for additional tuning+  * Follow [[docs:guide-user:services:vpn:pptp:client|PPTP client]] for client setup and [[docs:guide-user:services:vpn:pptp:extras|PPTP extras]] for additional tuning.
-  * Follow [[docs:guide-user:services:rng|Random generator]] to overcome low entropy issues.+
  
 ===== Goals ===== ===== Goals =====
-{{section>docs:guide-user:services:vpn:openvpn:server#goals&noheader&nofooter&noeditbutton}}+{{section>docs:guide-user:services:vpn:wireguard:server#goals&noheader&nofooter&noeditbutton}}
  
-===== Instructions =====+===== Command-line instructions =====
 ==== 1. Preparation ==== ==== 1. Preparation ====
-Set up [[docs:guide-user:services:ddns:client|DDNS client]] if required. +Install the required packages
-Install the packages and specify the VPN server configuration parameters.+Specify the VPN server configuration parameters.
  
 <code bash> <code bash>
 # Install packages # Install packages
 opkg update opkg update
-opkg install pptpd +opkg install pptpd kmod-nf-nathelper-extra
-</code> +
- +
-==== Server configuration ==== +
-There is no need to modify server configuration files /etc/pptpd.conf /etc/ppp/options.pptpd, however some parameters needs to be adjusted depending from clients and network configuration ( such as mtu, mru, ms-dns, proxyarp). +
-See documentation and tips below. +
- +
-Clients configuration is located in /etc/config/pptpd. +
-Modify it to enable pptpd and configure clients and network. +
-Following is example for two clients. +
-You can add multiple config 'login'+
- +
-<code bash> +
-# /etc/config/pptpd +
- +
-config service pptpd +
- option enabled '1' +
- option localip 'xxx.yyy.www.zzz' +
- +
-config login +
- option username 'foo' +
- option password 'bar' +
- option remoteip 'xxx.yyy.zzz.1'+
  
-config login +# Configuration parameters 
- option username 'foo' +VPN_POOL="192.168.6.128-254" 
- option password 'bar' +VPN_USER="USERNAME" 
- option remoteip 'xxx.yyy.zzz.2'+VPN_PASS="PASSWORD"
 </code> </code>
  
-==== Network configuration ==== +==== 2. Firewall ==== 
-If you are using different subnet for VPN clients you need to add route:+Enable conntrack helper to allow related GRE traffic. 
 +Consider VPN network as private. 
 +Assign VPN interface to LAN zone to minimize firewall setup. 
 +Allow access to VPN server from WAN zone.
  
 <code bash> <code bash>
-/etc/config/network +Configure kernel parameters 
- +cat << EOF >> /etc/sysctl.conf 
-config route +net.netfilter.nf_conntrack_helper=1
- option interface 'lan' +
- option target 'xxx.yyy.zzz.0' +
- option netmask '255.255.255.0' +
- option gateway 'xxx.yyy.www.zzz' +
-</code> +
- +
-==== Firewall configuration ==== +
-== Accept traffic from wan == +
-In order to accept pptp traffic in wan to router you need to open following protocols and ports. +
- +
-<code bash> +
-# /etc/config/network +
- +
-config rule +
- option target 'ACCEPT' +
- option name 'pptp' +
- option src 'wan' +
- option proto 'tcp' +
- option dest_port '1723' +
- +
-config rule +
- option target 'ACCEPT' +
- option name 'gre' +
- option src 'wan' +
- option proto '47' +
-</code> +
- +
-== Accept VPN traffic == +
-In order to enable traffic inside VPN to enter, leave and pass trough router you need to add following. +
-Be aware, that if you are using ppp (PPPoE or similar) in wan following configuration is insecure and shall be modified. +
- +
-<code bash> +
-cat << EOF >> /etc/firewall.user +
-# Allow all traffic in and out of the ppp interface +
-iptables -A input_rule -i ppp+ -j ACCEPT +
-iptables -A output_rule -o ppp+ -j ACCEPT +
-# This rule will allow traffic towards internet +
-iptables -A forwarding_rule -i ppp+ -j ACCEPT +
-iptables -A forwarding_rule -o ppp+ -j ACCEPT+
 EOF EOF
-</code> +/etc/init.d/sysctl restart
-As a safer way you can automate these rules like this: +
-<code bash> +
-cat << "EOF"/etc/ppp/ip-up +
-#!/bin/sh +
-NET_DEV="${1}" +
-if [ "${NET_DEV}" != *wan* ] +
-then iptables -A forwarding_rule -i "${NET_DEV}" -j ACCEPT +
-fi +
-EOF +
-cat << "EOF" > /etc/ppp/ip-down +
-#!/bin/sh +
-NET_DEV="${1}" +
-if [ "${NET_DEV}" != *wan* ] +
-then iptables -D forwarding_rule -i "${NET_DEV}" -j ACCEPT +
-fi +
-EOF +
-</code>+
  
-===== Set-up and configuration for historic versions (pre 14.07) ===== +# Configure firewall 
-<code bash> +uci rename firewall.@zone[0]="lan" 
-opkg install pptpd kmod-mppe+uci rename firewall.@zone[1]="wan" 
 +uci del_list firewall.lan.device="ppp+" 
 +uci add_list firewall.lan.device="ppp+" 
 +uci -q delete firewall.pptp 
 +uci set firewall.pptp="rule" 
 +uci set firewall.pptp.name="Allow-PPTP" 
 +uci set firewall.pptp.src="wan" 
 +uci set firewall.pptp.dest_port="1723" 
 +uci set firewall.pptp.proto="tcp" 
 +uci set firewall.pptp.target="ACCEPT" 
 +uci commit firewall 
 +/etc/init.d/firewall restart
 </code> </code>
  
-pptpd will be running, and will be running on boot. +==== 3VPN service ==== 
-Add a user to ''/etc/ppp/chap-secrets'' (see below). +Configure VPN service.
-Optionally add //proxyarp// to ''/etc/ppp/options.pptpd''+
-Then try to connect from a client. +
- +
-The kernel module kmod-mppe is needed for encryption. +
-If you are on trunk, you might need to update your firmware to latest before installing kernel modules, as the kernel sometimes changes, thus the trunk repository modules will not match the older kernel. +
- +
-==== OpenWrt Generic ==== +
-Instructions that are not specific to any particular version of OpenWrt. +
- +
-=== Configuration === +
-The default IP address of the server end of the tunnel is ''172.16.1.1'' with a colon after it:+
  
 <code bash> <code bash>
-/etc/ppp/options.pptpd +Configure VPN service 
-172.16.1.1:+uci set pptpd.pptpd.enabled="1" 
 +uci set pptpd.pptpd.logwtmp="0" 
 +uci set pptpd.pptpd.localip="${VPN_POOL%.*}.1
 +uci set pptpd.pptpd.remoteip="${VPN_POOL}" 
 +uci -q delete pptpd.@login[0] 
 +uci set pptpd.client="login" 
 +uci set pptpd.client.username="${VPN_USER}" 
 +uci set pptpd.client.password="${VPN_PASS}" 
 +uci commit pptpd 
 +/etc/init.d/pptpd restart
 </code> </code>
  
-Change this if you want a different IP address. +===== Testing ===== 
-There is no need to restart //pptpd// if you change this file, because it is used by //pppd// as soon as the next connection arrives. +{{section>docs:guide-user:services:vpn:wireguard:server#testing&noheader&nofooter&noeditbutton}}
-The file contains options for //pppd//, see //man pppd// on a Linux system for more information on the options available.+
  
-/!\ //ppp// has obsoleted this option (as of v2.4.3-7). +===== Troubleshooting ===== 
-In order to assign the local IP address of the server end of the tunnel, include the //localip// option in your ///etc/pptpd.conf//. +Collect and analyze the following information.
-For example:+
  
 <code bash> <code bash>
-localip 172.16.1.1 +# Restart services 
-</code>+/etc/init.d/log restart; /etc/init.d/pptpd restart; sleep 10
  
-The easiest way to get LAN access is to make sure the localip is in the LAN ip range. +# Log and status 
-To dynamicly assign IP addresses to clients, you can add the following which dynamicly assigns an IP to the client.+logread -e pptpd; netstat -l -n -p | grep -e pptpd
  
-<code bash> +# Runtime configuration 
-remoteip 172.16.1.100-109 +pgrep -f -a pptpd 
-</code>+ip address show; ip route show table all 
 +ip rule show; ip -6 rule show; nft list ruleset 
 +sysctl net.netfilter.nf_conntrack_helper
  
-=== Tunnel remote IP addresses === +# Persistent configuration 
-Add an IP address for every client, e.g.: +uci show network; uci show firewall; uci show pptpd 
- +grep -v -"^#" -e "^$" /etc/sysctl.conf
-<code bash> +
-# /etc/ppp/chap-secrets +
-# username provider password ipaddress +
-vpnuser pptp-server vpnpassword 172.16.1.2+
 </code> </code>
- 
-See //man pppd// on a Linux system for more information on this file. 
-Take care that the provider field matches the //name// option in ///etc/ppp/options.pptpd//. 
-The default is //pptp-server//. 
- 
-/!\ If you have x-wrt installed and use it to edit the //chap-secrets// file, it will create every entry with the provider of //pptpd//. 
-Also, every time the router is rebooted the file will be rewritten so that the provider is //pptpd//. 
-The easiest way to deal with this is to set the default provider in ///etc/ppp/options.pptpd// to //pptpd//. 
- 
-/!\ For the //bin// and //pptp// builds of OpenWrt, the file will start out being a symbolic link to a template in ///rom//, so remove the link, copy the template, and make sure it is //chmod 600//. 
- 
-/!\ It is important to set an IP address rather than use the default asterisk. 
-If you use an asterisk, the peer may propose it's own address, which could cause a routing loop. 
-This results in very large transmit counters on //ifconfig ppp0// and a badly performing router, as it spends all it's time trying to move packets through the loop. 
- 
-=== Firewall === 
-For your security OpenWrt will ignore connections on the WAN interface, but accept connection from a client on the LAN or wireless interfaces. 
-If your client is to connect on the WAN interface, edit the ///etc/firewall.user// file and add the following: 
- 
-<code bash> 
-iptables -t nat -A prerouting_rule -i $WAN -p tcp --dport 1723 -j ACCEPT 
-iptables        -A input_rule      -i $WAN -p tcp --dport 1723 -j ACCEPT 
-iptables        -A output_rule             -p 47               -j ACCEPT 
-iptables        -A input_rule              -p 47               -j ACCEPT 
-</code> 
- 
-See the [[docs:guide-user:firewall:start|Firewall Documentation]] for help. 
-Be aware that $WAN might not be defined. 
-If that is the case, insert the interface name instead. 
-I.e. replace $WAN by eth1. 
- 
-Alternatively you can configure the firewall: 
- 
-<code bash> 
-# /etc/config/firewall 
- 
-config 'rule' 
- option 'target' 'ACCEPT' 
- option '_name' 'pptpd' 
- option 'proto' 'tcp' 
- option 'dest_port' '1723' 
- option 'family' 'ipv4' 
- option 'src' 'wan' 
-</code> 
- 
-==== Configure Routing ==== 
-While we now have a VPN ready where the clients can connect to the OpenWrt router we might want to allow the clients to see inside the LAN. 
-Of course we can alway give appropriate routes to server and clients but there's another way. 
-In our example we have a LAN network ''192.168.0.1/24'' on the LAN port of our router. 
-We want multiple clients to connect to the //pptpd// server and be able to connect to the LAN without the need of client routes. 
-This is especially useful for Windows machines as they either route everything through the //pptpd// tunnel or nothing and we want them to be able to connect without much configuration hassle for the users. 
-We will use //proxyarp// for that purpose: 
- 
-<code bash> 
-# /etc/ppp/options.pptpd 
-proxyarp 
-</code> 
- 
-When the next client connection arrives you should see something like: 
- 
-<code> 
-found interface vlan0 for proxy arp 
-</code> 
- 
-in the logs. 
-The kernel will now answer arp requests for the clients connected through the PPTP tunnel and thus the packets are routed correctly to either the ppp+ device or vlan0. 
-We will have to add additional iptables rules. 
- 
-<code bash> 
-# Allow all traffic in and out of the ppp interface 
-/usr/sbin/iptables -A input_rule -i ppp+ -j ACCEPT 
-/usr/sbin/iptables -A output_rule -o ppp+ -j ACCEPT 
-# This rule will allow traffic towards internet 
-/usr/sbin/iptables -A forwarding_rule -i ppp+ -j ACCEPT 
-</code> 
- 
-==== Setup for Windows filesharing ==== 
-If you have Windows PPTP clients and you want them to be able to access file shares on the LAN, you need to set the IP addresses of the PPTP clients to be on the same subnet as the LAN. 
-This is because of a limitation in proxyarp. 
-They also cannot be on the same subnet as the local addresses of the PPTP clients. 
-For example, if your PPTP clients have addresses in the 192.168.0.0/24 subnet, you can set you LAN to be 192.168.30.0/24 with DCHP assigning 192.168.30.50-192.168.30.100, but be careful that your PPTP clients' subnets are not in the 192.168.0.0 range. 
-You would be better off selecting something in the 172.16.0.0/12 range (such as 172.18 for your LAN and 172.19 for the VPN clients with a bitmask of 16, i.e. 255.255.0.0). 
-You can set the IP address of the PPTP server to be 192.168.30.200 by adding the following line: 
- 
-<code bash> 
-# /etc/ppp/options.pptpd 
-192.168.30.200: 
-</code> 
- 
-You can then assign the client IP address beginning with 192.168.30.201. 
-Use the following settings for VPN in . 
- 
-<code bash> 
-cat << EOF >> /etc/firewall.user 
-iptables        -A forwarding_rule -s 192.168.30.0/24 -d 192.168.30.0/24 -j ACCEPT 
-iptables        -A output_rule     -o ppp+ -s 192.168.30.0/24 -d 192.168.30.0/24 -j ACCEPT 
-iptables        -A input_rule      -i ppp+ -s 192.168.30.0/24 -d 192.168.30.0/24 -j ACCEPT 
-# allow VPN connections to get out WAN interface (to internet) 
-iptables        -A forwarding_rule -i ppp+ -o $WAN -j ACCEPT 
-EOF 
-</code> 
- 
-You will now be able to access file shares by IP address. 
-For example, you can type 
- 
-<code> 
-\\192.168.30.50 
-</code> 
- 
-into the address bar of Windows Explorer. 
-Network neighborhood still doesn't detect available computers. 
-If anyone knows how to make this work please post the instructions here. 
-The desired configuration would have automatic detection and population, so there is no need to edit host files. 
-I tried following [[http://poptop.sourceforge.net/dox/replacing-windows-pptp-with-linux-howto.phtml|instructions]] for setting up samba to run as a WINS server but I couldn't get it to work. 
-Perhaps this is because OpenWrt is running an older version of samba that was selected because it has a smaller memory footprint. 
- 
-=> In general the way for computers to appear in Net-Hood is to have server (master browser) to populate browse list across networks + have hosts or lmhosts file setup on client machines(that is only way I discovered so far). 
-For samba servers you need to have config options in smb.conf:  (ip address of router/name of workgroup), but I'm not sure how it works on wrt (as it only have cups I couldn't get them installed due to space limitation) remote announce = 192.168.11.1/UR-WG-NAME and hosts file in windoze (c:\Windows\System32\drivers\etc\hosts) like 192.168.11.10    mypc       mypc.behind-wrt54g.org .. 
- 
-=> Other way way for computers to appear in Net-Hood is to use on router side utility called //bcrelay//. 
-//Bcrelay// turns on broadcast relay mode, sending all broadcasts received on the server's internal interface to the clients. 
-Default pptpd package on WhiteRussian 0.9 contains pptpd version 1.3.0 compiled without //bcrelay// support. 
-Good discussion about this problem can be found at [[http://forum.openwrt.org/viewtopic.php?pid=56890]] 
- 
-Decision: 
-  - Recompile pptpd with bcrelay support or get compiled by simba87 package from [[http://rapidshare.com/files/59421121/pptpd_1.3.4-1_mipsel.ipk.html]]. 
-  - Backup ///etc/pptpd.conf// and all files in ///etc/ppp///. Uninstall old pptpd package. 
-  - I put //pptpd_1.3.4-1_mipsel.ipk// to my hosting, then use //wget// on the router and use //ipkg install pptpd_1.3.4-1_mipsel.ipk//. 
-  - Add //bcrelay br0// to /etc/pptpd.conf and //proxyarp// to /etc/ppp/options.pptpd. 
- 
-===== Troubleshooting ===== 
-==== Test Connection ==== 
-Tell a client to connect to the PPTP server, using the username and password you set in //chap-secrets//. 
- 
-The connection should work, ping between the client and the server should work, but you may have to do some more configuring to let the client use your PPTP server as a gateway to the internet, or to see inside your LAN. 
-See the routing section above . 
- 
-==== Configure Debug Logging ==== 
-If you have problems making a connection, increase the amount of information logged: 
-  * edit ///etc/pptpd.conf// and add the line //debug//, and restart //pptpd// using ///etc/init.d/S50pptpd stop// followed by ///etc/init.d/S50pptpd start//, 
-  * edit ///etc/ppp/options.pptpd// and add the line //debug//, and the line //logfile "/tmp/pptpd.log"// ... these changes take effect on next client connection, there is no need to restart //pptpd//. 
- 
-To understand the //pppd// debug log, read these key sections of the PPTP Client Diagnosis HOWTO: 
-  * [[http://pptpclient.sourceforge.net/howto-diagnosis.phtml#confreqacknakrej|What does ConfReq, ConfAck, ConfNak, and ConfRej mean?]] 
-  * [[http://pptpclient.sourceforge.net/howto-diagnosis.phtml#mppe_bits|What are those CCP MPPE bitmasks?]] 
- 
-====Notes==== 
-If you can not ping router, host in lan or in internet from VPN client and there are no errors in pptpd log or system log, most likely packets get dropped in firewall. 
- 
-If you can connect to the //pptpd// and can ping the client from the server and vice versa but are not able to ping anything else refer to this [[http://poptop.sourceforge.net/dox/diagnose-forwarding.phtml|checklist for diagnosis]] 
- 
-There is a [[http://www.windowsecurity.com/articles/Configure-VPN-Connection-Windows-XP.html|Windows XP client HOWTO]] that may help. 
- 
-There is also the [[http://pptpclient.sourceforge.net/|PPTP Client for Linux]] or check the OpenWrt [[docs:guide-user:services:vpn:pptp:client]]. 
- 
-If the PPTP clients are behind an Actiontec DSL Modem/Router, only one of them will be able to connect. 
-This is do to a bug in the Actiontec. 
-Apparently it locks the connection to one client. 
-If the router is rebooted the first client to reconnect is locked in. 
-Putting the Actiontec into bridged mode and using a different router will probably bypass the problem. 
-Does anyone else have any experience with this? 
- 
-Starting 18.06 version a lot of users report such error 
- 
-<code> 
-Mon Jul 20 09:02:20 2020 kern.warn kernel: [  216.886288] conntrack: generic helper won't handle protocol 47. Please consider loading the specific helper module. 
-</code> 
- 
-to resolve it install this package 
- 
-<code> 
-kmod-nf-nathelper-extra 
-</code> 
- 
-everything after that starts work but maybe some other error comes out 
- 
-<code> 
-Tue Jul 21 08:02:21 2020 kern.info kernel: [  215.914057] nf_conntrack: default automatic helper assignment has been turned off for security reasons and CT-based  firewall rule not found. Use the iptables CT target to attach helpers instead. 
-</code> 
- 
-so if this is a problem. who can please help and  add info here 
  
  • Last modified: 2023/10/29 01:14
  • by vgaetera