Log in

Bekijk de volledige versie : Disconnect internet connection



hylman
14-04-2009, 13:49
I have asus wl-500gp v2 with oleg's firmware with Huawei 220 3G USB modem. I want to create a script so that the router will bring the internet connection up/down (toggle) everytime I press the reset button at the back of the router. I know that this has something to do with /usr/local/sbin/resetpressed, but I'm newbie in linux, so I don't have experience with script. Can somebody help me with this please?

Thanks,
Hylman

hylman
15-04-2009, 05:47
bump... anyone? or at least tell me the command line to stop internet connection. I tried "killall pppd", but after 20sec or so, it restarted again. I don't want this to happen. How could I achieve this?

Tamadite
16-04-2009, 22:25
try with iptables by dropping all traffic, e.g. to block

iptables -I FORWARD -j DROP

to unblock

iptables -D FORWARD 1

With this you block the WAN-LAN traffic but all WAN services in the router are still available.

hylman
17-04-2009, 01:40
Tamadite,

Thanks for your reply. For WAN-LAN traffic control, I used script I found while googling, which turn the radio on/off while pressing the EZ-setup button. I think this is enough in term of WAN-LAN traffic control, as I don't even bother to block the ethernet (cable) connection to my router.

But what I need is to completely disconnect my modem from internet, just as the "Disconnect" button does in the webif of Asus Oleg's firmware. This button works like magic, as it disconnect the modem, and pppd does not restart automagically after some 20s (which will happen if I do "killall pppd").

I've looked at the syslog.log of what happened when I presssed that "Disconnect" button from the webif, and the message said: "wan: disconnect manually" (or something like that.. I have no access to my router at the moment...)

Regards,
Hylman

hylman
17-04-2009, 09:53
Does anybody know what command the "connect" and "disconnect" buttons in the web interface run in the background? I can't trace it in either "dmesg" or "tail -f /tmp/syslog.log".

:confused:

hylman
18-04-2009, 01:00
Well, I found the culprit. It appears that I need to "killall dial" AND "killall pppd", otherwise if I only kill pppd, it will keep reconnect the internet.

I've modified the script I found from: http://wl500g.info/showthread.php?t=9604&highlight=ez-setup

Below is my /tmp/local/sbin/ez-setup script:



#!/bin/sh

WLAN=`wl isup`
if [ "$WLAN" = "0" ]; then
time=`/bin/date '+%b %e %H:%M:%S'`
echo "$time MANUALLY turning wireless and internet ON!" >> /tmp/syslog.log && wl radio on && /tmp/ppp/dial > /dev/null 2>&1 &
else
time=`/bin/date '+%b %e %H:%M:%S'`
echo "$time MANUALLY turning wireless and internet OFF!!" >> /tmp/syslog.log && wl radio off && killall dial && killall pppd
fi



This works like treat. But it would be perfect if the script detects the usb modem connection and disconnect it if it is connected, vice versa. It means that I need to replace the WLAN=`wl isup` with something for usb modem (or pppd status). Can anybody help me with this?

al37919
18-04-2009, 09:31
try to replace

[ "$WLAN" = "0" ]
with

[ -z `pidof pppd` ]

hylman
18-04-2009, 12:34
Thanks al37919.

Now it works as I expected. Considered this thread closed.

Regards,
Hylman