Giter Club home page Giter Club logo

vpn-ppp-router's Introduction

VPN PPP Router

Some simple ip-up and ip-down scripts with a shared configuration.

โš ๏ธ Developed and tested only on macOS. Support for other *nix operating systems to come!

Prerequisites

  • macOS ^11.3.0 (not tested on previous versions, your mileage may vary).

Getting started

After downloading and extracting the latest version, navigate inside the project directory.

cd /path/to/vpn-ppp-router

Rename the example ip.config.example file to ip.config.

mv ip.config.example ip.config

Configuration

Inside the ip.config file you'll have to replace the REMOTE_IP value with the remote IP of your PPP interface. To find the remote IP, connect to the VPN and run the following command:

ifconfig | grep -A1 ppp

After running it, you'll get an output similar to this one:

ppp0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1280
	inet 10.50.1.22 --> 10.50.1.0 netmask 0xffffff00

In this case, 10.50.1.0 would be the REMOTE_IP.

In addition to REMOTE_IP, you'll also need to configure the ROUTES.

The ROUTES values are defined using the CIDR notation.
There are various online tools to help you convert IPv4 ranges to CIDR (e.g.: https://www.ipaddressguide.com/cidr).

For a single IPv4 you can essentially just slap a /32 at the end and call it a day ๐Ÿ˜ (e.g.: 192.168.1.113 -> 192.168.1.113/32).

To sum it all up, based on the examples above, the ip.config file will look something like this:

#!/bin/bash

REMOTE_IP=10.50.1.0

ROUTES=(
  "192.168.1.113/32"
)

Installation

Copy or move ip-up, ip-down and ip.config to /etc/ppp.

sudo cp ip-up ip-down ip.config /etc/ppp

Set the permissions.

sudo chmod 755 /etc/ppp/ip-up /etc/ppp/ip-down

Trying it out

If everything went well, after reconnecting/connecting to your VPN all the traffic to the IP ranges configured in ip.config should be routed through your PPP interface.

To test if the routes were added correctly you can run the following command:

netstat -rn | grep ppp

The output should be similar to this one:

default            link#13            UCSIg         ppp0
1.1.1.1            link#13            UHWIig        ppp0
192.168.1.113/32   ppp0               USc           ppp0
10.50.1.0          10.50.1.22         UH            ppp0
10.50.1.22         ppp0               USc           ppp0
224.0.0/4          link#13            UmCSI         ppp0
239.255.255.250    link#13            UHmW3I        ppp0      3
255.255.255.255/32 link#13            UCSI          ppp0

As you can see on the third line, our route has been added correctly.

192.168.1.113/32   ppp0               USc           ppp0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.