Sunday, June 29, 2014

3G Backup on Mikrotik

I was playing with my Mikrotik at home (RB951G-2HnD) trying to learn more stuff and though I should put of some use to my 3G USB dongle (HUAWEI E220). This came in handy as next day my main connection had problems and needed a backup connection to the Internet.


Plug the 3G USB dongle and check on Mikrotik using the CLI commands "system resource usb print". If it can recognize the 3G modem then you are ok .See the command output below :


There should be a default ppp-out1 client, as shown above, that needs some parameters changed in order to establish a session. These are APN and PIN .


Adding NAT using command below :
 /ip firewall nat add action=masquerade chain=srcnat comment="ppp-out1" disabled=no out-interface=ppp-out1 to-addresses=


If both uplinks are up,  that is WAN ( ether1) on DSL modem and ppp-out1, it will go through DSL because of lower distance. Shutting down ether1, traffic goes through 3G connection. 


Reset USB Power
There is a feature on Mikrotiks that resets USB power and turns off USB port power for specified time.  It is useful when a 3G modem needs to be restarted. The command below will reset the port for 10 seconds.
 /system routerboard usb power-reset duration=10 ;  

Send and Receive SMS
Use he tool sms command to send SMS message to a mobile number.
  /tool sms send usb1 channel=1 phone-number=<mobile number> message="Hello!!!";   
and read any receive SMS by the 3G modem using the following commad. 
First we must enable receiving SMSs and then we can see total number of messages received.
 /tool sms set receive-enabled=yes port=usb1 channel=1  secret=****

Using "port print" you can see all available port and how they are used 

You can read the exact messages by issuing the command "/tool sms inbox print".


Andreas Schiemann said...

Would one be able to send commands to the RB951 by means of sms? If the data connection drops, as these are 2 different protocols?

Stelios Agapiou said...

Hi Andreas,
haven't try it but according to documentation it is possible to send SMS messages to a Mikrotik and can exectue scripts, and even respond to the sender.