Wednesday, July 3, 2013

Keep your client bridge connected at all times

wireless client bridge
Here is a script that is useful if you have a wireless client bridge in your network. A wireless client is good to have within your network because it adds scalability and efficiency to your network. Nevertheless, in order for it to be reliable in the network; it has to be connected to your main router at all times. If you are experiencing a disconnection between your main router and your wireless client bridge often; you may want to add this script to your main router.

If you are running dd-wrt v24 presp2, you can add this script to your start up to ensure connection between your main router and your wireless client bridge.

In the main router's web GUI, navigate to Administration > Commands and copy and paste the following script in open text box. After you have edited the script to your wireless bridge's ip address click Save Startup



#!/bin/sh

# This script solves an intermitent problem on my
# NetGear WNDR3300 wireless N radio.  Every few
# hours,  the wireless N radio stops broadcasting
# and cannot be seen by wireless clients.  Bringing
# the wireless interface down and then back up
# resolves the issue.  This script pings a
# wireless client, in my case, a WET610N wireless
# bridge that should always remain up and only
# connects to the wireless N radio.  If the
# ping fails twice within a given time, it
# brings the interface down and then back up.

# A wireless client that should always be up
CLIENT_IP=192.168.1.2

# Wireless interface that disappears
INTERFACE=`nvram get wl0_ifname`

# seconds to wait after failed ping to try again
FAIL_AGAIN=10

# seconds between checks
CHECK_EVERY=60

# after cycling, wait this many seconds
AFTER_CYCLE=360

# Client must be up before starting main loop
while true
do
  if ping -c 1 ${CLIENT_IP} >/dev/null
  then
    echo "${CLIENT_UP} ok - begining main loop"
    break
  fi
done

# main script
while sleep ${CHECK_EVERY}
do
  if ping -c 1 ${CLIENT_IP} >/dev/null
  then
    echo "${CLIENT_IP} ok"
  else
    echo "${CLIENT_IP} dropped one"
    sleep ${FAIL_AGAIN}
    if ! ping -c 1 ${CLIENT_IP} >/dev/null
    then
      echo "${CLIENT_IP} dropped two, sending restarting ${INTERFACE}"
      # on Atheros hardware instead use: ifconfig ${INTERFACE} down
      wl -i ${INTERFACE} down
      sleep 3
      # on Atheros hardware instead use: ifconfig ${INTERFACE} up
      wl -i ${INTERFACE} up
      sleep ${AFTER_CYCLE}
    fi
  fi
done 2>&1
Note: Where it says CLIENT_IP, change the ip to that of your wireless client bridge.

Tags: ,

0 Responses to “Keep your client bridge connected at all times”

Post a Comment

Subscribe

Get the latest updates via inbox

Designed by noogenpix