Adding routes to VPN (pptpd)

There is a file for running commands when PPP goes up or down.

On CentOS it is located at /etc/ppp/ip-up  (create it if not)

Examples of

#!/bin/bash

case "$5" in
        172.16.4.200)
                /sbin/route add -net 172.16.3.64/26 gw 172.16.4.200
                ;;
        172.16.4.201)
                /sbin/route add -net 172.16.3.128/26 gw 172.16.4.201
                ;;
        *)
esac


# Add a route for each client that connects to server: 

/sbin/ip ro add $5/32 via 10.0.3.1 dev $1 table office 

Make the script executable: chmod +x ip-up

Arguments available in ip-up scripts

Argument Description
$1 the interface name used by pppd (e.g. ppp3)
$2 the tty device name
$3 the tty device speed
$4 the local IP address for the interface
$5 the remote IP address
$6 the current IP address before connecting to the VPN
This entry was posted in Linux and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *