Sunday, December 11, 2005

Connecting to Windows VPN from Debian

Tired of using the PPTP Client GUI? Here's how I did it without the GUI. I really don't like the old GTK 1.x based GUI, and the way how resolv.conf is handled by the GUI.

# install packages
apt-get install ppp pptp-linux resolvconf

# create options.pptp
echo "lock noauth nobsdcomp nodeflate usepeerdns" > /etc/ppp/options.pptp

# create chap-secrets
echo "DOMAIN\\USERNAME PPTP PASSWORD *" > /etc/ppp/chap-secrets
chmod o-rw /etc/ppp/chap-secrets

# create /etc/ppp/peers/TUNNEL-NAME with the following content
pty "pptp SERVERIP --nolaunchpppd"
name DOMAIN\\USERNAME
remotename PPTP
require-mppe-128
file /etc/ppp/options.pptp
ipparam TUNNEL-NAME

# activate the tunnel
pon TUNNEL-NAME

# deactivate the tunnel
poff TUNNEL-NAME

# debug the tunnel with:
pon TUNNEL-NAME debug dump logfd 2 nodetach

# add the tunnel to /etc/network/interfaces with the following content
iface vpn inet ppp
provider TUNNEL-NAME

# create /etc/ppp/ip-up.d/TUNNEL-NAME as follows
#!/bin/sh
if [ "${PPP_IPPARAM}" = "TUNNEL-NAME" ]; then
route add -net 192.168.0.0/24 dev ${IFNAME}
fi

# after you've installed resolvconf, the name servers are managed by
# the resolvconf program based on the status of the interfaces, so
# if you have a static interface, make sure you add your default name
# server to your interface config in /etc/network/interfaces, e.g.
iface eth0 inet static
...
dns-nameservers YOUR_NAME_SERVER


Now you can connect to the VPN server by:

ifup vpn

And disconnect from the VPN server by:

ifdown vpn

And if you want, add this line to /etc/network/interfaces, so that the system will bring the interface up automatically.

auto vpn

No comments: