Penguin

Symptoms:

When behind a NAT firewall, you can't make a PPTP connection out from two internal macines to a single external server, or if you stop the connection from the first machine, you can't make a connection from another until 10 minutes is up.

Problem:

Netfilter doesn't know about the connection between a PPTP connection on TCP, and the portless GRE protocol. When you create a PPTP connection, a NAT table entry with a default 10 minute timeout is added. When you disconnect the PPTP, this connection is still running and has to time out before you can connect again.

Solution

Get a kernel that supports PPTP connection tracking.

You have two options:

  • install 2.6.14 or higher, as it was merged into the mainline at this point
  • patch an older kernel and iptables with a patch provided by the Netfilter developers.

With an older kernel

Don't do this. Get 2.6.14.

With 2.6.14+

If you're running 2.6.14.2 or lower, there are two patches on this Netfilter bug which you need to apply to your kernel.

No changes should need to be made to iptables.

Enable/module CONFIG_IP_NF_PPTP and CONFIG_IP_NF_NAT_PPTP; the modules are called ip_nat_pptp and ip_conntrack_pptp. Make sure that ip_nat_pptp and ip_conntrack_pptp are being loaded into the kernel if you are using kernel modules (CONFIG_IP_NF_PPTP=M). Use

lsmod | grep -i pptp

to check for the modules, and

modprobe ip_nat_pptp

and

modprobe ip_conntrack_pptp

to load the modules. If your testing works, then add the modules at boot by editing

/etc/modprobe.conf

and adding lines like this:

insert ip_nat_pptp /bin/true
insert ip_conntrack_pptp /bin/true

I did the testing using tcpdump and a Windows XP PC. On the NAT box, run tcpdump:

/usr/sbin/tcpdump -i any -n -nn host IP_ADDRESS_OF_PPTP_SERVER or host IP_ADDRESS_OF_TEST_PC and not port 22

The

and not port 22

is used to drop SSH traffic if you are using the TEST_PC or PPTP_SERVER to secure shell into the NAT box, otherwise it isn't required. That is all you have to do.

With an older kernel - "I Didn't Listen"

Grab a snapshot from http://ftp.netfilter.org/pub/patch-o-matic-ng/snapshot/ and untar it into a directory. They no longer support this patch, and you might find you have to get an older version of the p-o-m source to make this work. Be prepared to read mailing lists.

You also need some iptables source, so you could use the one in the version you will build below. Read that and return here.

$ cd /path/to/patch-o-matic/
$ export KERNEL_DIR=/usr/src/linux-2.6.10/
$ export IPTABLES_DIR=/tmp/iptables-1.2.10
$
$ ./runme pptp-conntrack-nat

Select 'y' to apply the patch.

I like to edit the Makefile to set EXTRAVERSION to -vpn as I also apply ipsec patches to my VPN kernels. Now, configure and build the kernel as usual - use make oldconfig to ask questions relevant to the new patch (answer Y or M to anything related to PPTP or GRE).

Build your kernel (using make-kpkg(1) if you're on Debian) and go for it.

Update iptables

When you've changed your kernel, the size of some structures change, so you have to recompile the userspace iptables(8) tool to match this.

  • If you build from source it's easy, and you can probably do it yourself.
  • If you're using Debian, the easiest thing to do is download the "latest" iptables source from packages.debian.org and rebuild it. If you're still running Woody, you will need to use the Sarge package (which will work).

On Sarge/Hoary:

$ mkdir /usr/src/iptables/
$ cd /usr/src/iptables
$ apt-get source iptables
$ tar -zvxf iptables_1.2.11-10.tar.gz (sub version numbers as appropriate)
$ cd iptables_1.2.11
$ vim scripts/prep.sh

Add "pptp-conntrack-nat" to the line that lists pomng_extensions.

$ dch -v 1.2.11-10itp1
Add your comment; this increments the package version number.
$ dpkg-buildpackage -uc -us -rfakeroot

You should end up with a iptables_1.2.11-10_i386.deb in the previous directory.

Note, this version of iptables and this kernel are married together. You can't use an unpatched iptables with a patched kernel, etc.

These next two steps are to give you an IPTABLES_DIR for pom on the kernel, as above:

$ cd /tmp
$ tar -zvxf /usr/src/iptables/iptables-1.2.11/upstream/iptables-1.2.11.tar.bz2