Now heres a good hack:
- use a dialer that supports auto/re-connect pppd and wvdial are my best dialers since i am a *nix till i die so...
- create a bash/batch script calling reconnect
- use a fully connected system.... multiple modems
- use a fully connected system.... multiple modems that interchange after one disconnects to pick the other up,
- use a fully connected system.... multiple modems that interchange after one disconnects to pick the other up and changes the data/traffic route
- use a fully connected system.... multiple modems that interchange after one disconnects to pick the other up and changes the data route and also allows the data/traffic to be persistent on a specific device/modem....
We good? alright
I will show the following methods.
- Bash script to check what modem/device has highest speed(read connected)
- after that change route to currently connected modem (read highest speed)
- finally make sure the above connections can be used e.g to stream a video (very difficult...but not impossible)
Script:
as i said, i use wvdial alot so .... calling to modems with wvdial
sudo wvdialconf [sudo] password for taecode0h: Editing `/etc/wvdial.conf'. Scanning your serial ports for a modem. Modem Port Scan<*1>: S0 S1 S2 S3 ttyACM0<*1>: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud ttyACM0<*1>: ATQ0 V1 E1 -- failed with 9600 baud, next try: 115200 baud ttyACM0<*1>: ATQ0 V1 E1 -- and failed too at 115200, giving up. Sorry, no modem was detected! Is it in use by another program? Did you configure it properly with setserial? Please read the FAQ at http://alumnit.ca/wiki/?WvDial
this command checks for the modem on the system then after that writes it to the config fie that is /etc/wvdial.conf
now we can replicate the same config file as we will use the same settings as both modems are of the same company, with that said we will also be required to use a different serial port for the second modem depending on what it finds: .....
now we can replicate the same config file as we will use the same settings as both modems are of the same company, with that said we will also be required to use a different serial port for the second modem depending on what it finds: .....
taecode0h@r41nsec:~$ sudo wvdialconf Editing `/etc/wvdial.conf'. Scanning your serial ports for a modem. Modem Port Scan<*1>: S0 S1 S2 S3 ttyACM0<*1>: ATQ0 V1 E1 -- OK ttyACM0<*1>: ATQ0 V1 E1 Z -- OK ttyACM0<*1>: ATQ0 V1 E1 S0=0 -- OK ttyACM0<*1>: ATQ0 V1 E1 S0=0 &C1 -- OK ttyACM0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 -- OK ttyACM0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK ttyACM0<*1>: Modem Identifier: ATI -- MF192-T-1.0.0 ttyACM0<*1>: Speed 4800: AT -- OK ttyACM0<*1>: Speed 9600: AT -- OK ttyACM0<*1>: Speed 19200: AT -- OK ttyACM0<*1>: Speed 38400: AT -- OK ttyACM0<*1>: Speed 57600: AT -- OK ttyACM0<*1>: Speed 115200: AT -- OK ttyACM0<*1>: Speed 230400: AT -- OK ttyACM0<*1>: Speed 460800: AT -- OK ttyACM0<*1>: Max speed is 460800; that should be safe. ttyACM0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK ttyACM1<*1>: ATQ0 V1 E1 -- OK ttyACM1<*1>: ATQ0 V1 E1 Z -- OK ttyACM1<*1>: ATQ0 V1 E1 S0=0 -- OK ttyACM1<*1>: ATQ0 V1 E1 S0=0 &C1 -- OK ttyACM1<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 -- OK ttyACM1<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK ttyACM1<*1>: Modem Identifier: ATI -- MF192-T-1.0.0 ttyACM1<*1>: Speed 4800: AT -- OK ttyACM1<*1>: Speed 9600: AT -- OK ttyACM1<*1>: Speed 19200: AT -- OK ttyACM1<*1>: Speed 38400: AT -- OK ttyACM1<*1>: Speed 57600: AT -- OK ttyACM1<*1>: Speed 115200: AT -- OK ttyACM1<*1>: Speed 230400: AT -- OK ttyACM1<*1>: Speed 460800: AT -- OK ttyACM1<*1>: Max speed is 460800; that should be safe. ttyACM1<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK ttyACM2<*1>: ATQ0 V1 E1 -- OK ttyACM2<*1>: ATQ0 V1 E1 Z -- OK ttyACM2<*1>: ATQ0 V1 E1 S0=0 -- OK ttyACM2<*1>: ATQ0 V1 E1 S0=0 &C1 -- OK ttyACM2<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 -- OK ttyACM2<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK ttyACM2<*1>: Modem Identifier: ATI -- MF192-T-1.0.0 ttyACM2<*1>: Speed 4800: AT -- OK ttyACM2<*1>: Speed 9600: AT -- OK ttyACM2<*1>: Speed 19200: AT -- OK ttyACM2<*1>: Speed 38400: AT -- OK ttyACM2<*1>: Speed 57600: AT -- OK ttyACM2<*1>: Speed 115200: AT -- OK ttyACM2<*1>: Speed 230400: AT -- OK ttyACM2<*1>: Speed 460800: AT -- OK ttyACM2<*1>: Max speed is 460800; that should be safe. ttyACM2<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK ttyUSB0<*1>: ATQ0 V1 E1 -- OK ttyUSB0<*1>: ATQ0 V1 E1 Z -- OK ttyUSB0<*1>: ATQ0 V1 E1 S0=0 -- OK ttyUSB0<*1>: ATQ0 V1 E1 S0=0 &C1 -- OK ttyUSB0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 -- OK ttyUSB0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK ttyUSB0<*1>: Modem Identifier: ATI -- Manufacturer: +GMI: HUAWEI TECHNOLOGIES CO., LTD ttyUSB0<*1>: Speed 9600: AT -- OK ttyUSB0<*1>: Max speed is 9600; that should be safe. ttyUSB0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK ttyUSB1<*1>: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud ttyUSB1<*1>: ATQ0 V1 E1 -- failed with 9600 baud, next try: 9600 baud ttyUSB1<*1>: ATQ0 V1 E1 -- and failed too at 115200, giving up. ttyUSB2<*1>: ATQ0 V1 E1 -- OK ttyUSB2<*1>: ATQ0 V1 E1 Z -- OK ttyUSB2<*1>: ATQ0 V1 E1 S0=0 -- OK ttyUSB2<*1>: ATQ0 V1 E1 S0=0 &C1 -- OK ttyUSB2<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 -- OK ttyUSB2<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK ttyUSB2<*1>: Modem Identifier: ATI -- Manufacturer: +GMI: HUAWEI TECHNOLOGIES CO., LTD ttyUSB2<*1>: Speed 9600: AT -- OK ttyUSB2<*1>: Max speed is 9600; that should be safe. ttyUSB2<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK Found an USB modem on /dev/ttyACM0. Modem configuration written to /etc/wvdial.conf. ttyACM0<Info>: Speed 460800; init "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0" ttyACM1<Info>: Speed 460800; init "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0" ttyACM2<Info>: Speed 460800; init "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0" ttyUSB0<Info>: Speed 9600; init "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0" ttyUSB2<Info>: Speed 9600; init "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"
As you can see it did find two modems .... forget the part u see the mf-192 its a GSM type i was using to illustrate this, again it only shows one was found but clearly two have according to the terminal one one ttyUSB0 and on ttyACM0 with that said...
leego... save another config file /etc/wvdial2.conf edit the required parts and finally set it out to roll,
now the script.
modem_route=$( for iface in `ifconfig -a | grep ppp | awk '{print $1; }'`; do echo $iface = `ping -I $iface -c 1 -q 8.8.8.8 | grep avg | awk -F/ '{print $5;}'` done | sort -k 3 -rn | head -n 1 ) logger "Setting new route from candidate: $modem_route" ip route del default ip route add default dev `echo $modem_route | awk '{print $1;}'`
now this pings google dns server to check speed and also disconnection depending on the ping TTL and also changes the route between the two modem routes as you can see on the last two lines.
now next thing is to dial both modems.... this is done with the following command
sudo wvdial -C /etc/wvdial.conf
calls first^ modem
sudo wvdial -C /etc/wvdial2.conf
calls second^ modem
oww run a cron job to call the script every- i dont know people say cron jobs cant run every second but hey... people also say hacking is hard :)
with that said... more configurations can be done to induct a smoother flow on the internet like streaming media and also on allowing media required to pass on a specific device to be as such unchanged :)
do i need to go deeper than this sure... but come on should i do all this for you?
if yes ... wait for it... THIS IS FOR EDUCATIONAL PURPOSES ONLY how to configure routes.
sorta looks like this now huh
sorta looks like this now huh
________ +------------+ / | | | +-------------+ Modem 1 +------- __ | | | / ___/ \_ +------+-------+ +------------+ | _/ \__ | if1 | / / \ | | | |YoBox -----+ Script | |Internet \_ __/ | | | \__ __/ | if2 | \ \___/ +------+-------+ +------------+ | | | | \ +-------------+ Modem 2 +------- | | | +------------+ \________
No comments:
Post a Comment