How do I configure VPN connections on Ubuntu Server with no GUI?

Solution 1:

To use PPTP, you need to do the following:

First, install the pptp-linux, pppd, ppp packages. Then, create a file in /etc/ppp/peers/. The file name is irrelevant, but this name will be used to switch on the PPTP tunnel, so name it something meaningful. The file (the "peer file") should contain this:

pty "/usr/sbin/pptp <server_ip_address> --nolaunchpppd"
name <your_login_name>
remotename <identifier>
require-mppe-128
file /etc/ppp/options.pptp
ipparam <ipparam_id>

Replace the server_ip_address and the your_login_name with the appropriate values. The identifier will be used for supplying a password (see below). The ipparam_id is used by the scripts in /etc/ppp/ip-up.d/. It is needed if you want to do something with the tunnel interface (adding routes, maybe -- see below).

You need to supply your password. The password is stored in a plaintext file (which sucks, be sure to chown the file to 0600). The file is /etc/ppp/chap-secrets, anbd it should contain a line like this:

your_login_name    identifier    <your_password>    *

The first two parameters is from the peer file.

If you want to do something when the PPTP tunnel starts and/or stops, you need to add scripts to the /etc/ppp/ip-up.d/ and the /etc/ppp/ip-down.d/ directories. Every script in these directories will be run upon (de)activating a ppp tunnel. The following global variables exported for the scripts (there are others, but these are the most useful):

  • PPPD_PID: The PID of the pppd process
  • PPP_IFACE: The interface in question
  • PPP_IPPARAM: The ipparam_id, which is given in the peer file
  • PPP_LOCAL: The local IP address assigned to the ppp interface
  • PPP_REMOTE: The remote IP address assigned to the ppp interface

After all this, you can use the

pon <peer file>

to start the PPTP tunnel, and the

poff <peer file>

to stop it.

Solution 2:

This is a good site: http://pptpclient.sourceforge.net

  1. Usually, we can setup PPTP VPN connection using "pptpsetup" command

    pptpsetup --create Test_VPN --server xxx.xxx.xxx.xxx --domain MyDomain --username MyName --password mypassword --encrypt
    
  2. Start the VPN connection

    pppd call Test_VPN
    
  3. If something is wrong, here is the debug command

    pppd call Test_VPN logfd 2 nodetach debug dump
    

On ubuntu, I think the package you need is pptp-linux, you can install it by the command:

apt-get install pptp-linux