Documente Academic
Documente Profesional
Documente Cultură
http://wiki.mikrotik.com/wiki/VPN_(any_type)_between_2_Mikrotik_rout...
Server side
On the server side we first create an user who will connect to the server: (Be sure to set a complex password and a longer username)
/ppp secret add caller-id="" comment="Some description" disabled=no limit-bytes-in=0 \ limit-bytes-out=0 local-address=10.0.16.9 name=ka password=ka profile=default \ remote-address=10.0.16.10 routes="" service=l2tp
Creating the server interface is not nececery for all this to work since the ROS will dynamicly create the interface each time the user authenticates, but will ease creation of firewall rules. Enable the server:
/interface l2tp-server server set authentication=pap,chap,mschap1,mschap2 \ default-profile=default-encryption enabled=yes max-mru=1460 max-mtu=1460 mrru=disabled
Don't forget to change the dst-address to your IP range on the client side
Here is where you have to take a break from this script and read this script. Since you don't have any static IP addresses, you will need a dynamic DNS on the serve side. Once you have configured the ChangeIP.org script from the link, proceed to the client side configuration.
Client side
Create a l2tp client interface to connect to the server. Change IP_OF_L2TP_SERVER to an IP address of your server side router.
/interface l2tp-client add add-default-route=no allow=pap,chap,mschap1,mschap2 \
1 of 2
8/4/2013 7:18 PM
VPN (any type) between 2 Mikrotik routers and no static IP addresses - M...
http://wiki.mikrotik.com/wiki/VPN_(any_type)_between_2_Mikrotik_rout...
connect-to=IP_OF_L2TP_SERVER dial-on-demand=no disabled=no max-mru=1460 \ max-mtu=1460 mrru=disabled name=l2tp-BL password=ka profile=default-encryption user=ka
Don't forget to change the dst-address to your IP range on the server side Now to make the link work after one of the IP addresses change. First add a script named 'SetL2TP' and with the following code:
:global newr1 [:resolve hostname.changeip.org] /int l2tp-client set l2tp-BL connect-to=$newr1 :log info "SetL2TPscript:Changing IP"
When executed, this will resolve the new IP to the ChangeIP.org hostname you have set on the server side. Then add a scheduler that will execute the above script every 60 seconds (make sure the schedular is now disabled):
/system scheduler add disabled=yes interval=1m name=SetL2TP on-event="system script run SetL2TP" \ policy=read,write,test start-time=startup
Experiment with this interval. You don't want too short an interval because you might get an IP from cache and not be able to reconnect for a longer time. Now add two scripts that enable and disable the scheduler above. Just paste these two lines on the MT terminal:
/system script add name=EnaSched_1 policy=ftp,reboot,read,write,policy,test,winbox,password,sniff \ source="sys sched ena SetL2TP" /system script add name=DisaSched_1 policy=ftp,reboot,read,write,policy,test,winbox,password,sniff \ source="sys sched disa SetL2TP"
Netwatch pings the specified IP address (remote end of VPN link in this case) and then executes different scripts if ping was successful or unsuccessful.
2 of 2
8/4/2013 7:18 PM