1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Start VPNserver with Client

Discussion in 'Tomato Firmware' started by breakena, Oct 29, 2017.

  1. breakena

    breakena New Member Member

    Hello all,
    I am a newbie and I just need to be pushed in the right direction .I need a script on a tomatoUSB that checks for the client connection then starts the VPN server service .I have placed this script in the scheduler of the server to run every minute.The below script doesnt work and i just need some assitance.

    1)Server is off
    2) The Client starts up
    3)The server sees the client up and then starts the Server service
    4)the client connects
    5The server shutsdown when the client is off

    Server
    #######################################
    ifconfig | grep tap0 > /dev/null
    t=$?
    if [ "$t" != 0 ]; then
    echo "$t"
    echo "no tap-device available"
    logger -t TAPTEST "no tap-device available"
    logger -t TAPTEST "$t"
    modprobe tun
    service vpnserver1 start
    logger -t TAPTEST "tap started"
    sleep 3
    fi
    ############################################

    This is my client configuration
    Client
    #######################################
    remote X.X.X.X
    port 1194
    dev tap
    secret staticvpn.key
    proto udp
    comp-lzo
    route-gateway X.X.X.X
    redirect-gateway def1
    float
    route-method exe
    route-delay 2
    ##############################################
     
  2. alfred

    alfred Addicted to LI Member

    A logical question, if the server is off, how can the off-line server see the client is up?
     
  3. breakena

    breakena New Member Member

    A script in the scheduler checks to see if the client is up then runs "service vpnserver1 start" this starts the server
     
  4. Rangaistus

    Rangaistus Network Newbie Member

    i don't understand what you're asking. when you say client is up, do you mean making a connection attempt?
    so you have a client, in say China, attempting to connect to the Server, say in Canada, and you want the server to be stopped until a connection attempt is made, at which point the server starts?

    if that is the case, you'll need to open a port in the firewall (the same port that the VPN server listens to), run a program that listens for incoming connection attempts, determine that it's a connection attempt from a legit client, then start the server and immediately quit, or stop listening on the port to avoid conflict.

    the vpn server does this already. the program you are looking for is the vpn server.
     

Share This Page