Difference between revisions of "OpenWRT: 3G modem"

From OnnoWiki
Jump to navigation Jump to search
Line 1: Line 1:
Use 3g/UMTS USB Dongle for WAN connection
 
FIXME: REDUNDANT with wired.wan.with.3g.dongle
 
 
 
This recipe explains how to setup and configure OpenWrt for using a USB 3g/UMTS-modem for WAN connection. You may want to checkout the multiwan package to use this simultaneously with other connections to the internet.
 
This recipe explains how to setup and configure OpenWrt for using a USB 3g/UMTS-modem for WAN connection. You may want to checkout the multiwan package to use this simultaneously with other connections to the internet.
  
Line 45: Line 42:
 
Check dmesg for:
 
Check dmesg for:
  
USB Serial support registered for generic
+
USB Serial support registered for generic
usbserial_generic 1-1:1.0: generic converter detected
+
usbserial_generic 1-1:1.0: generic converter detected
USB Serial support registered for generic
+
USB Serial support registered for generic
usbserial_generic 1-1:1.0: generic converter detected
+
usbserial_generic 1-1:1.0: generic converter detected
usb 1-1: generic converter now attached to ttyUSB0
+
usb 1-1: generic converter now attached to ttyUSB0
usbserial_generic 1-1:1.1: generic converter detected
+
usbserial_generic 1-1:1.1: generic converter detected
usb 1-1: generic converter now attached to ttyUSB1
+
usb 1-1: generic converter now attached to ttyUSB1
...
+
...
usbcore: registered new interface driver usbserial_generic
+
usbcore: registered new interface driver usbserial_generic
usbserial: USB Serial Driver core
+
usbserial: USB Serial Driver core
USB Serial support registered for GSM modem (1-port)
+
USB Serial support registered for GSM modem (1-port)
usbcore: registered new interface driver option
+
usbcore: registered new interface driver option
option: v0.7.2:USB Driver for GSM modems
+
option: v0.7.2:USB Driver for GSM modems
  
 
If above lines do not appear in dmesg, but instead you see something like:
 
If above lines do not appear in dmesg, but instead you see something like:
  
scsi1 : SCSI emulation for USB Mass Storage devices
+
scsi1 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 4
+
usb-storage: device found at 4
usb-storage: waiting for device to settle before scanning
+
usb-storage: waiting for device to settle before scanning
scsi 1:0:0:0: CD-ROM            Novatel  Mass Storage    2.31 PQ: 0 ANSI: 0
+
scsi 1:0:0:0: CD-ROM            Novatel  Mass Storage    2.31 PQ: 0 ANSI: 0
scsi 1:0:0:0: Attached scsi generic sg1 type 5
+
scsi 1:0:0:0: Attached scsi generic sg1 type 5
usb-storage: device scan complete
+
usb-storage: device scan complete
  
 
then, depending on your modem, you have to switch device mode (described below).
 
then, depending on your modem, you have to switch device mode (described below).
Line 72: Line 69:
 
If you still can't see usbserial_generic in dmesg, try loading the usbserial module (<vid> and <pid> are Vendor and Product ID of your device):
 
If you still can't see usbserial_generic in dmesg, try loading the usbserial module (<vid> and <pid> are Vendor and Product ID of your device):
  
rmmod usbserial #optional
+
rmmod usbserial #optional
insmod /lib/modules/`uname -r`/usbserial.ko vendor=0x<vid> product=0x<pid>
+
insmod /lib/modules/`uname -r`/usbserial.ko vendor=0x<vid> product=0x<pid>
  
 
Check dmesg again for:
 
Check dmesg again for:
  
usbcore: registered new interface driver usbserial
+
usbcore: registered new interface driver usbserial
USB Serial support registered for generic
+
USB Serial support registered for generic
usbserial_generic 1-1.3:1.0: generic converter detected
+
usbserial_generic 1-1.3:1.0: generic converter detected
usb 1-1.3: generic converter now attached to ttyUSB0
+
usb 1-1.3: generic converter now attached to ttyUSB0
usbserial_generic 1-1.3:1.1: generic converter detected
+
usbserial_generic 1-1.3:1.1: generic converter detected
usb 1-1.3: generic converter now attached to ttyUSB1
+
usb 1-1.3: generic converter now attached to ttyUSB1
usbcore: registered new interface driver usbserial_generic
+
usbcore: registered new interface driver usbserial_generic
usbserial: USB Serial Driver core
+
usbserial: USB Serial Driver core
  
 
switching USB mode
 
switching USB mode
Line 93: Line 90:
 
Now your USB Dongle should create logs in dmesg. If it doesn't, try
 
Now your USB Dongle should create logs in dmesg. If it doesn't, try
  
usb_modeswitch -c /etc/usb_modeswitch.d/<file>
+
usb_modeswitch -c /etc/usb_modeswitch.d/<file>
  
 
where <file> represents the modem's combined vendor/product id, e.g. 19d2:0083 for a ZTE MF190. Obviously, that file must exist in the forementioned directory.
 
where <file> represents the modem's combined vendor/product id, e.g. 19d2:0083 for a ZTE MF190. Obviously, that file must exist in the forementioned directory.
Line 104: Line 101:
 
Before you start, make note of your modem's vendor and product ID:
 
Before you start, make note of your modem's vendor and product ID:
  
# cat /proc/bus/usb/devices
+
# cat /proc/bus/usb/devices
...
+
...
P:  Vendor=1410 ProdID=5020 Rev= 0.00
+
P:  Vendor=1410 ProdID=5020 Rev= 0.00
S:  Manufacturer=Novatel Wireless, Inc.
+
S:  Manufacturer=Novatel Wireless, Inc.
...
+
...
  
 
First, find out your device address - in this example it's going to be sg0. Then issue the following:
 
First, find out your device address - in this example it's going to be sg0. Then issue the following:
  
sdparm --eject /dev/sg0
+
sdparm --eject /dev/sg0
  
 
Then, check for changes of your product ID:
 
Then, check for changes of your product ID:
  
# cat /proc/bus/usb/devices
+
# cat /proc/bus/usb/devices
...
+
...
P:  Vendor=1410 ProdID=7001 Rev= 0.00
+
P:  Vendor=1410 ProdID=7001 Rev= 0.00
S:  Manufacturer=Novatel Wireless, Inc.
+
S:  Manufacturer=Novatel Wireless, Inc.
S:  Product=Qualcomm Configuration
+
S:  Product=Qualcomm Configuration
...
+
...
I:* If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
+
I:* If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
...
+
...
  
 
Configuration
 
Configuration
Line 159: Line 156:
 
You can find it here '/etc/chatscripts/3g.chat', it looks like this:
 
You can find it here '/etc/chatscripts/3g.chat', it looks like this:
  
ABORT  BUSY
+
ABORT  BUSY
ABORT  'NO CARRIER'
+
ABORT  'NO CARRIER'
ABORT  ERROR
+
ABORT  ERROR
REPORT  CONNECT
+
REPORT  CONNECT
TIMEOUT 12
+
TIMEOUT 12
""      "AT&F"
+
""      "AT&F"
OK      "ATE1"
+
OK      "ATE1"
OK      'AT+CGDCONT=1,"IP","$USE_APN"'
+
OK      'AT+CGDCONT=1,"IP","$USE_APN"'
ABORT  'NO CARRIER'
+
ABORT  'NO CARRIER'
TIMEOUT 15
+
TIMEOUT 15
OK      "ATD*99***1#"
+
OK      "ATD*99***1#"
CONNECT ' '
+
CONNECT ' '
  
 
If your modem needs a special AT command, your can add it to this file.
 
If your modem needs a special AT command, your can add it to this file.
Line 176: Line 173:
 
For troubleshooting or locating the best position for the USB Dongle, you can add the AT command
 
For troubleshooting or locating the best position for the USB Dongle, you can add the AT command
  
""      "AT+CSQ"
+
""      "AT+CSQ"
  
 
to check signal quality. It returns the signal quality in RSSI (Received Signal Strength Indication) and in BER (Bit Error Rate, reported in percent).
 
to check signal quality. It returns the signal quality in RSSI (Received Signal Strength Indication) and in BER (Bit Error Rate, reported in percent).
Line 188: Line 185:
 
Looks like this in dmesg logread:
 
Looks like this in dmesg logread:
  
send (AT+CSQ^M)
+
send (AT+CSQ^M)
expect (OK)
+
expect (OK)
^M
+
^M
AT+CSQ^M^M
+
AT+CSQ^M^M
+CSQ: 11,99^M
+
+CSQ: 11,99^M
^M
+
^M
OK
+
OK
-- got it
+
-- got it
  
 
A more flexible way to check signal strength, but also network registration and SIM status is to run
 
A more flexible way to check signal strength, but also network registration and SIM status is to run
  
gcom
+
gcom
  
 
from the console, or if it returns a port-in-use error because your connection is already up,
 
from the console, or if it returns a port-in-use error because your connection is already up,
  
gcom -d /dev/ttyUSBx
+
gcom -d /dev/ttyUSBx
  
 
where x represents a port number not used by the wan connection itself.
 
where x represents a port number not used by the wan connection itself.
Line 213: Line 210:
 
Now check dmesg logread for successful connect:
 
Now check dmesg logread for successful connect:
  
pppd 2.4.4 started by root, uid 0
+
pppd 2.4.4 started by root, uid 0
abort on (BUSY)
+
abort on (BUSY)
abort on (ERROR)
+
abort on (ERROR)
report (CONNECT)
+
report (CONNECT)
timeout set to 12 seconds
+
timeout set to 12 seconds
send (AT&F^M)
+
send (AT&F^M)
expect (OK)
+
expect (OK)
AT&F^M^M
+
AT&F^M^M
OK
+
OK
 +
  -- got it
 +
send (ATE1^M)
 +
expect (OK)
 +
^M
 +
ATE1^M^M
 +
OK
 
  -- got it
 
  -- got it
send (ATE1^M)
+
send (AT+CGDCONT=1,"IP","your.apn"^M)
expect (OK)
+
abort on (NO CARRIER)
^M
+
timeout set to 15 seconds
ATE1^M^M
+
expect (OK)
OK
+
^M
 +
AT+CGDCONT=1,"IP","your.apn"^M^M
 +
OK
 
  -- got it
 
  -- got it
send (AT+CGDCONT=1,"IP","your.apn"^M)
+
  send (ATD*99***1#^M)
abort on (NO CARRIER)
+
expect (CONNECT)
timeout set to 15 seconds
+
^M
expect (OK)
+
ATD*99***1#^M^M
^M
+
CONNECT
AT+CGDCONT=1,"IP","your.apn"^M^M
+
  -- got it
OK
+
send ( ^M)
  -- got it
+
 
send (ATD*99***1#^M)
 
expect (CONNECT)
 
^M
 
ATD*99***1#^M^M
 
CONNECT
 
-- got it
 
send ( ^M)
 
 
Serial connection established.
 
Serial connection established.
 
Using interface 3g-wan
 
Using interface 3g-wan
Line 261: Line 259:
 
/etc/hotplug.d/iface/30-aiccu starts aiccu when the WAN connection is established. It seems however that, in the case of 3G connections, the start scripts are started just a bit too early and the start of aiccu fails. I have butchered the script a bit:
 
/etc/hotplug.d/iface/30-aiccu starts aiccu when the WAN connection is established. It seems however that, in the case of 3G connections, the start scripts are started just a bit too early and the start of aiccu fails. I have butchered the script a bit:
  
#!/bin/sh
+
#!/bin/sh  
 
+
[ "$ACTION" = "ifup" -a "$INTERFACE" = "wan" ] && /etc/init.d/aiccu enabled && sleep 15; /etc/init.d/aiccu restart
+
[ "$ACTION" = "ifup" -a "$INTERFACE" = "wan" ] && /etc/init.d/aiccu enabled && sleep 15; /etc/init.d/aiccu restart
  
 
Note that sixxs really frowns upon quick re-re-restarts of aiccu, it may get your account blocked for unjust use of resources. Be careful with these scripts.
 
Note that sixxs really frowns upon quick re-re-restarts of aiccu, it may get your account blocked for unjust use of resources. Be careful with these scripts.
Line 282: Line 280:
 
5. You need to configure interfaces. Ive configured first modem modifying existing Wan interface in "/etc/config/network":
 
5. You need to configure interfaces. Ive configured first modem modifying existing Wan interface in "/etc/config/network":
  
config 'interface' 'wan'
+
config 'interface' 'wan'  
option 'proto' '3g'
+
option 'proto' '3g'
option 'service' 'umts'
+
option 'service' 'umts'
option 'device' '/dev/ttyUSB0'
+
option 'device' '/dev/ttyUSB0'
option 'apn' 'internet'
+
option 'apn' 'internet'
option 'pincode' ''
+
option 'pincode' ''
option 'username' ''
+
option 'username' ''
option 'password' ''
+
option 'password' ''
  
 
Usually You need to provide APN name in "option 'apn' 'Name-Of-APN-HERE'". If Your sim card have PIN or need to use username or pass - put it respectively there. This should gives You working internet connection.
 
Usually You need to provide APN name in "option 'apn' 'Name-Of-APN-HERE'". If Your sim card have PIN or need to use username or pass - put it respectively there. This should gives You working internet connection.
Line 295: Line 293:
 
6. Check in log read next /ttyUSB[X] ports. In my case I have second modem starting with /ttyUSB3 (previous one use /ttyUSB0 to /ttyUSB2) so second interface looks like this:
 
6. Check in log read next /ttyUSB[X] ports. In my case I have second modem starting with /ttyUSB3 (previous one use /ttyUSB0 to /ttyUSB2) so second interface looks like this:
  
config 'interface' 'wan2'
+
config 'interface' 'wan2'
option 'proto' '3g'
+
option 'proto' '3g'
option 'service' 'umts'
+
option 'service' 'umts'
option 'maxwait' '0'
+
option 'maxwait' '0'
option 'device' '/dev/ttyUSB3'
+
option 'device' '/dev/ttyUSB3'
option 'apn' 'internet'
+
option 'apn' 'internet'
option 'pincode' ''
+
option 'pincode' ''
option 'username' ''
+
option 'username' ''
option 'password' ''
+
option 'password' ''
  
 
7. remember to add second interface to zone in firewall "/etc/config/firewall":
 
7. remember to add second interface to zone in firewall "/etc/config/firewall":
  
config 'zone'
+
config 'zone'
option 'name' 'wan'
+
option 'name' 'wan'
option 'input' 'REJECT'
+
option 'input' 'REJECT'
option 'output' 'ACCEPT'
+
option 'output' 'ACCEPT'
option 'forward' 'REJECT'
+
option 'forward' 'REJECT'
option 'masq' '1'
+
option 'masq' '1'
option 'mtu_fix' '1'
+
option 'mtu_fix' '1'
option 'network' 'wan wan2'
+
option 'network' 'wan wan2'
  
 
Look at last line - there is wan2 added.
 
Look at last line - there is wan2 added.
Line 331: Line 329:
 
Network (default route to 0 and peerdns to 0):
 
Network (default route to 0 and peerdns to 0):
  
config 'interface' 'loopback'
+
config 'interface' 'loopback'
option 'ifname' 'lo'
+
option 'ifname' 'lo'
option 'proto' 'static'
+
option 'proto' 'static'
option 'ipaddr' '127.0.0.1'
+
option 'ipaddr' '127.0.0.1'
option 'netmask' '255.0.0.0'
+
option 'netmask' '255.0.0.0'
  
config 'interface' 'lan'
+
config 'interface' 'lan'
option 'ifname' 'eth0.1'
+
option 'ifname' 'eth0.1'
option 'type' 'bridge'
+
option 'type' 'bridge'
option 'proto' 'static'
+
option 'proto' 'static'
option 'ipaddr' '192.168.1.1'
+
option 'ipaddr' '192.168.1.1'
option 'netmask' '255.255.255.0'
+
option 'netmask' '255.255.255.0'
 +
 +
config 'interface' 'wan'
 +
option 'proto' '3g'
 +
option 'service' 'umts'
 +
option 'device' '/dev/ttyUSB0'
 +
option 'apn' 'vpn'
 +
option 'pincode' ''
 +
option 'username' 'vpn'
 +
option 'password' 'vpn'
 +
option 'maxwait' '20'
 +
option 'defaultroute' '0'
  
config 'interface' 'wan'
+
config 'interface' 'wan2'
option 'proto' '3g'
+
option 'proto' '3g'
option 'service' 'umts'
+
option 'service' 'umts'
option 'device' '/dev/ttyUSB0'
+
option 'device' '/dev/ttyUSB3'
option 'apn' 'vpn'
+
option 'apn' 'erainternet'
option 'pincode' ''
+
option 'pincode' ''
option 'username' 'vpn'
+
option 'username' 'erainternet'
option 'password' 'vpn'
+
option 'password' 'erainternet'
option 'maxwait' '20'
+
option 'maxwait' '10'
option 'defaultroute' '0'
+
option 'defaultroute' '0'
  
config 'interface' 'wan2'
+
config 'switch'
option 'proto' '3g'
+
option 'name' 'rtl8366s'
option 'service' 'umts'
+
option 'reset' '1'
option 'device' '/dev/ttyUSB3'
+
option 'enable_vlan' '1'
option 'apn' 'erainternet'
+
option 'blinkrate' '2'
option 'pincode' ''
 
option 'username' 'erainternet'
 
option 'password' 'erainternet'
 
option 'maxwait' '10'
 
option 'defaultroute' '0'
 
  
config 'switch'
+
config 'switch_vlan'
option 'name' 'rtl8366s'
+
option 'device' 'rtl8366s'
option 'reset' '1'
+
option 'vlan' '1'
option 'enable_vlan' '1'
+
option 'ports' '0 1 2 3 5t'
option 'blinkrate' '2'
 
  
config 'switch_vlan'
+
config 'switch_port'
option 'device' 'rtl8366s'
+
option 'device' 'rtl8366s'
option 'vlan' '1'
+
option 'port' '1'
option 'ports' '0 1 2 3 5t'
+
option 'led' '6'
  
config 'switch_port'
+
config 'switch_port'
option 'device' 'rtl8366s'
+
option 'device' 'rtl8366s'
option 'port' '1'
+
option 'port' '2'
option 'led' '6'
+
option 'led' '9'
  
config 'switch_port'
+
config 'switch_port'
option 'device' 'rtl8366s'
+
option 'device' 'rtl8366s'
option 'port' '2'
+
option 'port' '5'
option 'led' '9'
+
option 'led' '2'
 
 
config 'switch_port'
 
option 'device' 'rtl8366s'
 
option 'port' '5'
 
option 'led' '2'
 
  
  
Line 396: Line 394:
 
Firewall - add second wan zones
 
Firewall - add second wan zones
  
config 'defaults'
+
config 'defaults'
option 'syn_flood' '1'
+
option 'syn_flood' '1'
option 'input' 'ACCEPT'
+
option 'input' 'ACCEPT'
option 'output' 'ACCEPT'
+
option 'output' 'ACCEPT'
option 'forward' 'REJECT'
+
option 'forward' 'REJECT'
option 'drop_invalid' '1'
+
option 'drop_invalid' '1'
  
config 'zone'
+
config 'zone'
option 'name' 'lan'
+
option 'name' 'lan'
option 'network' 'lan'
+
option 'network' 'lan'
option 'input' 'ACCEPT'
+
option 'input' 'ACCEPT'
option 'output' 'ACCEPT'
+
option 'output' 'ACCEPT'
option 'forward' 'REJECT'
+
option 'forward' 'REJECT'
  
config 'zone'
+
config 'zone'
option 'name' 'wan'
+
option 'name' 'wan'
option 'input' 'REJECT'
+
option 'input' 'REJECT'
option 'output' 'ACCEPT'
+
option 'output' 'ACCEPT'
option 'forward' 'REJECT'
+
option 'forward' 'REJECT'
option 'masq' '1'
+
option 'masq' '1'
option 'mtu_fix' '1'
+
option 'mtu_fix' '1'
option 'network' 'wan'
+
option 'network' 'wan'
 +
 +
config 'rule'
 +
option 'src' 'wan'
 +
option 'proto' 'udp'
 +
option 'dest_port' '68'
 +
option 'target' 'ACCEPT'
 +
option 'family' 'ipv4'
  
config 'rule'
+
config 'rule'
option 'src' 'wan'
+
option 'src' 'wan'
option 'proto' 'udp'
+
option 'proto' 'icmp'
option 'dest_port' '68'
+
option 'icmp_type' 'echo-request'
option 'target' 'ACCEPT'
+
option 'family' 'ipv4'
option 'family' 'ipv4'
+
option 'target' 'ACCEPT'
  
config 'rule'
+
config 'rule'
option 'src' 'wan'
+
option 'src' 'wan'
option 'proto' 'icmp'
+
option 'proto' 'icmp'
option 'icmp_type' 'echo-request'
+
list 'icmp_type' 'echo-request'
option 'family' 'ipv4'
+
list 'icmp_type' 'destination-unreachable'
option 'target' 'ACCEPT'
+
list 'icmp_type' 'packet-too-big'
 +
list 'icmp_type' 'time-exceeded'
 +
  list 'icmp_type' 'bad-header'
 +
list 'icmp_type' 'unknown-header-type'
 +
list 'icmp_type' 'router-solicitation'
 +
list 'icmp_type' 'neighbour-solicitation'
 +
option 'limit' '1000/sec'
 +
option 'family' 'ipv6'
 +
option 'target' 'ACCEPT'
  
config 'rule'
+
config 'rule'
option 'src' 'wan'
+
option 'src' 'wan'
option 'proto' 'icmp'
+
option 'dest' '*'
list 'icmp_type' 'echo-request'
+
option 'proto' 'icmp'
list 'icmp_type' 'destination-unreachable'
+
list 'icmp_type' 'echo-request'
list 'icmp_type' 'packet-too-big'
+
list 'icmp_type' 'destination-unreachable'
list 'icmp_type' 'time-exceeded'
+
list 'icmp_type' 'packet-too-big'
list 'icmp_type' 'bad-header'
+
list 'icmp_type' 'time-exceeded'
list 'icmp_type' 'unknown-header-type'
+
list 'icmp_type' 'bad-header'
list 'icmp_type' 'router-solicitation'
+
list 'icmp_type' 'unknown-header-type'
list 'icmp_type' 'neighbour-solicitation'
+
option 'limit' '1000/sec'
option 'limit' '1000/sec'
+
option 'family' 'ipv6'
option 'family' 'ipv6'
+
option 'target' 'ACCEPT'
option 'target' 'ACCEPT'
 
  
config 'rule'
+
config 'include'
option 'src' 'wan'
+
option 'path' '/etc/firewall.user'
option 'dest' '*'
+
option 'proto' 'icmp'
+
config 'forwarding'
list 'icmp_type' 'echo-request'
+
option 'dest' 'wan'
list 'icmp_type' 'destination-unreachable'
+
option 'src' 'lan'
list 'icmp_type' 'packet-too-big'
 
list 'icmp_type' 'time-exceeded'
 
list 'icmp_type' 'bad-header'
 
list 'icmp_type' 'unknown-header-type'
 
option 'limit' '1000/sec'
 
option 'family' 'ipv6'
 
option 'target' 'ACCEPT'
 
  
config 'include'
+
config 'rule'
option 'path' '/etc/firewall.user'
+
option 'target' 'ACCEPT'
  
config 'forwarding'
+
config 'zone'
option 'dest' 'wan'
+
option 'name' 'wan2'
option 'src' 'lan'
+
option 'forward' 'REJECT'
 +
option 'output' 'ACCEPT'
 +
option 'network' 'wan2'
 +
option 'input' 'REJECT'
 +
option 'masq' '1'
 +
option 'mtu_fix' '1'
  
config 'rule'
+
config 'forwarding'
option 'target' 'ACCEPT'
+
option 'dest' 'wan2'
 
+
option 'src' 'lan'
config 'zone'
 
option 'name' 'wan2'
 
option 'forward' 'REJECT'
 
option 'output' 'ACCEPT'
 
option 'network' 'wan2'
 
option 'input' 'REJECT'
 
option 'masq' '1'
 
option 'mtu_fix' '1'
 
 
 
config 'forwarding'
 
option 'dest' 'wan2'
 
option 'src' 'lan'
 
  
  
Line 492: Line 490:
  
  
config 'multiwan' 'config'
+
config 'multiwan' 'config'
option 'health_monitor' 'serial'
+
option 'health_monitor' 'serial'
option 'default_route' 'fastbalancer'
+
option 'default_route' 'fastbalancer'
option 'debug' '1'
+
option 'debug' '1'
  
config 'interface' 'wan'
+
config 'interface' 'wan'
option 'health_fail_retries' '3'
+
option 'health_fail_retries' '3'
option 'health_recovery_retries' '5'
+
option 'health_recovery_retries' '5'
option 'failover_to' 'fastbalancer'
+
option 'failover_to' 'fastbalancer'
option 'timeout' '10'
+
option 'timeout' '10'
option 'dns' '8.8.8.8 8.8.4.4'
+
option 'dns' '8.8.8.8 8.8.4.4'
option 'weight' '10'
+
option 'weight' '10'
option 'health_interval' '120'
+
option 'health_interval' '120'
option 'icmp_hosts' 'gateway'
+
option 'icmp_hosts' 'gateway'
  
config 'interface' 'wan2'
+
config 'interface' 'wan2'
option 'timeout' '3'
+
option 'timeout' '3'
option 'health_fail_retries' '3'
+
option 'health_fail_retries' '3'
option 'health_recovery_retries' '5'
+
option 'health_recovery_retries' '5'
option 'failover_to' 'fastbalancer'
+
option 'failover_to' 'fastbalancer'
option 'dns' '208.67.222.222 208.67.220.220'
+
option 'dns' '208.67.222.222 208.67.220.220'
option 'weight' '10'
+
option 'weight' '10'
option 'health_interval' '120'
+
option 'health_interval' '120'
option 'icmp_hosts' 'gateway'
+
option 'icmp_hosts' 'gateway'
  
config 'mwanfw'
+
config 'mwanfw'
option 'src' '192.168.1.150'
+
option 'src' '192.168.1.150'
option 'wanrule' 'wan2'
+
option 'wanrule' 'wan2'
 
+
config 'mwanfw'
+
config 'mwanfw'
option 'wanrule' 'fastbalancer'
+
option 'wanrule' 'fastbalancer'
  
  
Line 529: Line 527:
 
Create file
 
Create file
  
# touch /bin/tester.sh
+
# touch /bin/tester.sh
# chmod 755 /bin/tester.sh
+
# chmod 755 /bin/tester.sh
  
 
Put this into file:
 
Put this into file:
  
#!/bin/sh
+
#!/bin/sh
if ! ping -q -c 1 -W 10 -I 3g-wan 8.8.8.8 > /dev/null; then
+
if ! ping -q -c 1 -W 10 -I 3g-wan 8.8.8.8 > /dev/null; then
        (ifup wan; sleep 5; /etc/init.d/multiwan restart) &
+
        (ifup wan; sleep 5; /etc/init.d/multiwan restart) &
    fi
+
    fi
 
+
if ! ping -q -c 1 -W 10 -I 3g-wan2 8.8.8.8 > /dev/null; then
+
if ! ping -q -c 1 -W 10 -I 3g-wan2 8.8.8.8 > /dev/null; then
        (ifup wan2; sleep 5; /etc/init.d/multiwan restart) &
+
        (ifup wan2; sleep 5; /etc/init.d/multiwan restart) &
    fi
+
    fi
  
 
Create CRON:
 
Create CRON:
  
# /etc/init.d/cron stop
+
# /etc/init.d/cron stop
# echo "*/2 * * * * /bin/tester.sh" >> /etc/crontabs/root
+
# echo "*/2 * * * * /bin/tester.sh" >> /etc/crontabs/root
# /etc/init.d/cron enable
+
# /etc/init.d/cron enable
# /etc/init.d/cron start
+
# /etc/init.d/cron start
  
 
Script will ping through two wans: 3g-wan and 3g-wan2 and if not recieving ping restart interface respectively. Additionally, It will wait 5 sec and force restart multiwan as it seems restarting modem wasnt recognized by multiwan automatically and it wasnt add to routing table. Restart of multiwan should take care of this situation.
 
Script will ping through two wans: 3g-wan and 3g-wan2 and if not recieving ping restart interface respectively. Additionally, It will wait 5 sec and force restart multiwan as it seems restarting modem wasnt recognized by multiwan automatically and it wasnt add to routing table. Restart of multiwan should take care of this situation.
Line 554: Line 552:
 
Additionally in case of DSN being not visible by local clients put 'list 'dhcp_option' '6,208.67.222.222,208.67.220.220' More here: https://forum.openwrt.org/viewtopic.php?id=17316 ' code into etc/config/dhcp
 
Additionally in case of DSN being not visible by local clients put 'list 'dhcp_option' '6,208.67.222.222,208.67.220.220' More here: https://forum.openwrt.org/viewtopic.php?id=17316 ' code into etc/config/dhcp
  
config 'dnsmasq'
+
config 'dnsmasq'
option 'domainneeded' '1'
+
option 'domainneeded' '1'
option 'boguspriv' '1'
+
option 'boguspriv' '1'
option 'filterwin2k' '0'
+
option 'filterwin2k' '0'
option 'localise_queries' '1'
+
option 'localise_queries' '1'
option 'rebind_protection' '1'
+
option 'rebind_protection' '1'
option 'rebind_localhost' '1'
+
option 'rebind_localhost' '1'
option 'local' '/lan/'
+
option 'local' '/lan/'
option 'domain' 'lan'
+
option 'domain' 'lan'
option 'expandhosts' '1'
+
option 'expandhosts' '1'
option 'nonegcache' '0'
+
option 'nonegcache' '0'
option 'authoritative' '1'
+
option 'authoritative' '1'
option 'readethers' '1'
+
option 'readethers' '1'
option 'leasefile' '/tmp/dhcp.leases'
+
option 'leasefile' '/tmp/dhcp.leases'
option 'resolvfile' '/tmp/resolv.conf.auto'
+
option 'resolvfile' '/tmp/resolv.conf.auto'
  
config 'dhcp' 'lan'
+
config 'dhcp' 'lan'
option 'interface' 'lan'
+
option 'interface' 'lan'
option 'start' '100'
+
option 'start' '100'
option 'limit' '150'
+
option 'limit' '150'
option 'leasetime' '12h'
+
option 'leasetime' '12h'
list 'dhcp_option' '6,208.67.222.222,208.67.220.220'
+
list 'dhcp_option' '6,208.67.222.222,208.67.220.220'
  
config 'dhcp' 'wan'
+
config 'dhcp' 'wan'
option 'interface' 'wan'
+
option 'interface' 'wan'
option 'ignore' '1'
+
option 'ignore' '1'
  
  

Revision as of 08:02, 29 July 2012

This recipe explains how to setup and configure OpenWrt for using a USB 3g/UMTS-modem for WAN connection. You may want to checkout the multiwan package to use this simultaneously with other connections to the internet.

Please use OpenWrt 10.03.1-rc3 'Backfire' or newer image.

!: You are advised to inform yourself on how easily cellular mobile telephony can be intercepted. Remember this is a wireless connection. Also, some providers block certain ports: do not forget to inform yourself about that, too
!: If you've got a Huawei E367 (which will work), or a Huawei E585 (which does not currently work), you may want to read the following tutorial (which includes info on why you may not be able to get the on-board micro-SD card to function): http://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?t=836

Preparations Required Packages

First install required packages:

   comgt manpage for comgt
   Appropriate host controller interface for your USB hardware (precompiled images will most likely already contain the correct one)
       kmod-usb2 (aka EHCI)
       kmod-usb-ohci
       kmod-usb-uhci (for example VIA chips)
   Support for serial communication; needed to send control commands to the dongle and receive its responses.
   kmod-usb-serial, and
   kmod-usb-serial-option, and
   kmod-usb-serial-wwan, or
   kmod-usb-acm i.s.o. the last two, depending on dongle/phone hardware.
       kmod-usb-serial-option is not available for 2.4 kernel, install kmod-usb-serial and put a line equivalent to "usbserial vendor=0x12d1 product=0x1003 maxSize=2048" in /etc/modules.d/60-usb-serial)
   modeswitching tools, if your modem initially presents itself as a storage device - one of the following, depending on your modem:
       usb-modeswitch and usb-modeswitch-data (recommended) A mode switching tool for controlling "flip flop" (multiple device) USB gear.
       sdparm - utility to send SCSI commands (needed on Ovation MC935D)
   luci-proto-3g for proper support in luci in RC6 and later

Dependencies

If you are doing an offline installation, you might need some of these packages handy

   kmod-usb-core, already in 10.03 RC3 Image
   chat, dependency of comgt
   ppp, dependency of chat, already in 10.03 RC3 Image
   kmod-usb-serial, dependency of kmod-usb-serial-option

Installation

Now plug your USB Dongle to the USB port and restart the router.

Check dmesg for:

USB Serial support registered for generic
usbserial_generic 1-1:1.0: generic converter detected
USB Serial support registered for generic
usbserial_generic 1-1:1.0: generic converter detected
usb 1-1: generic converter now attached to ttyUSB0
usbserial_generic 1-1:1.1: generic converter detected
usb 1-1: generic converter now attached to ttyUSB1
...
usbcore: registered new interface driver usbserial_generic
usbserial: USB Serial Driver core
USB Serial support registered for GSM modem (1-port)
usbcore: registered new interface driver option
option: v0.7.2:USB Driver for GSM modems

If above lines do not appear in dmesg, but instead you see something like:

scsi1 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 4
usb-storage: waiting for device to settle before scanning
scsi 1:0:0:0: CD-ROM            Novatel  Mass Storage     2.31 PQ: 0 ANSI: 0
scsi 1:0:0:0: Attached scsi generic sg1 type 5
usb-storage: device scan complete

then, depending on your modem, you have to switch device mode (described below).

If you still can't see usbserial_generic in dmesg, try loading the usbserial module (<vid> and <pid> are Vendor and Product ID of your device):

rmmod usbserial #optional
insmod /lib/modules/`uname -r`/usbserial.ko vendor=0x<vid> product=0x<pid>

Check dmesg again for:

usbcore: registered new interface driver usbserial
USB Serial support registered for generic
usbserial_generic 1-1.3:1.0: generic converter detected
usb 1-1.3: generic converter now attached to ttyUSB0
usbserial_generic 1-1.3:1.1: generic converter detected
usb 1-1.3: generic converter now attached to ttyUSB1
usbcore: registered new interface driver usbserial_generic
usbserial: USB Serial Driver core

switching USB mode usb-modeswitch method

Install and use the usb-modeswitch and usb-modeswitch-data packages with the correct hardware ID's for your USB Dongle in order to switch the USB dongle from CDROM file system to Modem mode (→ flip flop). Read on here how to use this package.

Now your USB Dongle should create logs in dmesg. If it doesn't, try

usb_modeswitch -c /etc/usb_modeswitch.d/<file>

where <file> represents the modem's combined vendor/product id, e.g. 19d2:0083 for a ZTE MF190. Obviously, that file must exist in the forementioned directory.

If your device doesn't work with usb_modeswitch, try the sdparm method. sdparm method

This method uses sdparm to issue SCSI eject command to the emulated CDROM device. This is enough to put some modems into modem mode (tested on Ovation MC935D).

Before you start, make note of your modem's vendor and product ID:

# cat /proc/bus/usb/devices
...
P:  Vendor=1410 ProdID=5020 Rev= 0.00
S:  Manufacturer=Novatel Wireless, Inc.
...

First, find out your device address - in this example it's going to be sg0. Then issue the following:

sdparm --eject /dev/sg0

Then, check for changes of your product ID:

# cat /proc/bus/usb/devices
...
P:  Vendor=1410 ProdID=7001 Rev= 0.00
S:  Manufacturer=Novatel Wireless, Inc.
S:  Product=Qualcomm Configuration
...
I:* If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
...

Configuration

The shown configuration replaces the WAN line, so no further changes are needed to the firewall/other configuration. Note that if you also want to use the WAN port, you have to define it as WAN2 in the configuration. If you define the 3g connection as WAN2, you have to do more changes to other parts, like firewall and so on. Network configuration

Edit your '/etc/config/network' file: (see network 3G section for more details) config interface wan option ifname ppp0 option pincode 1234 option device /dev/ttyUSB0 option apn your.apn option service umts option proto 3g

Replace 'pincode' with the correct pincode of your SIM card. Note that an disabled pincode on the SIM card is problematic, please enable it. If you are connecting to a phone where the pincode has already been entered, there if no need for this.

Replace 'device' with the correct USB port of your modem. On a phone this might for example be /dev/ttyACM0.

Replace 'apn' with the correct APN of your 3g/umts provider.

Note in case your APN also requires an username/password, you can configure this too, just add to the network configuration file: option username yourusername option password yourpassword

Replace 'username' and 'password' with the correct username/password you received from your 3g provider.

For some providers, apperently it is neccessary to add 'noipdefault' to 'pppd_options'. If logread shows that the connection was established and CHAP authentication was successful, but the connection was immediately dropped after, then try:

      option 'pppd_options' 'noipdefault'

If your provider supports PAP authentication only then you need to disable all other protocols via these added options:

      option 'pppd_options' 'noipdefault refuse-chap refuse-mschap refuse-mschap-v2 refuse-eap' 

Now you have configured the network interface. Chat configuration

Now we need to check if the default chatscript does work with your 3g provider or not.

You can find it here '/etc/chatscripts/3g.chat', it looks like this:

ABORT   BUSY
ABORT   'NO CARRIER'
ABORT   ERROR
REPORT  CONNECT
TIMEOUT 12
""      "AT&F"
OK      "ATE1"
OK      'AT+CGDCONT=1,"IP","$USE_APN"'
ABORT   'NO CARRIER'
TIMEOUT 15
OK      "ATD*99***1#"
CONNECT ' '

If your modem needs a special AT command, your can add it to this file.

For troubleshooting or locating the best position for the USB Dongle, you can add the AT command

""      "AT+CSQ"

to check signal quality. It returns the signal quality in RSSI (Received Signal Strength Indication) and in BER (Bit Error Rate, reported in percent).

Lower rssi value is stronger signal, scale is from 0 to 99, were 99 means no signal. Values higher then 31 means real bad signal. :!: There is a misunderstanding of rssi in the sentence above. A higher rssi value represents a stronger signal, scale is from 0 to 99, where 1 is the lowest detectable signal and 31 a very good signal. Don't expect your signal to go all the way up to 99, though.

If BER returns 99 it means not known or not detectable.

Command return is "+CSQ: <rssi>,<ber>"

Looks like this in dmesg logread:

send (AT+CSQ^M)
expect (OK)
^M
AT+CSQ^M^M
+CSQ: 11,99^M
^M
OK
-- got it

A more flexible way to check signal strength, but also network registration and SIM status is to run

gcom

from the console, or if it returns a port-in-use error because your connection is already up,

gcom -d /dev/ttyUSBx

where x represents a port number not used by the wan connection itself.

Establishing connection

Just type on console 'ifup wan'

Now check dmesg logread for successful connect:

pppd 2.4.4 started by root, uid 0
abort on (BUSY)
abort on (ERROR)
report (CONNECT)
timeout set to 12 seconds
send (AT&F^M)
expect (OK)
AT&F^M^M
OK
 -- got it
send (ATE1^M)
expect (OK)
^M
ATE1^M^M
OK
-- got it
send (AT+CGDCONT=1,"IP","your.apn"^M)
abort on (NO CARRIER)
timeout set to 15 seconds
expect (OK)
^M
AT+CGDCONT=1,"IP","your.apn"^M^M
OK
-- got it
send (ATD*99***1#^M)
expect (CONNECT)
^M
ATD*99***1#^M^M
CONNECT
 -- got it
send ( ^M)

Serial connection established. Using interface 3g-wan Connect: 3g-wan <--> /dev/ttyUSB0 Could not determine remote IP address: defaulting to x.x.x.x local IP address x.x.x.x remote IP address x.x.x.x primary DNS address x.x.x.x secondary DNS address x.x.x.x adding wan (3g-wan) to firewall zone wan

That's it, now you should be connected.

If you want an permanent connect from startup, add 'ifup wan' command to '/etc/rc.local' file. AICCU interaction

/etc/hotplug.d/iface/30-aiccu starts aiccu when the WAN connection is established. It seems however that, in the case of 3G connections, the start scripts are started just a bit too early and the start of aiccu fails. I have butchered the script a bit:

#!/bin/sh 

[ "$ACTION" = "ifup" -a "$INTERFACE" = "wan" ] && /etc/init.d/aiccu enabled && sleep 15; /etc/init.d/aiccu restart

Note that sixxs really frowns upon quick re-re-restarts of aiccu, it may get your account blocked for unjust use of resources. Be careful with these scripts. Installing multiple 3G dongles

You can use many usb 3G dongles with easy using active USB hub.

We assume You have at least one 3g dongle configured and active and You have working internet connection. If not - You'll need to install modules for 3g support before going to connect any 3g dongle. Check http://wiki.openwrt.org/doc/recipes/3gdongle for more information.

1. Connect active USB hub to openWrt router. Check if hub power supply is big enough to power total count of 3g dongles. Roughly You'll need 500+ mAmp per one 3g dongle. Remember that modem can slightly exceed its declared power consumption in HDSPA+ modes. Be generous and pick USB hub with some power source overhead.

2. Connect all 3g dongles and start.

3. Browse through logread to check if modems are properly recognized and /ttyUSB ports are assigned.

4. Usually 3g modem have few ports - one for connection and others are service types. IE Huawei E1750 have 3 ports. First is communication port and last is service one. If You have only one modem it will be recognized as /ttyUSB0, /ttyUSB1 and /ttyUSB2. You need to configure interface using /ttyUSB0 (first one). Huawei E372 have 5 ports but similar to other Huawei communication port is the first one.

5. You need to configure interfaces. Ive configured first modem modifying existing Wan interface in "/etc/config/network":

config 'interface' 'wan' 
	option 'proto' '3g'
	option 'service' 'umts'
	option 'device' '/dev/ttyUSB0'
	option 'apn' 'internet'
	option 'pincode' 
	option 'username' 
	option 'password' 

Usually You need to provide APN name in "option 'apn' 'Name-Of-APN-HERE'". If Your sim card have PIN or need to use username or pass - put it respectively there. This should gives You working internet connection.

6. Check in log read next /ttyUSB[X] ports. In my case I have second modem starting with /ttyUSB3 (previous one use /ttyUSB0 to /ttyUSB2) so second interface looks like this:

config 'interface' 'wan2'
	option 'proto' '3g'
	option 'service' 'umts'
	option 'maxwait' '0'
	option 'device' '/dev/ttyUSB3'
	option 'apn' 'internet'
	option 'pincode' 
	option 'username' 
	option 'password' 

7. remember to add second interface to zone in firewall "/etc/config/firewall":

config 'zone'
	option 'name' 'wan'
	option 'input' 'REJECT'
	option 'output' 'ACCEPT'
	option 'forward' 'REJECT'
	option 'masq' '1'
	option 'mtu_fix' '1'
	option 'network' 'wan wan2'

Look at last line - there is wan2 added.

8. Now You have both interfaces configured and they should work.

9. You can use both interfaces as failover LOADBALANCER/ MULTIWAN

loadbalncer - https://forum.openwrt.org/viewtopic.php?id=23904

Note: It seems multiwan isnt perfectly suit for 3G modems in terms of stability. Modems dont reconnect automatically by HealthMonitor. Also after Mobem being manually restarted, multiwan dont use newly restarted interface until multiwan restart is restarted.

Configuration files for two 3G modems paired in multiwan:

Network (default route to 0 and peerdns to 0):

config 'interface' 'loopback'
	option 'ifname' 'lo'
	option 'proto' 'static'
	option 'ipaddr' '127.0.0.1'
	option 'netmask' '255.0.0.0'
config 'interface' 'lan'
	option 'ifname' 'eth0.1'
	option 'type' 'bridge'
	option 'proto' 'static'
	option 'ipaddr' '192.168.1.1'
	option 'netmask' '255.255.255.0'

config 'interface' 'wan'
	option 'proto' '3g'
	option 'service' 'umts'
	option 'device' '/dev/ttyUSB0'
	option 'apn' 'vpn'
	option 'pincode' 
	option 'username' 'vpn'
	option 'password' 'vpn'
	option 'maxwait' '20'
	option 'defaultroute' '0'
config 'interface' 'wan2'
	option 'proto' '3g'
	option 'service' 'umts'
	option 'device' '/dev/ttyUSB3'
	option 'apn' 'erainternet'
	option 'pincode' 
	option 'username' 'erainternet'
	option 'password' 'erainternet'
	option 'maxwait' '10'
	option 'defaultroute' '0'
config 'switch'
	option 'name' 'rtl8366s'
	option 'reset' '1'
	option 'enable_vlan' '1'
	option 'blinkrate' '2'
config 'switch_vlan'
	option 'device' 'rtl8366s'
	option 'vlan' '1'
	option 'ports' '0 1 2 3 5t'
config 'switch_port'
	option 'device' 'rtl8366s'
	option 'port' '1'
	option 'led' '6'
config 'switch_port'
	option 'device' 'rtl8366s'
	option 'port' '2'
	option 'led' '9'
config 'switch_port'
	option 'device' 'rtl8366s'
	option 'port' '5'
	option 'led' '2'


Firewall - add second wan zones

config 'defaults'
	option 'syn_flood' '1'
	option 'input' 'ACCEPT'
	option 'output' 'ACCEPT'
	option 'forward' 'REJECT'
	option 'drop_invalid' '1'
config 'zone'
	option 'name' 'lan'
	option 'network' 'lan'
	option 'input' 'ACCEPT'
	option 'output' 'ACCEPT'
	option 'forward' 'REJECT'
config 'zone'
	option 'name' 'wan'
	option 'input' 'REJECT'
	option 'output' 'ACCEPT'
	option 'forward' 'REJECT'
	option 'masq' '1'
	option 'mtu_fix' '1'
	option 'network' 'wan'

config 'rule'
	option 'src' 'wan'
	option 'proto' 'udp'
	option 'dest_port' '68'
	option 'target' 'ACCEPT'
	option 'family' 'ipv4'
config 'rule'
	option 'src' 'wan'
	option 'proto' 'icmp'
	option 'icmp_type' 'echo-request'
	option 'family' 'ipv4'
	option 'target' 'ACCEPT'
config 'rule'
	option 'src' 'wan'
	option 'proto' 'icmp'
	list 'icmp_type' 'echo-request'
	list 'icmp_type' 'destination-unreachable'
	list 'icmp_type' 'packet-too-big'
	list 'icmp_type' 'time-exceeded'
 	list 'icmp_type' 'bad-header'
	list 'icmp_type' 'unknown-header-type'
	list 'icmp_type' 'router-solicitation'
	list 'icmp_type' 'neighbour-solicitation'
	option 'limit' '1000/sec'
	option 'family' 'ipv6'
	option 'target' 'ACCEPT'
config 'rule'
	option 'src' 'wan'
	option 'dest' '*'
	option 'proto' 'icmp'
	list 'icmp_type' 'echo-request'
	list 'icmp_type' 'destination-unreachable'
	list 'icmp_type' 'packet-too-big'
	list 'icmp_type' 'time-exceeded'
	list 'icmp_type' 'bad-header'
	list 'icmp_type' 'unknown-header-type'
	option 'limit' '1000/sec'
	option 'family' 'ipv6'
	option 'target' 'ACCEPT'
config 'include'
	option 'path' '/etc/firewall.user'

config 'forwarding'
	option 'dest' 'wan'
	option 'src' 'lan'
config 'rule'
	option 'target' 'ACCEPT'
config 'zone'
	option 'name' 'wan2'
	option 'forward' 'REJECT'
	option 'output' 'ACCEPT'
	option 'network' 'wan2'
	option 'input' 'REJECT'
	option 'masq' '1'
	option 'mtu_fix' '1'
config 'forwarding'
	option 'dest' 'wan2'
	option 'src' 'lan'



Multiwan - Additionally add 'option 'health_monitor' 'serial at the beggining to help healthmonitor check for dropped ppp interface (Proposed by Jolouis).


config 'multiwan' 'config'
	option 'health_monitor' 'serial'
	option 'default_route' 'fastbalancer'
	option 'debug' '1'
config 'interface' 'wan'
	option 'health_fail_retries' '3'
	option 'health_recovery_retries' '5'
	option 'failover_to' 'fastbalancer'
	option 'timeout' '10'
	option 'dns' '8.8.8.8 8.8.4.4'
	option 'weight' '10'
	option 'health_interval' '120'
	option 'icmp_hosts' 'gateway'
config 'interface' 'wan2'
	option 'timeout' '3'
	option 'health_fail_retries' '3'
	option 'health_recovery_retries' '5'
	option 'failover_to' 'fastbalancer'
	option 'dns' '208.67.222.222 208.67.220.220'
	option 'weight' '10'
	option 'health_interval' '120'
	option 'icmp_hosts' 'gateway'
config 'mwanfw'
	option 'src' '192.168.1.150'
	option 'wanrule' 'wan2'

config 'mwanfw'
	option 'wanrule' 'fastbalancer'


I have issues with auro reconnecting modems so Ive modified script for checking if modems are up. Script check modems separately. Ive based this on great tutorial found at http://eko.one.pl/?p=openwrt-3g#automatycznyrestartpoczenia

Create file

# touch /bin/tester.sh
# chmod 755 /bin/tester.sh

Put this into file:

#!/bin/sh
if ! ping -q -c 1 -W 10 -I 3g-wan 8.8.8.8 > /dev/null; then
        (ifup wan; sleep 5; /etc/init.d/multiwan restart) &
    fi

if ! ping -q -c 1 -W 10 -I 3g-wan2 8.8.8.8 > /dev/null; then
        (ifup wan2; sleep 5; /etc/init.d/multiwan restart) &
    fi

Create CRON:

# /etc/init.d/cron stop
# echo "*/2 * * * * /bin/tester.sh" >> /etc/crontabs/root
# /etc/init.d/cron enable
# /etc/init.d/cron start

Script will ping through two wans: 3g-wan and 3g-wan2 and if not recieving ping restart interface respectively. Additionally, It will wait 5 sec and force restart multiwan as it seems restarting modem wasnt recognized by multiwan automatically and it wasnt add to routing table. Restart of multiwan should take care of this situation.

Additionally in case of DSN being not visible by local clients put 'list 'dhcp_option' '6,208.67.222.222,208.67.220.220' More here: https://forum.openwrt.org/viewtopic.php?id=17316 ' code into etc/config/dhcp

config 'dnsmasq'  
	option 'domainneeded' '1'
	option 'boguspriv' '1'
	option 'filterwin2k' '0'
	option 'localise_queries' '1'
	option 'rebind_protection' '1'
	option 'rebind_localhost' '1'
	option 'local' '/lan/'
	option 'domain' 'lan'
	option 'expandhosts' '1'
	option 'nonegcache' '0'
	option 'authoritative' '1'
	option 'readethers' '1'
	option 'leasefile' '/tmp/dhcp.leases'
	option 'resolvfile' '/tmp/resolv.conf.auto'
config 'dhcp' 'lan'
	option 'interface' 'lan'
	option 'start' '100'
	option 'limit' '150'
	option 'leasetime' '12h'
	list 'dhcp_option' '6,208.67.222.222,208.67.220.220'
config 'dhcp' 'wan'
	option 'interface' 'wan'
	option 'ignore' '1'


It could be made to work as described here in our Forum. Compile things yourself

If you want to build an own firmware containing support for a UMTS Modem, maybe this BuildHowTo will help you: Wireless router with a 3G dongle and multiwan for failover on Wired, Wireless client (routed) and 3G



Referensi

Pranala Menarik