PDA

Bekijk de volledige versie : Automatically Change PPPoe Connection



mndt
31-07-2007, 12:58
I want my router to use a diffrent username & pass between 3-7 am or simply switch WAN Interfaces.

I use a PPPoe connection To my adsl provider and at that special time the bandwidth is free.

I am sick and tired of changing connection through web interface (It's slow and dummy)

Are there any other ways of doing this?

or Any binary to install into router so that it does this automatically?

KGy
31-07-2007, 13:49
Hi and sorry my english.

If you use only adsl account (PPPoE, PPTP os , you can dial this script:



killall pppd >/dev/null 2>&1
pppd file /tmp/ppp/options.wan0 >/dev/null 2>&1


and disconnect

killall pppd >/dev/null 2>&1


If you use two adsl account, create two new file (/opt/etc/options.wan1 and /opt/etc/options.wan2) based on /tmp/ppp/options.wan0 (and change adsl account name and password).

You can change adsl connection, if you use two script:

/opt/dial_adsl1


killall pppd >/dev/null 2>&1
cp /opt/etc/options.wan1 /tmp/ppp/options.wan0
pppd file /tmp/ppp/options.wan0 >/dev/null 2>&1


/opt/dial_adsl2


killall pppd >/dev/null 2>&1
cp /opt/etc/options.wan2 /tmp/ppp/options.wan0
pppd file /tmp/ppp/options.wan0 >/dev/null 2>&1


and the changes you can automate with cron.
If hangup the line, the router can reconnect with adsl1 (or adsl2) definitions.

If your isp use a automatic_ip (dhcp) or L2TP, the router use "udhcpc" program to communicate with your isp (not dial up).
(use this command


udhcpc -i eth1 -p /var/run/udhcpc0.pid -s /tmp/udhcpc &
I don't know, whitch program can to connect/to disconnect the wan adapter (send a Connect/Disconnect signal to udhcpc), my isp support only pppoe connection. If your isp combine pppoe and dhcp type connection, you must set connection type in nvram (get info: nvram get wan_proto_t )
if pppoe: "PPPoE"
if dhcp: "Automatic IP"

If you use dhcp (or BigPond) connection, I find a tester for testing connect/disconnect function :)

George

mndt
14-08-2007, 13:54
Sorry for the delay.
As I'm a total newb i was trying to figure out.
Thank you. What you said works OK but there is no command as cron i can use in telnet.

Anyways, I came across an idea if i could only automate the router to somehow restore user settings from a file like the one we use in the web interface to backup settings and then reboot.

Are there any scripts to do that?

KGy
17-08-2007, 04:30
Hi and sorry my english.

0) install cron (or use busybox@crond (crond command)).
See tutorial (http://www.macsat.com/macsat/content/view/28/29/)



ipkg install cron



1) create wto adsl config file for pppd (based on /tmp/ppp/options.wan0)



cp /tmp/ppp/options.wan0 /opt/etc/options.wan1
cp /tmp/ppp/options.wan0 /opt/etc/options.wan2

and change adsl login parameter in files (.wan1 = adsl1:user/pass, .wan2 = adsl2:user/pass)

2) create wto script:

/opt/dial_adsl1


#!/bin/sh
killall pppd >/dev/null 2>&1
cp /opt/etc/options.wan1 /tmp/ppp/options.wan0
pppd file /tmp/ppp/options.wan0 >/dev/null 2>&1


/opt/dial_adsl2


#!/bin/sh
killall pppd >/dev/null 2>&1
cp /opt/etc/options.wan2 /tmp/ppp/options.wan0
pppd file /tmp/ppp/options.wan0 >/dev/null 2>&1


3) modify crontab (/opt/etc/crontab) file, when run dial_adsl(n) script.
(add two line-s and change time parameters (see macsat.com manual))
(this crontab run dial_adsl2 script at 03:00 AM, and run dial_adsl1 script at 07:00 am and the dial_adsl1 in main(master) internet connection (the dial_adsl2 is slave)...)



00 3 * * * admin run-parts /opt/dial_adsl2
00 7 * * * admin run-parts /opt/dial_adsl1


And dont't forget, these codes run on oleg fw (not on origial asus).

Bye, George