Objective: Configure a MangOH to route cellular internet data to/from other network interfaces. For example the image below shows how we will route traffic to/from the ethernet IoT slot to/from the cellular gateway.
Solution: To configure the MangOH to route data to/from network interfaces to/from the public cellular interface execute the following steps:
A. For wired interfaces, i.e. eth0 run the following steps:
-
Download the cfg_gateway.sh script to the MangOH device (also found under /scripts in the
MangOH GitHub) using the following:
scp ./scripts/cfg_gateway.sh root@192.168.2.2:/tmp/. -
ssh or console into the MangOH device.
ssh root@192.168.2.2 -
Move to the /tmp directory (or directory where the cfg_gateway.sh script was copied to above)
cd /tmp -
Run the cfg_gateway.sh script
./cfg_gateway.sh -
An example run of executing the script is shown below (note the default parameters are used):
david@sw-dclark:~/MTPublic4.3.0$ ssh root@192.168.2.2
root@swi-mdm9x28:~# cd /tmp
root@swi-mdm9x28:/tmp# chmod +x cfg_gateway.sh
root@swi-mdm9x28:/tmp# ./cfg_gateway.sh
MangOH gateway configuration
Enter WAN (cellular) interface (default: rmnet_data0):
WAN interface rmnet_data0
Enter LAN interface (default: eth0):
LAN interface eth0
Enter LAN IP (default: 192.168.20.1):
IP address (192.168.20.1)
Enter LAN Net Mask (default: 255.255.255.0):
net mask (255.255.255.0)
Mounting LAN interface ‘eth0’ IP: ‘192.168.20.1’, net mask: ‘255.255.255.0’
Check SIM inserted…
SIM card is inserted and unlocked (LE_SIM_READY).
Mounting the relay interface ‘rmnet_data0’…
Enabling the radio on ‘rmnet_data0’…
Radio power is already set to ON.
Enter APN (default: internet.sierrawireless.com):
Enabling the data connection on ‘rmnet_data0’ using APN ‘internet.sierrawireless.com’…
Setting up profile 1
Setting access point name … ok
Setting packet data protocol … ok
Setting Authentication … ok
Connecting … ok
Checking if device is up … ok
Routing … ok
Updating /etc/resolv.conf … ok
Updating /etc/resolv.conf … ok
Testing connection … Waiting for data connection on ‘rmnet_data0’…
Relay interface ‘rmnet_data0’ IP address is ‘100.71.221.227’
ok
Cleaning IP tables…
Enabling IP forwarding…
net.ipv4.ip_forward = 1
Configuring the NAT…
Configure DHCP server (Y/n): Y
Enter start IP (default: 192.168.20.10):
IP address (192.168.20.10)
Enter end IP (default: 192.168.20.100):
IP address (192.168.20.100)
Reconfiguring the DHCP server…
stopping DNS forwarder and DHCP server: dnsmasq… stopped /usr/bin/dnsmasq (pid 1196)
done.
Generating the configuration file ‘/tmp/dnsmasq.eth0.conf’ for the DHCP server…
Restarting the DHCP server…
starting DNS forwarder and DHCP server: dnsmasq… done.
MangOH gateway configuration completed
- You can verify that the interface is up with the given parameters using ifconfig as shown below:
root@swi-mdm9x28:/tmp# ifconfig eth0
eth0 Link encap:Ethernet HWaddr AE:BA:5B:62:58:29
inet addr:192.168.20.1 Bcast:192.168.20.255 Mask:255.255.255.0
inet6 addr: fe80::acba:5bff:fe62:5829/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:991 errors:0 dropped:0 overruns:0 frame:0
TX packets:1168 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:240898 (235.2 KiB) TX bytes:811303 (792.2 KiB)
B. For wireless interfaces, i.e. wlan0 (TI) or wlan1 (MT7692) run the following steps to configure a WiFi Access Point (AP):
- First follow the instructions for setting up the WiFi found on the MangOH Red Wiki (note that if the TI WiFi is used then the first 2 sections on this wiki can be skipped as they are required only for MediaTek7692 WiFi):
- Check if the WiFi AP web service is running using ‘app status’
root@swi-mdm9x28:/tmp# app status
[running] atAirVantage
[running] atQmiLinker
[running] atService
[running] audioService
[running] avcService
[running] cellNetService
[running] dataConnectionService
[running] fwupdateService
[running] gpioService
[running] modemService
[running] portService
[running] positioningService
[running] powerMgr
[running] secStore
[stopped] smsInboxService
[stopped] spiService
[stopped] tools
[stopped] voiceCallService
[stopped] wifi
[stopped] wifiApTest
[stopped] wifiClientTest
[running] wifiService
[stopped] wifiWebAp
-
If the WiFi AP web service is stopped then start the web service using ‘app start wifiWebAp’
-
From a web browser on a laptop/desktop PC connected to CF3 USB port on the MangOH goto the following local URL which can be used to configure the MangOH WiFi interface (wlan0, wlan1) as an AP:
http://192.168.2.2:8080/
Summary: The attached script which can also be found on the MangOH GitHub web site can be used to configure the MangOH as a gateway.
For example, when I tested the script I wanted to create a gateway between the ethernet IoT slot (eth0) and the cellular interface (rmnet_data0). After running the script I was able to connect my lap top to the ethernet port on the MangOH Red IoT slot and use the cellular interface (rmnet_data0) for internet access.
cfg_gateway.sh (8.3 KB)