Jesin's Blog

Welcome to the Portal of Technology

  • Facebook
  • GitHub
  • Google+
  • RSS
  • Twitter
  • Home
  • Categories
    • Domains
    • Linux
    • Networking
    • PHP
    • Virtualization
    • Web Design
    • Web Servers
    • Windows
  • WordPress Plugins
    • Custom Error Pages
    • HTTP Digest Authentication
    • Mailgun Email Validator
  • Toolbox
    • DNS Lookup Tool
    • htdigest Generator Tool Online
    • htpasswd Generator Tool Online
    • HTTP Headers Lookup Tool
    • MD5 Encryption Tool
    • Open Port Check Tool
    • SHA-1 Encryption Tool
    • URL Encoding/Decoding Tool
  • About Me
  • Contact Me
  • Sitemap
Home ›
Linux ›
How to configure a Linux PPTP VPN client

How to configure a Linux PPTP VPN client

November 27, 2011 Linux Jesin A 13 Comments

linux category thumbnail

Configuring a VPN client connection is a simple matter of point and click in Windows OSes, but in Linux it is involves installing a package, configuring passwords, VPN server settings and finally routing the traffic destined for the VPN network via the VPN connection. The package named pptp is used on the client side for configuring a connection. To setup a VPN server read How to setup a VPN Server in Windows Server 2008. This tutorial is for both Debian Linux variants and Red Hat Linux variants.

Fedora/Red Hat/CentOS PPTP Client Installation

Install the pptp client

yum install pptp

Debian/Ubuntu PPTP Client Installation

Use the apt-get command

apt-get install pptp-linux

Configuring VPN credentials and server settings

Edit the following file and enter your VPN username and password

vi /etc/ppp/chap-secrets

The syntax of the file is as follows

DOMAIN\\username      PPTP      vpnpassword     *

For example to configure a user named jesin on example.com with pass1 as the password enter

EXAMPLE\\jesin        PPTP      pass1           *

If your VPN network doesn’t come under a domain replace DOMAIN with your VPNSERVER name.

Next is to configure the VPN server settings. Create and edit a new file under the peers directory

vi /etc/ppp/peers/vpnconnection1

Add content according to the syntax below

pty "pptp vpn-server-hostname-or-ip-address --nolaunchpppd"
name DOMAIN\\username
remotename PPTP
require-mppe-128
file /etc/ppp/options.pptp
ipparam vpnconnection1

Here “DOMAIN\\username” is the same as the one entered in the chap-secrets file. The ipparam should contain the name of the newly created file, in this case it is “vpnconnection1”

Adding a route to the routing table

All traffic for the VPN network should pass through the VPN interface so an entry has to be added to the routing table. To automatically add an entry whenever a VPN connection is established create and edit the following file

vi /etc/ppp/ip-up.d/vpn1-route

Add the following content

#!/bin/bash
route add -net 10.0.0.0/8 dev ppp0

Make the file executable

chmod +x /etc/ppp/ip-up.d/vpn1-route

Testing the connection

To connect using the newly created VPN connection use the following command

pppd call vpnconnection1

Take a peek into the messages log file using the following command

tail -f /var/log/messages

you should see something similar to this

Nov 27 13:46:20 server1 kernel: [ 800.071028] PPP generic driver version 2.4.2
Nov 27 13:46:20 server1 pppd[1083]: pppd 2.4.5 started by root, uid 0
Nov 27 13:46:20 server1 pppd[1083]: Using interface ppp0
Nov 27 13:46:20 server1 pppd[1083]: Connect: ppp0 /dev/pts/0
Nov 27 13:46:25 server1 pppd[1083]: CHAP authentication succeeded
Nov 27 13:46:25 server1 kernel: [ 804.683790] padlock: VIA PadLock Hash Engine not detected.
Nov 27 13:46:25 server1 kernel: [ 804.687408] PPP MPPE Compression module registered
Nov 27 13:46:25 server1 pppd[1083]: MPPE 128-bit stateless compression enabled
Nov 27 13:46:26 server1 pppd[1083]: local IP address 10.0.0.11
Nov 27 13:46:26 server1 pppd[1083]: remote IP address 10.0.0.12

Try pinging a system in the VPN network and you should get proper replies.

Disconnecting the connection

To disconnect the PPTP VPN connection use the killall command

killall pppd

Related posts:

linux category thumbnailSetting up a PPTP VPN Server on Debian/Ubuntu windows category thumbnailHow to setup a VPN Server in Windows Server 2008 networking category thumbnailHow to Configure PPP in Cisco Routers windows category thumbnailSetting up an authoritative DNS in Windows Server 2008 linux category thumbnailHow to configure NIS server in Linux

Tags: linux, vpn

Comments

  1. marcelo says

    March 23, 2014 at 5:31 am

    Thanks Jesin. I edit the file pap-secrets too and works.

    Reply
  2. Denis says

    June 19, 2014 at 4:17 am

    Thanks, helped me a lot.

    Reply
  3. Andrew b says

    November 18, 2014 at 2:19 am

    I love tutorials that actually work 🙂 Thanks!

    Reply
  4. D'go says

    February 13, 2015 at 9:30 pm

    I cant seem to edit this in step

    vi /etc/ppp/ip-up.d/vpn1-route

    Please help.

    Im running fed 18 arm on cubieboard

    Reply
    • Jesin A says

      February 13, 2015 at 9:39 pm

      I found this from an article dated 2007, see if it works:

      vi /etc/ppp/ip-up.local

      Edit this file, place the same contents in it and make it executable.

      Reply
      • D'go says

        February 13, 2015 at 10:32 pm

        Thank you for the reply – Not sure if you can assist but i was able to add that however after attempting to connect
        sudo pppd call vpnconnection1
        i get

        [fedpower@10.1.1.1 ~]$ sudo pppd call vpnconnection1
        Couldn’t open the /dev/ppp device: No such device or address
        pppd: Please load the ppp_generic kernel module.

        Any idea?

        Reply
        • Jesin A says

          February 13, 2015 at 10:38 pm

          Edit /etc/modprobe.d/modules.conf and change

          alias char-major-108 ppp

          to

          alias char-major-108 ppp_generic
    • daniel says

      July 26, 2018 at 8:48 am

      use the ‘sudo’ command as pretty much all the ppp related command would need to be ran with elevated privileges.

      Reply
  5. D'go says

    February 13, 2015 at 11:23 pm

    Thank you for your efforts Im going to leave it as is:

    I am unable to edit this in step:
    vi /etc/ppp/ip-up.d/vpn1-route
    to insert this:
    #!/bin/bash
    route add -net 10.0.0.0/8 dev ppp0

    but even under root i get:
    “/etc/ppp/ip-up.d/vpn1-route”
    “/etc/ppp/ip-up.d/vpn1-route” E212: Can’t open file for writing
    Press ENTER or type command to continue

    Reply
    • Jesin A says

      February 13, 2015 at 11:26 pm

      Please read my earlier comment, I told you to edit /etc/ppp/ip-up.local and place that code.

      Reply
  6. Josef Bunes says

    September 19, 2015 at 4:48 pm

    I have a problem: After connecting I can ping to the pptp server/gate, to the computers in connected network, but my ip address is my origin one(ip of my isp). What can I do to have ip address of vpn?

    Reply
  7. Jose says

    November 26, 2015 at 8:08 am

    Awesome. It helps me a lot, great job!

    Reply
  8. Vladimir says

    October 31, 2017 at 3:54 am

    When I try to call my vpn , I get message that pppd can’t open options from File /etc/ppp/options.pptp no such file or directory

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Get a wealth of information delivered to your inbox. Subscribe and never miss a single article.

  • Tutorials and howtos
  • Code, scripts and commands
  • Online Tools

* No spam, unsubscribe anytime

Hire Me

  • SSL installation and hardening (A+ on Qualys SSL test)
  • Apache & Nginx configuration
  • Email deliverability improvement (10/10 on Mail Tester & MailGenius)
  • WordPress customization, optimization and migration
  • and much more…

    Tools

    • DNS Lookup Tool
    • htdigest Generator Tool Online
    • htpasswd Generator Tool Online
    • HTTP Headers Lookup Tool
    • MD5 Encryption Tool
    • Open Port Check Tool
    • SHA-1 Encryption Tool
    • URL Encoding/Decoding Tool

    Nav

    • Home
    • About Me
    • Contact Me
    • Privacy Policy
    • Sitemap
    Vultr SSD VPS

    Creative Commons License
    Jesin's Blog by Jesin A is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
    Based on a work at websistent.com.