Advertisement
jms1

Mikrotik automatic VPN/dynamic DNS (first version)

Apr 5th, 2019
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. # Notes:
  2. # - "corpVPN" is the name of the "/interface ovpn-client" item which
  3. # "dials into" the corporate VPN server
  4. # - 10.0.0.4 and 10.0.0.5 are the internal DNS servers
  5. # - This works, but I ended up finding a cleaner way to do it.
  6.  
  7. /system script add name=vpn-up source={
  8. :local ifName [/interface get $interface name]
  9. :if ( $ifName = "corpVPN" ) do={
  10. :log info "VPN UP setting corp DNS"
  11. /ip dhcp-client set 0 use-peer-dns=no
  12. /ip dns set servers=10.0.0.4,10.0.0.5
  13. }
  14. }
  15.  
  16. /system script add name=vpn-down source={
  17. :local ifName [/interface get $interface name]
  18. :if ( $ifName = "corpVPN" ) do={
  19. :log info "VPN DOWN setting dynamic DNS"
  20. /ip dhcp-client set 0 use-peer-dns=yes
  21. /ip dns set servers=""
  22. }
  23. }
  24.  
  25. /system script add name=rebooted source={
  26. :log info "REBOOTED setting dynamic DNS"
  27. /ip dhcp-client set 0 use-peer-dns=yes
  28. /ip dns set servers=""
  29. }
  30.  
  31. /ppp profile set [find] on-up=vpn-up on-down=vpn-down
  32. /system scheduler add name=rebooted start-time=startup on-event=rebooted
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement