Support Forum
The Forums are a place to find answers on a range of Fortinet products from peers and product experts.
Tim_Carter
New Contributor

Prevent VPN from connecting when inside the office

Hi folks,

 

I am using the Auto-connect feature with my FortiClient, but I find that the VPN still connects when I am in the office. Ideally, I want the VPN to auto-connect if there is no route available to the file server. If it can connect to the file server (either on the local LAN or through the site-to-site VPN from my other office) then the FortiClient shouldn't connect the VPN.

 

Any ideas how to achieve this?

 

Many thanks in advance for your help.

 

Tim.

1 REPLY 1
Tim_Carter
New Contributor

Hi folks,

FYI, I have written my own vbscript to do this which I'm happy to share.

Essentially, my solution was as follows:

[ul]
  • Create an internal DNS entry for vpn.customer.com on the LAN DNS pointing to 127.0.0.1. That way the VPN will fail to connect when in the office.
  • Use a script that runs every minute to detect whether the internal interface of the router is pingable.
  • If the router is not pingable, assume external and kill the scheduler.exe process. It instantly relaunches itself and the VPN tries to connect (because I have Auto Connect etc., ticked).
  • If the router is pingable, do nothing.[/ul]

    Script as follows:

     

    Dim host host = "10.0.0.1" Set WshShell = WScript.CreateObject("WScript.Shell") Ping = WshShell.Run("ping -n 1 " & host, 0, True) Select Case Ping Case 0   ' LAN is contactable, do nothing. Case 1   ' LAN is NOT contactable, restart scheduler.exe to connect VPN.   Dim oShell : Set oShell = CreateObject("WScript.Shell")   oShell.Run "%COMSPEC% /k taskkill /f /im scheduler.exe", 2, False End Select

     

    The only problem I have left is that killing the scheduler process leaves a FortiClient icon in the systray that doesn't disappear until you mouse over it. If anyone knows how to deal with that, let me know.

  • Announcements

    Select Forum Responses to become Knowledge Articles!

    Select the “Nominate to Knowledge Base” button to recommend a forum post to become a knowledge article.

    Labels
    Top Kudoed Authors