User Tools

Site Tools


docs:guide-user:services:vpn:vpnc-client

VPNC Client

for configuration see current README

VPNC for older firmware versions

:!: NOTE: The information on this page is obsolete. Beginning with Chaos Calmer, vpnc is configured via UCI. See the README in the vpnc package directory.
For an overview over all existing Virtual private network (VPN)-related articles in the OpenWrt wiki, please visit overview

vpnc

opkg update
opkg install vpnc
cat << "EOF" > /etc/vpnc/default.conf
IPSec gateway 188.40.166.25
IPSec ID munky
IPSec secret correcthorsebatterystaple
Xauth username munky
Xauth passwordcorrecthorsebatterystaple
EOF

This provides the router with access to the vpn but nothing on your LAN will access the vpn resources. So we need post-connect rules.

cat << "EOF" > /etc/vpnc/post-connect.d/masquerade
iptables -A forwarding_rule -o tun0 -j ACCEPT
iptables -A forwarding_rule -i tun0 -j ACCEPT
iptables -t nat -A postrouting_rule -o tun0 -j MASQUERADE
EOF

Now when you run the command 'vpnc' it should connect the vpn and your LAN will be able to connect as well now. Next we want to autoconnect when you boot the router.

mkdir /etc/config/vpnc
cd /etc/config/vpnc
cat << "EOF" > /etc/config/vpnc/startup-script
#!/bin/sh /etc/rc.common
START = 75
STOP = 01 
 
start () {
    vpnc
}
 
stop () {
    vpnc-disconnect
}
EOF

This script should be symlinked to /etc/init.d but for some reason the symlink cannot be enabled.

cp /etc/config/vpnc/startup-script /etc/init.d/vpnc
/etc/init.d/vpnc enable

The remaining problem is detecting when the vpn disconnects. Note 10.10.10.1 in this script. You should change this to an ip address on the vpn.

cat << "EOF" > /etc/config/vpnc/keep-alive
#!/bin/sh
if ping -q -c 1 10.10.10.1 2>&1 > /dev/null
then
    echo itworks > /dev/null
else
    /etc/init.d/vpnc stop
    sleep 50
    /etc/init.d/vpnc start
fi
EOF

The final action needed is to created the scheduled task. The following runs this every 15 minutes.

crontab -e
*/15 * * * * /etc/config/vpnc/keep-alive
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
docs/guide-user/services/vpn/vpnc-client.txt · Last modified: 2019/09/08 13:16 by tmomas