Skip to content
www.mytechnote.ru
Menu
  • Administration
    • Scripts
  • Equipment
    • Reviews
    • Instructions
  • Other
  • English
    • English
    • Русский
Menu

How to Set Up and Optimize PPTP VPN on Ubuntu Server 16.04

In today’s guide, we’ll walk you through the detailed steps to establish a PPTP VPN connection on Ubuntu Server 16.04. Plus, we’ll cover how to ensure automatic reconnections and route management.

Please note: PPTP has known vulnerabilities, so consider this method for learning purposes and evaluate more secure VPN options for critical applications.

Step-by-Step Guide: Setting up a PPTP Server on Ubuntu

1. Switching to Superuser Mode

To begin, you’ll want to access your system’s root. Do this with:

sudo su

 

2. System Update

Always start by updating your system to the latest versions:

apt-get update && apt-get upgrade && apt-get dist-upgrade

3. Installing the PPTP Client

To get the required client, run:

apt-get install pptp-linux

4. Configuring the Connection

Use the nano editor to create and configure your connection file:

 nano /etc/ppp/peers/vpn

Within this file, you’ll enter several parameters. Remember to adjust settings such as the server address, username, and password to fit your setup. Example of the file content:

pty “pptp 192.168.1.125 –nolaunchpppd” #change the server address to yours
require-mschap-v2
require-mppe-128
user test1 #username
password “testtest” #password
nodeflate
nobsdcomp
noauth
nodefaultroute  #disable default route,
#if you need it – replace with defaultroute
persist #reconnect when disconnected
maxfail 10 #number of reconnection attempts
holdoff 15 #interval between connections

5. Testing the Connection

After setup, connect using:

pppd call vpn

To verify the connection, use:

ifconfig ppp

ppp0      Link encap:Point-to-Point Protocol  
          inet addr:192.168.6.100  P-t-P:192.168.6.1  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1396  Metric:1
          RX packets:5 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3
          RX bytes:68 (68.0 B)  TX bytes:68 (68.0 B)

If you need to disconnect, a simple:

killall pppd

 

will do the trick.

6. Automating Route Addition and Reconnections

For seamless connectivity, it’s wise to automate route additions and ensure your VPN auto-reconnects if there’s a drop.

For route additions:

nano /etc/ppp/ip-up

You should add lines to the end of the file:

case "$5" in
        192.168.6.1)
                        route add -net 192.168.6.0/24 gw 192.168.6.1
                ;;
        *)
esac

 

 

Don’t forget to change addresses to yours.

For auto-connect and auto-reconnect you can use 2 scripts:

First one – pptp.sh:

nano ~/pptp.sh
#!/bin/sh
vpn='192.168.1.125' #external address or domain name of your vpn server 
ps=`ps ax | grep $vpn | wc -l`
if [ $ps -ge 2 ]; then
exit 1;
else /usr/sbin/pppd call vpn
exit 0;
fi

Second – pptp-reconnect.sh:

nano ~/pptp.sh
#!/bin/bash
SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
#change 192.168.6.1 to your server's internal IP.
if ! ping -Q 2 -c 4 -t 2 192.168.6.1; then
pids=( $(pgrep -f pppd) )
for pid in "${pids[@]}"; do
  if [[ $pid != $$ ]]; then
    kill "$pid"
  fi
done
/root/pptp.sh
fi

Don’t forget to make theese scripts executable:

chmod +x ~/pptp.sh ~/pptp-reconnect.sh

And add them to cron:

crontab -e

Add to the end of the file line:

*/1 * * * * /bin/bash /root/pptp-reconnect.sh

 

 

 

 

In Conclusion

Setting up a PPTP client on Ubuntu Server 16.04 can be achieved with the above steps. Whether you’re an IT professional or a hobbyist looking to learn, this guide provides an easy-to-follow route to get your VPN up and running.

Disclaimer: While PPTP provides a foundational understanding of VPN configurations, always explore and consider modern and more secure VPN solutions for robust applications.

 

Posted on 09.04.201730.05.2024 by sanglyb

Post navigation

← Ultimate April Fools’ Computer Prank: Make Them Think It’s Broken
Optimizing Linux Traffic: A Comprehensive Guide to Dnsmasq & Ipset Routing Techniques →

Leave a Reply Cancel reply

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

Подписывайтесь

Youtube
vk
telegram
github
twitter
rss
  • Форум
  • Об авторе
  • Поддержать автора

Популярные записи

Новые записи

  • How to Extend an LVM Partition in Linux
  • SCCM Reporting Errors After Migrating from SQL Server 2016 to 2019
  • Problem Using PassFiltEx on Older CPUs
  • How to remove attachments from old calendar events in Exchange using a script
  • How to download and install Office 2024 LTSC

Архивы

  • 2026 (3)
  • 2025 (5)
  • 2024 (7)
  • 2023 (30)
  • 2022 (4)
  • 2020 (17)
  • 2017 (82)
  • 2016 (5)
© 2015-2026 www.mytechnote.ru
Использование материалов сайта возможно только с разрешения владельца или обязательна индексируемая, прямая, передающая вес ссылка на материал.