Auto IPsec tunnel on the router WRT-160

So I'm back:). Last time I promised to tell you how to automatically run at startup IPsecrouter, and in this short note, I'll do it.
In order to implement autostart tunnel, we need to create a startup init script for thisrecord to the file

/etc/init.d/racoon

The following text

#! /bin/sh /etc/rc.common

START=50
STOP=80
start() {
    echo "Starting racoon..."

   ifconfig eth1:0 b.b.b.b netmask 255.255.255.0

   if ! ( lsmod | grep -E "^af_key" > /dev/null ); then insmod af_key;fi
   if ! ( lsmod | grep -E "^esp4" > /dev/null ); then insmod esp4;fi
   if ! ( lsmod | grep -E "^ah4" > /dev/null ); then insmod ah4;fi
   if ! ( lsmod | grep -E "^xfrm4_tunnel" > /dev/null ); then insmod xfrm4_tunnel;fi
   if ! ( lsmod | grep -E "^authenc" > /dev/null ); then insmod authenc;fi
   if ! ( lsmod | grep -E "^xfrm4_mode_tunnel" > /dev/null ) then insmod xfrm4_mode_tunnel;fi
   if ! ( test -d "/var/racoon" ); then mkdir /var/racoon;fi

   racoon
   sleep 2
   setkey -f /etc/racoon/setkey.conf
   racoonctl vpn-connect A.A.A.A
   echo "Done."
}

stop() {
   echo "Stopping racoon..."

   racoonctl vpn-disconnect A.A.A.A
   pkill racoon

   echo "Done."
}

restart() {
   stop
   start
}

Где A.A.A.A -  the address of the server that connects to,

а  b.b.b.b - gateway to your internal network

Well, almost everything is left only to "insert " this script
# /etc/init.d/racoon enable

And run it

# /etc/init.d/racoon start
 

Now everything;)

English

Add new comment

anonimous_comment

  • Allowed HTML tags: <div><img><p><br><b><i><u>
  • Lines and paragraphs break automatically.
  • You may quote other posts using [quote] tags.

Plain text

  • No HTML tags allowed.
  • You may quote other posts using [quote] tags.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.