30
Can We Configure VPN With Dynamic IP Public On The Both Side? Mikrotik User Meeting Turkey 2014 By Mochamad Asnul Bahar Arief 1

Can We Configure VPN With Dynamic IP Public On The Both ...mum.mikrotik.com/presentations/TR14/arief.pdfSolution 1. Lease DNS services ( Dyndns, NoIP ) ( 25$/year ) on RouterOS Ver

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Can We Configure VPN With Dynamic IP Public On The Both ...mum.mikrotik.com/presentations/TR14/arief.pdfSolution 1. Lease DNS services ( Dyndns, NoIP ) ( 25$/year ) on RouterOS Ver

Can We Configure VPN With Dynamic IP Public On The Both Side?

Mikrotik User Meeting Turkey 2014

By Mochamad Asnul Bahar Arief

1

Page 2: Can We Configure VPN With Dynamic IP Public On The Both ...mum.mikrotik.com/presentations/TR14/arief.pdfSolution 1. Lease DNS services ( Dyndns, NoIP ) ( 25$/year ) on RouterOS Ver

About me• Mochamad Asnul Bahar Arief• Jakarta , Indonesia• PT.UFOAKSES SUKSES LUARBIASA• Technical Director• MTCNA,MTCWE,MTCTCE

2

Page 3: Can We Configure VPN With Dynamic IP Public On The Both ...mum.mikrotik.com/presentations/TR14/arief.pdfSolution 1. Lease DNS services ( Dyndns, NoIP ) ( 25$/year ) on RouterOS Ver

Statistic• Most of them have dynamic ip• Most of them need vpn

3

Page 4: Can We Configure VPN With Dynamic IP Public On The Both ...mum.mikrotik.com/presentations/TR14/arief.pdfSolution 1. Lease DNS services ( Dyndns, NoIP ) ( 25$/year ) on RouterOS Ver

Solution1. Lease DNS services ( Dyndns, NoIP ) ( 25$/year )on RouterOS Ver 6.11, It’s possible for PPTP,L2TP fill in the address on the connect-to column with a domain name.

2. Communication router to router ( Free )

4

Page 5: Can We Configure VPN With Dynamic IP Public On The Both ...mum.mikrotik.com/presentations/TR14/arief.pdfSolution 1. Lease DNS services ( Dyndns, NoIP ) ( 25$/year ) on RouterOS Ver

Knowledge Requirement • VPN-Tunnel • Static routing• Command-Line• Fetch-Tool• Scripting ( Scripts Repository + Scheduler )http://wiki.mikrotik.com/wiki/Manual:Scripting- Global Scope & Variable- Local Scope & Variable- Global Commands- Common Commands- Print Commands- Conditional Statement- Logical Operators

5

Page 6: Can We Configure VPN With Dynamic IP Public On The Both ...mum.mikrotik.com/presentations/TR14/arief.pdfSolution 1. Lease DNS services ( Dyndns, NoIP ) ( 25$/year ) on RouterOS Ver

What is necessary for PPTP,SSTP,L2TP Client Configuration?

• User• Password • Connect-to ( IP Address PPTP Server )

6

Page 7: Can We Configure VPN With Dynamic IP Public On The Both ...mum.mikrotik.com/presentations/TR14/arief.pdfSolution 1. Lease DNS services ( Dyndns, NoIP ) ( 25$/year ) on RouterOS Ver

Case

7

Page 8: Can We Configure VPN With Dynamic IP Public On The Both ...mum.mikrotik.com/presentations/TR14/arief.pdfSolution 1. Lease DNS services ( Dyndns, NoIP ) ( 25$/year ) on RouterOS Ver

8

Page 9: Can We Configure VPN With Dynamic IP Public On The Both ...mum.mikrotik.com/presentations/TR14/arief.pdfSolution 1. Lease DNS services ( Dyndns, NoIP ) ( 25$/year ) on RouterOS Ver

9

Page 10: Can We Configure VPN With Dynamic IP Public On The Both ...mum.mikrotik.com/presentations/TR14/arief.pdfSolution 1. Lease DNS services ( Dyndns, NoIP ) ( 25$/year ) on RouterOS Ver

The Idea

10

Page 11: Can We Configure VPN With Dynamic IP Public On The Both ...mum.mikrotik.com/presentations/TR14/arief.pdfSolution 1. Lease DNS services ( Dyndns, NoIP ) ( 25$/year ) on RouterOS Ver

The Idea

11

Page 12: Can We Configure VPN With Dynamic IP Public On The Both ...mum.mikrotik.com/presentations/TR14/arief.pdfSolution 1. Lease DNS services ( Dyndns, NoIP ) ( 25$/year ) on RouterOS Ver

The Idea

12

Page 13: Can We Configure VPN With Dynamic IP Public On The Both ...mum.mikrotik.com/presentations/TR14/arief.pdfSolution 1. Lease DNS services ( Dyndns, NoIP ) ( 25$/year ) on RouterOS Ver

The Idea

13

Page 14: Can We Configure VPN With Dynamic IP Public On The Both ...mum.mikrotik.com/presentations/TR14/arief.pdfSolution 1. Lease DNS services ( Dyndns, NoIP ) ( 25$/year ) on RouterOS Ver

Implement The Idea with Script

• Both of the router configured with PPTP • Both of the router has dynamic ip on ether2• Setup the ntp client • Create the script into script repository • Execute the script with scheduler

14

Page 15: Can We Configure VPN With Dynamic IP Public On The Both ...mum.mikrotik.com/presentations/TR14/arief.pdfSolution 1. Lease DNS services ( Dyndns, NoIP ) ( 25$/year ) on RouterOS Ver

Script Router-B (Send IP)Execute this script just once by manual ( without scheduler )

15

Page 16: Can We Configure VPN With Dynamic IP Public On The Both ...mum.mikrotik.com/presentations/TR14/arief.pdfSolution 1. Lease DNS services ( Dyndns, NoIP ) ( 25$/year ) on RouterOS Ver

Router-B

On files Menu will appear ROUTER-B.txtOn files Menu Router-A will appear ROUTER-B.txt

16

Page 17: Can We Configure VPN With Dynamic IP Public On The Both ...mum.mikrotik.com/presentations/TR14/arief.pdfSolution 1. Lease DNS services ( Dyndns, NoIP ) ( 25$/year ) on RouterOS Ver

Script Router-B (update)

:global currentTime;

{

:local a [/file get ROUTER-A.txt creation-time];

:if ($a !=$currentTime) do={:log info message="update ROUTER-A.txt";

:local b [/file get ROUTER-A.txt contents];

:local c [:len $b];

:local d [:pick $b 200 217];

:local e [:find $d "/"];

:local f [:pick $d 0 $e];

:set currentTime $a;

:put [/interface pptp-client set numbers=0 connect-to=$f];} else={:log info message="There is noUpdate From ROUTER-A.txt"};

}

17

Page 18: Can We Configure VPN With Dynamic IP Public On The Both ...mum.mikrotik.com/presentations/TR14/arief.pdfSolution 1. Lease DNS services ( Dyndns, NoIP ) ( 25$/year ) on RouterOS Ver

Script Router-B (check-IP)

:global currentIP;

{

:local d [/ip address get [find interface="ether2"] address];

:if ($d != $currentIP) do={:log info message=" IP Has change from $currentIP to $d";

:set currentIP $d;

:local a [/ip address print file=ROUTER-B where interface="ether2"];

:local b [/interface pptp-client get number=0 connect-to];

:put [/tool fetch address=$b src-path=ROUTER-B.txt dst-path=ROUTER-B.txt mode=ftp port=21 user=admin password=“” upload=yes keep-result=yes];} else={:log info message="IP Public is still Same"};

}

18

Page 19: Can We Configure VPN With Dynamic IP Public On The Both ...mum.mikrotik.com/presentations/TR14/arief.pdfSolution 1. Lease DNS services ( Dyndns, NoIP ) ( 25$/year ) on RouterOS Ver

ROUTER-B ( execute by schedule )

19

Page 20: Can We Configure VPN With Dynamic IP Public On The Both ...mum.mikrotik.com/presentations/TR14/arief.pdfSolution 1. Lease DNS services ( Dyndns, NoIP ) ( 25$/year ) on RouterOS Ver

Script ROUTER-A (Send IP)

Execute this script just once by manual ( without schedule )

20

Page 21: Can We Configure VPN With Dynamic IP Public On The Both ...mum.mikrotik.com/presentations/TR14/arief.pdfSolution 1. Lease DNS services ( Dyndns, NoIP ) ( 25$/year ) on RouterOS Ver

ROUTER-A• On files menu will appear ROUTER-A.txt , ROUTER-B.txt• On files menu ROUTER-B will appear ROUTER-A.txt, ROUTER-B.txt

21

Page 22: Can We Configure VPN With Dynamic IP Public On The Both ...mum.mikrotik.com/presentations/TR14/arief.pdfSolution 1. Lease DNS services ( Dyndns, NoIP ) ( 25$/year ) on RouterOS Ver

Script ROUTER-A (Check-IP)

:global currentIP;{:local a [/ip address get [find interface="ether2"] address];:if ($a != $currentIP) do={:log info message=" IP has change from $currentIP to $a";:local b [/file get ROUTER-B.txt contents];:local c [:len $b];:local d [:pick $b 200 217];:local e [:find $d "/"];:local f [:pick $d 0 $e];:local g [/ip address print file=ROUTER-A where interface=ether2];:local h [/tool fetch address=$f src-path=ROUTER-A.txt dst-path=ROUTER-A.txt mode=ftp port=21 user=admin password="" upload=yes];:set currentIP $a;:put ($g+$h);} else={:log info message="IP is still same"};}

22

Page 23: Can We Configure VPN With Dynamic IP Public On The Both ...mum.mikrotik.com/presentations/TR14/arief.pdfSolution 1. Lease DNS services ( Dyndns, NoIP ) ( 25$/year ) on RouterOS Ver

ROUTER-A ( execute by schedule )

23

Page 24: Can We Configure VPN With Dynamic IP Public On The Both ...mum.mikrotik.com/presentations/TR14/arief.pdfSolution 1. Lease DNS services ( Dyndns, NoIP ) ( 25$/year ) on RouterOS Ver

Security Issue• It’s dynamic IP, how can you mark the ftp connection only from

trusted connection ?- labeling the ftp connection just before it leave the router

by changing the dscp on mangle

24

Page 25: Can We Configure VPN With Dynamic IP Public On The Both ...mum.mikrotik.com/presentations/TR14/arief.pdfSolution 1. Lease DNS services ( Dyndns, NoIP ) ( 25$/year ) on RouterOS Ver

ROUTER-A ( mangle )

25

Page 26: Can We Configure VPN With Dynamic IP Public On The Both ...mum.mikrotik.com/presentations/TR14/arief.pdfSolution 1. Lease DNS services ( Dyndns, NoIP ) ( 25$/year ) on RouterOS Ver

ROUTER-B ( mangle )

26

Page 27: Can We Configure VPN With Dynamic IP Public On The Both ...mum.mikrotik.com/presentations/TR14/arief.pdfSolution 1. Lease DNS services ( Dyndns, NoIP ) ( 25$/year ) on RouterOS Ver

ROUTER-B ( Filter Rule )

27

Page 28: Can We Configure VPN With Dynamic IP Public On The Both ...mum.mikrotik.com/presentations/TR14/arief.pdfSolution 1. Lease DNS services ( Dyndns, NoIP ) ( 25$/year ) on RouterOS Ver

ROUTER-B ( Filter Rule )

28

Page 29: Can We Configure VPN With Dynamic IP Public On The Both ...mum.mikrotik.com/presentations/TR14/arief.pdfSolution 1. Lease DNS services ( Dyndns, NoIP ) ( 25$/year ) on RouterOS Ver

• Advantage Fast Respose

• Disadvantage Can only be call by the IP address If both of the router having a change of ip simultaneously, then

admin shall update the ip address by manual.

29

Page 30: Can We Configure VPN With Dynamic IP Public On The Both ...mum.mikrotik.com/presentations/TR14/arief.pdfSolution 1. Lease DNS services ( Dyndns, NoIP ) ( 25$/year ) on RouterOS Ver

Thank YouContact DetailMochamad Asnul Bahar AriefPT.UFOAKSE SUKSES LUARBIASATel : +62 7257577Email : [email protected] : [email protected] : www.ufoakses.co.id

30