www.rodneybeede.com "I would love to change the world, but they won't give me the source code" - unknown
 Navigation

Installing Linux (OpenWRT) on a home router with remote VPN access - Last Modified 2012-02-08 19:30 UTC - Created 2012-02-08 19:26 UTC

I have a Buffalo WZR-HP-AG300H wireless router for my home network. I like it because it supports Linux and has a USB port for my network backup drive as well. It came with DD-WRT, but it was too buggy for stable use as a network drive server and VPN server. I opted for OpenWRT instead which while it requires more configuration effort has worked out very nicely. I've included the steps below I used for setting up a PPTP VPN server I can access remotely. This works out really nice as well for playing video games with friends and family since they just VPN into my network and appear on my local LAN. I choose PPTP over OpenVPN or other solutions because Windows 7 has native support for the client which is easier for others to configure. For security I used passwords that were 30+ characters long which alleviates brute force attacks.

I used OpenWrt Firmware Attitude Adjustment (r29484) / LuCI Trunk (trunk+svn8073) and kernel version 2.6.39.4.

Steps

  1. Install the following packages (I used the LuCI System, Software page):
  2. pptpd
  3. luci-proto-pptp
  4. pptp
  5. The LuCI web interface doesn't have a page for doing configuration for PPTP VPNs
  6. ssh into your router (root@ipaddress)
  7. vi /etc/pptpd.conf (or whatever editor/method you prefer)
  8. Content of pptpd.conf
    option /etc/ppp/options.pptpd
    
    # Set IPs to something not in your DHCP allocated LAN but on the same subnet
    localip 10.1.1.2
    remoteip 10.1.1.3-10
    
    #debug
    
  9. vi /etc/ppp/options.pptpd
  10. Content of options.pptpd
    # Tested against Windows 7 client
    
    auth
    name "pptp-server"
    
    #debug
    #dump
    # pppd logfile option
    #logfile "/tmp/log/pptpd.log"
    
    refuse-pap
    refuse-chap
    refuse-mschap
    
    require-mschap-v2
    # PLEASE NOTE THAT ON OpenWRT (or DD-WRT, etc) distribution builds the pppd is special patched
    #	The MPPC flag builds a non-standard PPP that uses different options.
    # So don't rely on most pptpd or pppd examples since you need the special version one
    mppe required,no40,no56,stateless
    
    # Makes clients look like they are on the lan
    proxyarp
    
    # Client alive check
    lcp-echo-failure 3
    lcp-echo-interval 60
    
  11. vi /etc/ppp/chap-secrets
  12. Content of chap-secrets
    #USERNAME  PROVIDER  PASSWORD  IPADDRESS
    #	* for IPADDRESS means dynamically assign from the remoteip range in options.pptpd
    rbeede pptp-server ProvideAReallyLongPasswordHere *
    gamer pptp-server ProvideAReallyLongPasswordHere *
    
  13. Set firewall rules to allow outside Internet connections to VPN into you and for VPN users to talk to the full LAN
    1. In the LuCI web interface
    2. Network tab
    3. Firewall subtab
    4. Custom Rules sub-subtab
    5. Add the following for your custom rules:
      # This file is interpreted as shell script.
      # Put your custom iptables rules here, they will
      # be executed with each firewall (re-)start.
      
      WAN=eth1
      
      # Allow VPN server
      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
      
      # Allow VPN pptpd connections access to the lan
      iptables        -A forwarding_rule -s 10.1.1.0/24 -d 10.1.1.0/24 -j ACCEPT
      iptables        -A output_rule     -o ppp+ -s 10.1.1.0/24 -d 10.1.1.0/24 -j ACCEPT
      iptables        -A input_rule      -i ppp+ -s 10.1.1.0/24 -d 10.1.1.0/24 -j ACCEPT
      
      # Allow VPN pptpd connections Internet access
      iptables        -A forwarding_rule -i ppp+ -o $WAN -j ACCEPT
      
    6. You may have to adjust IP addresses in the above as needed
  14. /etc/init.d/pptpd enable
  15. /etc/init.d/pptpd start
  16. You should now be able to connect using your public IP
  17. You may find enabling dyndns on your router useful
  18. You may also want to enable a time server client in OpenWrt to ensure you don't have issues with connecting