Networking

How to share VPN connection over LAN using Mikrotik Router OS?

August 21, 2013

In this tutorial I’m going to discuss about sharing a VPN connection (PPTP) over LAN using Mikrotik Router OS.

VPN Setup – Mikrotik

This is useful in many cases where you are a premium VPN subscriber and want to share the service over LAN.

Script for configuration :

[admin@MikroTik] > /export
# aug/11/2013 15:58:05 by RouterOS 6.0
# software id = 
#
/interface pptp-client
add connect-to=172.17.26.201 disabled=no name=pptp-out1 password=a user=a
/interface ethernet
set 0 mac-address=00:0C:29:4C:AB:51 name=LAN
set 1 mac-address=00:0C:29:4C:AB:47 name=WAN
/ip hotspot user profile
set [ find default=yes ] idle-timeout=none keepalive-timeout=2m mac-cookie-timeout=3d
/ip pool
add name=dhcp_pool1 ranges=192.168.25.1-192.168.25.199,192.168.25.201-192.168.25.254
/ip dhcp-server
add address-pool=dhcp_pool1 disabled=no interface=LAN name=dhcp1
/port
set 0 name=serial0
set 1 name=serial1
/ip address
add address=192.168.0.200/24 interface=WAN network=192.168.0.0
add address=192.168.25.200/24 interface=LAN network=192.168.25.0
/ip dhcp-server network
add address=192.168.25.0/24 dns-server=8.8.8.8 gateway=192.168.25.200
/ip firewall mangle
add action=mark-routing chain=prerouting new-routing-mark=vpn src-address=192.168.25.0/24
/ip firewall nat
add action=masquerade chain=srcnat out-interface=pptp-out1
/ip route
add distance=1 gateway=pptp-out1 routing-mark=vpn
add check-gateway=ping distance=1 gateway=192.168.0.1

Interfaces :

WAN – Connected to Internet
LAN – Connected to Local Area
pptp-out – VPN Connection

This is the first experimental setup which I did. Feel free to correct any mistake if you find any. Thanks šŸ™‚