📜 ⬆️ ⬇️

We distribute 3G Internet throughout the apartment (Anydata ADU-300A and D-Link DIR-320)

The only opportunity I have at home to go online is to connect to a wireless CDMA Wellcom (a local analogue of SkyLink). And since there are several computers, it is advisable to distribute this very Wellcom to everyone, independently of each other. An excellent solution is to use a D-Link DIR-320 wi-fi router with a USB port, with an alternative firmware that allows you to connect a AnyData ADU-300A USB modem to it.

Theoretically, this question has already been repeatedly discussed in the vast expanses of the network, but I decided to reduce everything into one “instruction for the lazy.”


c:\> telnet 192.168.0.1
Login: admin
Password: admin

Further we exercise in the console of the Telnet session (better through copy / paste, so as not to be mistaken in writing). First we need to determine the vendor and product code for our modem. For each device they are unique. In an open telnet session, we give the command:

$tail -f /usr/tmp/syslog.log - we look at the system kernel logs in real time.
')
Now we insert the modem into the USB port of the router and watch what is happening. Something similar should appear on the screen:

Okt 29 05:02:09 kernel: hub.c: new USB device 00:03.0-1, assigned address 2
Okt 29 05:02:09 kernel: usb.c: USB device 2 (vend/prod 0x16d5/0x6506) is not claimed by any active driver.


We write down the parameters vendor and product. Exit by Ctrl-C.

Check the launch of the modem port:

$insmod usbserial vendor=0x16d5 product=0x6506 ( !)

$ls -l /dev/usb/*


That should appear on the screen like these lines:

crw------- 1 admin root 188, 0 Okt 29 2009 0
crw------- 1 admin root 188, 1 Okt 29 2009 1


Fine! We now have ports / dev / usb / tts / 0 and / dev / usb / tts / 1, of which we will need the first one - tts0.

Now we add scripts for dialing ppp connections:

Create the file / tmp / ppp / peers / dialup, but first the missing peers directory:

$mkdir /tmp/ppp/peers

Run the editor and use the usual "copy-paste":

$vi

In the vi editor, go to edit mode by pressing "i", and paste the code starting from the top left corner:

debug
/dev/usb/tts/0
115200
crtscts
noipdefault
ipcp-accept-local
lcp-echo-interval 60
lcp-echo-failure 5
usepeerdns
noauth
nodetach
mtu 1400
mru 1400
user 'cdma'
password 'cdma'
connect "/usr/sbin/chat -s -S -V -t 60 -f /tmp/ppp/dialup.chat 2 > /tmp/chat.log"


We press "Esc" and save to the file with the command

:w /tmp/ppp/peers/dialup

We leave from the editor

:q

To check, we can view the created file with the command:

$cat /tmp/ppp/peers/dialup

The result should be exactly the same as in the above lines:

debug
/dev/usb/tts/0
115200
crtscts
noipdefault
ipcp-accept-local
lcp-echo-interval 60
lcp-echo-failure 5
usepeerdns
noauth
nodetach
mtu 1400
mru 1400
user 'cdma'
password 'cdma'
connect "/usr/sbin/chat -s -S -V -t 60 -f /tmp/ppp/dialup.chat 2>/tmp/chat.log"


The following file /tmp/ppp/dialup.chat is similar to copy-paste:

$vi

'' ''
'' 'ATZ'
'OK' 'ATD #777'
'CONNECT' ''

Esc -> :w /tmp/ppp/dialup.chat -> :q

result:
$cat /tmp/ppp/dialup.chat

'' ''
'' 'ATZ'
'OK' 'ATD #777'
'CONNECT' ''


Add the created files to /tmp/local/.files with the commands:

$echo /tmp/ppp/peers/dialup > /tmp/local/.files
$echo /tmp/ppp/dialup.chat >> /tmp/local/.files


Stored in the memory of the router

$flashfs save && flashfs commit && flashfs enable

And we overload the router with the command:

$reboot

Now you can smoke, and at the same time and test the performance of the connection before the final stage. The dialer files have already been saved, you only need to manually start the modem port again.

$insmod usbserial vendor=0x16d5 product=0x6506

Now we can try to connect. Please note that in our dialup script the nodetach parameter is specified , so we will remain in the open session until you press Ctrl-C. Thus, it will be possible to see what happens in the process of dialing:

$pppd call dialup

After entering the command, something like this should happen in our Telnet terminal session:

Script /usr/sbin/chat -s -S -V -t 60 -f /tmp/ppp/dialup.chat 2>/tmp/chat.log finished (pid 162), status = 0x0
Serial connection established.
using channel 2
Using interface ppp0
Connect: ppp0 <--> /dev/usb/tts/0
............................................................
local IP address 10.50.29.187
remote IP address 10.50.29.148
primary DNS address 80.255.144.8
secondary DNS address 80.255.1.9
Script /tmp/ppp/ip-up started (pid 165)
Script /tmp/ppp/ip-up finished (pid 165), status = 0x0


Now you can open the browser, ask Google for something (or Yandex, to taste), go to your favorite site ... You can also check the connection speed via http://www.testinternet.ru/ or similar, to make sure that it does not lower than it was when connected directly to a computer.
To end the connection, go back to the telnet window and press Ctrl-C.

In order not to permanently register all these interesting and fascinating things every time the router is turned on, we will create a startup file for the modem port and the connection - / tmp / local / sbin / post-boot

$mkdir /tmp/local/sbin

Fill the startup file:

$vi

#!/bin/sh
insmod usbserial vendor=0x16d5 product=0x6506
sleep 5
pppd call dialup

Esc -> :w /tmp/local/sbin/post-boot -> :q


In order for our file to be executed by the system when it is loaded, we assign the execution attribute to it:

$chmod +x /tmp/local/sbin/post-boot

And do not forget to persist

$flashfs save && flashfs commit

All is ready! Reboot and try!

$reboot

To control the execution of commands, you can open a telnet session with the command:

$tail -f /usr/tmp/syslog.log

Enjoy the system!

Important!
The Vendor and Product codes in the article are for my modem! Do not forget to change them for your devices!

Source: https://habr.com/ru/post/78195/


All Articles