Setup VPN connection (Microsoft PPTP) for Ubuntu 12.04

来源:互联网 发布:c语言swich case 编辑:程序博客网 时间:2024/04/29 08:44



Setting up VPN client (PPTP) to connect to some VPN server should be a fairly easy task nowadays - at least most of the online articles/tutorials/videos all suggest so. For example,https://www.youtube.com/watch?v=YUgSpKFhuqg, andhttp://ashu-geek.blogspot.co.uk/2012/05/vpn-virtual-private-network.html.


It is in fact very simple --- well, at least for Windows and Mac OS, least 5 minutes for both OSs. However for Ubuntu (not sure for other Linux variants), it's pain-in-the-ass business!!


Basically, the NetworkManager was disabled on all machines in the lab since network setup is handled in the old-fashion way of making use of /etc/network/interfaces file. Most tutorial are based on a working state of NetworkManager.


One solution is to put NetworkManager back into the control

https://answers.launchpad.net/ubuntu/+source/gnome-nettool/+question/204377

which didn't work for my case.

*************************************************************************

*************************************************************************

wired device not managed
  Most probably your interface appears in /etc/network/

interfaces. By default, NetworkManager does not manage
  interfaces that appear in /etc/network/
interfaces. You can change this behaviour.

  To do this - in a terminal:
  sudo nano /etc/NetworkMan
ager/NetworkManager.conf
  change the line managed=
false to managed=true

  Save, stop and start network manager:
  sudo service network-manager restart

  Alternatively, you can remove the interface from /etc/network/interfaces.
  backup the current interfaces file:
  sudo cp /etc/network/
interfaces /etc/network_interfaces_backup

  Then open the file:
  sudo nano /etc/network/
interfaces

  Delete everything in that file and copy and paste the following:
  auto lo
  iface lo inet loopback

  Save, stop and start network manager:
  sudo service network-manager restart

*************************************************************************

*************************************************************************



There is of course nice step-by-step instructions on how to configure VPN connection manually.

https://help.ubuntu.com/community/VPNClient


The above link also explains the sort of 'conflicts' between /etc/network/interfaces and NetworkManager.


Anyway, it took our network guru the whole morning to get the manual configuration working, although I have no idea how did he fix it.


The only extra bit I can figure is that the error seemed to be "FATAL: Module ppp_mppe not found"  and he seemed to have done 'modprobe ppp-compress-18', which also mentioned in the following trhead:

http://www.linuxfly.org/post/642/


Gee! How can I assume you could remember everything FOR EVER! It's bound to be forgot!

To start VPN now, run the following:

sudo pon AlbitaVPN nodetach


Some other networking knowledge along the road

PPTP Client 

Mppe Installation Upgrades Question

sudo modprobe ppp-compress-18

if you don't see any message, you are ok.
Next, check that pppd program contains MPPE support by entering

strings `which pppd`|grep -i mppe|wc --lines

if you get a number, you are ok. I get 43.

which also gives links to:

PPTP Client  Diagnosis HOWTO

and

PPTP Client Debian HOWTO


How to route only specific subnet (source ip) to a particular interface

policy based routing

A simple introduction (with a nice easy example) to source based routing


Gateways and Routes


From `man pppd` -(Point-to-Point Protocol Daemon)

PPP  is  the protocol used for establishing internet links over dial-up modems, DSL connections, and
       many other types of point-to-point links.  The pppd daemon works together with the kernel PPP driver
       to establish and maintain a PPP link with another system (called the peer) and to negotiate Internet
       Protocol (IP) addresses for each end of the link.  Pppd can also authenticate the peer and/or supply
       authentication  information  to  the peer.  PPP can be used with other network protocols besides IP,
       but such use is becoming increasingly rare.


Some debugging strings

pptp --version

lsmod | grep ppp

cat /etc/ppp/options.pptp

pon vpn-name debug dump logfd 2 nodetach

less  /var/log/pppd.log

egrep '^[^#]'  /etc/ppp/options.pptpd


PPTP Client Routing HOWTO


Creating VPN Connection on Linux (Ubuntu) using command line (PPTP Client for windows VPN Server)

To successfully configure PPTP VPN Client we need:-
  • /etc/ppp/peers/myvpn (Suppose we have given name to tunnel or connection as myvpn for our identity purpose)
  • /etc/ppp/chap-secrets
  • Server name or ip address of vpn server.
  • User name and password to connect vpn server.
  • Most important pptp-linux package

补充(2013-09-27)

要在新机器上配置VPN,就又翻出来看了一遍,有些新的理解,不知道对不对

PPTP Client: pptp-linux

PPP: Point-to-Point Protocol daemon, 是个支持MPPE加密的package,主要包含pppd程序(上面的man pppd和检测是否支持MPPE)

注意:Thepptp-linux package does not depend on ppp (>= 2.4.2)because it is possible to configure a tunnel without encryption.