View Single Post
Old 10-09-2015, 20:54   #9533
alfonsor
Senior Member
 
Iscritto dal: Oct 2005
Messaggi: 7494
a parte tutto ciò che fa connettere la chiavetta usb, a proposito ho detto che c'è già tutto nel firmware, ma a dire il vero non so se c'è sul 2200V4

la maniera più semplice per fare il tutto è questa: quando la usb viene impostata come modem, apparirà un'interfaccia di vario nome, diciamo che sia usb0; siccome il 2200V4 si mette già come router, cambi il nome di eth4 (la wan) in quello che ti pare, cambi il nome di usb0 in eth4 e tutto funzionerà tranquillamente

sia sul 2200V3 che sul 4000, una volta fatto tutto ciò, basta scrivere semplicemente rc wan start; sul 2200V4 non so bene cosa si deve fare a questo punto a dire il vero perché non ci ho mai provato

lo script per il tethering del 2200V3 è questo
Codice:
#!/bin/sh

PATH=/usr/sbin
. /etc/amod/lib/func

#exec >/dev/pts/0
#exec >/dev/console

init() {
  # sanity check
  [ -e /var/amod/teth ] && exit 0

  # insert modules
  echo " * teth: inserting modules"
  insmod /lib/modules/drivers/net/mii.ko >/dev/null 2>&1
  insmod /lib/modules/drivers/net/usb/usbnet.ko >/dev/null 2>&1
  insmod /lib/modules/drivers/net/usb/cdc_ether.ko >/dev/null 2>&1
  insmod /lib/modules/drivers/net/usb/rndis_host.ko >/dev/null 2>&1

  # get group1 hwaddr
  echo " * teth: saving group1 hwaddr"
  ghwa=$(amodfunc ifhwaddr group1)
  [ "$ghwa" ] || {
    echo " * teth: can't obtain group1 hwa"
    exit 1
  }
  AMODSetVar group1HWAddr $ghwa

  # change eth3 name to eth5
  echo " * teth: changing eth3 name to eth5"
  ifconfig eth3 down
  brctl delif group1 eth3
  ifconfig eth3 hw ether 01:02:03:04:05:06
  nameif eth5 01:02:03:04:05:06
  ifconfig eth5 hw ether $ghwa

  brctl addif group1 eth5
  ifconfig eth5 up

  # run ifplugd on usb0
  echo " * teth: starting ifplugd on usb0"
  ifplugd -s -a -M -I -q -r /etc/amod/bin/teth -i usb0

  echo >/var/amod/teth
  echo " * teth: done"
  exit 0
}

deinit() {
  # sanity check
  [ -e /var/amod/teth ] || exit 0
  
  # remove ifplugd on usb0
  echo " * teth: removing ifplugd on usb0"
  ifplugd -i usb0 -k  >/dev/null 2>&1
  ifplugd -i eth3 -k  >/dev/null 2>&1

  usb0hw=$(AMODGetVar usb0HWAddr)
  [ "$usb0hw" ] && {
    eth3hwa=$(amodfunc ifhwaddr eth3)
    [ "$eth3hwa" = "$usb0hw" ] && {
      ifconfig eth3 down
      nameif usb3 $usb0hw
    }
    AMODDropVar usb0HWAddr
  }

  # get saved group1 hwaddr
  echo " * teth: getting saved group1 hwaddr"
  ghwa=$(AMODGetVar group1HWAddr)
  [ "$ghwa" ] && {
    # change eth5 name to eth3
    echo " * teth: changing eth5 name to eth3"
    ifconfig eth5 down
    brctl delif group1 eth5
    ifconfig eth5 hw ether 01:02:03:04:05:06
    nameif eth3 01:02:03:04:05:06
    ifconfig eth3 hw ether $ghwa
    brctl addif group1 eth3
    ifconfig eth3 up
    AMODDropVar group1HWAddr
  }

  # remove modules
  echo " * teth: removing modules"
  rmmod rndis_host >/dev/null 2>&1
  rmmod cdc_ether >/dev/null 2>&1
  rmmod usbnet >/dev/null 2>&1
  rmmod mii >/dev/null 2>&1

  rm /var/amod/teth
  echo " * teth: done"
  exit 0
}

usb0() {
  echo "usb0"
  dize /etc/amod/bin/teth start
  exit 0
}

eth3() {
  echo "eth3"
  dize /etc/amod/bin/teth stop
  exit 0
}


start() {
  echo "start"
  ifplugd -i usb0 -k  >/dev/null 2>&1

  # get usb0 hwaddr
  usb0hwa=$(amodfunc ifhwaddr usb0)
  [ "$usb0hwa" ] || exit 1

  AMODSetVar usb0HWAddr "$usb0hwa"
  
  # change usb0 name to eth3
  ifconfig usb0 down
  nameif eth3 $usb0hwa
  ifconfig eth3 up
  
  ifplugd -i usb0 -k
  ifplugd -s -a -M -I -p -q -r /etc/amod/bin/teth -i eth3
  
  # start wan
  rc wan start
  [ -x /etc/amod/conf/wan.user ] && dize /etc/amod/conf/wan.user "up"
  exit 0
} 

stop() {
  echo "stop"

  ifplugd -i eth3 -k
  ifplugd -s -a -M -I -q -r /etc/amod/bin/teth -i usb0

  rc wan stop
  [ -x /etc/amod/conf/wan.user ] && dize /etc/amod/conf/wan.user "down"
  exit 0
}

case "$1" in
    init) init;;
  deinit) deinit;;
    usb0) usb0;;
    eth3) eth3;;
   start) start;;
    stop) stop;;
       *) exit 1;;
esac
alfonsor è offline   Rispondi citando il messaggio o parte di esso