# Setting up MangOH Red as Router to Cellular Gateway

**URL:** <https://mangoh.discourse.group/t/setting-up-mangoh-red-as-router-to-cellular-gateway/1241>\
**Category:** Wiki\
**Created:** [March 14, 2018, 4:35pm UTC](https://mangoh.discourse.group/t/setting-up-mangoh-red-as-router-to-cellular-gateway/1241 "2018-03-14T16:35:51Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![dclark75](https://avatars.discourse-cdn.com/v4/letter/d/a8b319/32.png) [@dclark75](https://mangoh.discourse.group/u/dclark75)\
**Post date:** [March 14, 2018, 4:35pm UTC](https://mangoh.discourse.group/t/setting-up-mangoh-red-as-router-to-cellular-gateway/1241/1 "2018-03-14T16:35:51Z")

</div>

**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.

 ![IMG_2399](https://us1.discourse-cdn.com/flex016/uploads/mangoh/original/1X/b296e8e445e329438cc0bb56f9a382e684d04a56.jpg)

**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:**

1. 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](mailto:root@192.168.2.2):/tmp/.

2. ssh or console into the MangOH device.  
ssh [root@192.168.2.2](mailto:root@192.168.2.2)

3. Move to the /tmp directory (or directory where the cfg\_gateway.sh script was copied to above)  
cd /tmp

4. Run the cfg\_gateway.sh script  
./cfg\_gateway.sh

5. 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](mailto: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](http://internet.sierrawireless.com)):  
Enabling the data connection on ‘rmnet\_data0’ using APN ‘[internet.sierrawireless.com](http://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

1. 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):**

1. 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):

> **[mangOH/mangOH](https://github.com/mangOH/mangOH/wiki/mangOH-Red-mt7697-WiFi)**
>
> Primary mangOH git repository. Contribute to mangOH/mangOH development by creating an account on GitHub.

1. 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

1. If the WiFi AP web service is stopped then start the web service using ‘app start wifiWebAp’

2. 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/](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](https://mangoh.discourse.group/uploads/short-url/dHJQ8Tz33YyzUYh3U4hVlCwGuC2.sh) (8.3 KB)

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/nick/32/1380_2.png) [@nick](https://mangoh.discourse.group/u/nick)\
**Post date:** [March 14, 2018, 9:45pm UTC](https://mangoh.discourse.group/t/setting-up-mangoh-red-as-router-to-cellular-gateway/1241/2 "2018-03-14T21:45:33Z")

</div>

Cool use case and tutorial 🔥👏🏼. Thanks for sharing @dclark75.

---

<div class="post-metadata">

**Author:** ![dingo](https://avatars.discourse-cdn.com/v4/letter/d/c2a13f/32.png) [@dingo](https://mangoh.discourse.group/u/dingo)\
**Post date:** [March 15, 2018, 10:31am UTC](https://mangoh.discourse.group/t/setting-up-mangoh-red-as-router-to-cellular-gateway/1241/3 "2018-03-15T10:31:12Z")

</div>

HOWTO Guide or WIKI candidate for sure

---

<div class="post-metadata">

**Author:** ![christopheradams1](https://avatars.discourse-cdn.com/v4/letter/c/e68b1a/32.png) [@christopheradams1](https://mangoh.discourse.group/u/christopheradams1)\
**Post date:** [August 11, 2020, 2:45pm UTC](https://mangoh.discourse.group/t/setting-up-mangoh-red-as-router-to-cellular-gateway/1241/5 "2020-08-11T14:45:16Z")

</div>

After typing in step 1:  
root@swi-mdm9x28-wp:~# scp ./scripts/cfg\_gateway.sh [root@192.168.2.2](mailto:root@192.168.2.2):/tmp/

I get an error message

Host ‘192.168.2.2’ is not in the trusted hosts file.  
(ssh-rsa fingerprint md5 90:43:bc:3c:49:99:d8:f4:a0:b0:45:cd"d6:d4:d0:be)  
Do you want to continue connecting? (y/n) y  
./scripts/cfg\_gateway.sh: No such file or directory

However the cfg\_gateway.sh file is in the directory Home/mangOH/scripts and there it is cfg\_gateway.sh

Can you please help me fix this problem?

---

<div class="post-metadata">

**Author:** ![christopheradams1](https://avatars.discourse-cdn.com/v4/letter/c/e68b1a/32.png) [@christopheradams1](https://mangoh.discourse.group/u/christopheradams1)\
**Post date:** [August 17, 2020, 5:39pm UTC](https://mangoh.discourse.group/t/setting-up-mangoh-red-as-router-to-cellular-gateway/1241/6 "2020-08-17T17:39:18Z")

</div>

Is there a way to check what devices are connected to the ethernet card? Like seeing their ip address? does the mangoh red assign ip address to connected devices when it is configured as a router?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [August 17, 2020, 10:29pm UTC](https://mangoh.discourse.group/t/setting-up-mangoh-red-as-router-to-cellular-gateway/1241/7 "2020-08-17T22:29:16Z")

</div>

Seems these lines are used to config the assigned ip address

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):

---

<div class="post-metadata">

**Author:** ![christopheradams1](https://avatars.discourse-cdn.com/v4/letter/c/e68b1a/32.png) [@christopheradams1](https://mangoh.discourse.group/u/christopheradams1)\
**Post date:** [August 18, 2020, 1:25am UTC](https://mangoh.discourse.group/t/setting-up-mangoh-red-as-router-to-cellular-gateway/1241/8 "2020-08-18T01:25:10Z")

</div>

Thanks for the help and okay, so if my raspberry pi’s IP address is 192.168.1.141, and mangoh reds default IP address is 192.168.20.1 and I wanted to send data via ethernet from raspberry pi to mangoh red would I configure that section as so?:

Configure DHCP server (Y/n): Y  
Enter start IP (default: 192.168.20.10): 192.168.1.141  
Enter end IP (default: 192.168.20.100): 192.168.20.1

?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [August 18, 2020, 1:35am UTC](https://mangoh.discourse.group/t/setting-up-mangoh-red-as-router-to-cellular-gateway/1241/9 "2020-08-18T01:35:19Z")

</div>

I suggest you using the default one:192.168.20.10  
In this case, I believe the raspberry pi will have Ip address 192.168.20.10

---

<div class="post-metadata">

**Author:** ![christopheradams1](https://avatars.discourse-cdn.com/v4/letter/c/e68b1a/32.png) [@christopheradams1](https://mangoh.discourse.group/u/christopheradams1)\
**Post date:** [August 18, 2020, 2:19am UTC](https://mangoh.discourse.group/t/setting-up-mangoh-red-as-router-to-cellular-gateway/1241/10 "2020-08-18T02:19:19Z")

</div>

@jyijyi Okay, however now I have a complete issue that happened out of nowhere. After re-running ./cfg\_gateway.sh in mangoh red I made the changes and exited the ssh connection. I then tried to re-enter mangoh red by ssh [root@192.168.2.2](mailto:root@192.168.2.2) and it is saying destination host is unreachable. I then tried to ping it and 100% of the packets were never received. This is frustrating because I did absolutely nothing.

Do you know how to get back into mangoh red via ssh, this is crazy???

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [August 18, 2020, 2:22am UTC](https://mangoh.discourse.group/t/setting-up-mangoh-red-as-router-to-cellular-gateway/1241/11 "2020-08-18T02:22:58Z")

</div>

does it work after reboot?

I remember I need to add “iptables -I INPUT -j ACCEPT” after "iptables --flush " in the script, otherewise it cannot SSH via ECM.

---

<div class="post-metadata">

**Author:** ![christopheradams1](https://avatars.discourse-cdn.com/v4/letter/c/e68b1a/32.png) [@christopheradams1](https://mangoh.discourse.group/u/christopheradams1)\
**Post date:** [August 18, 2020, 2:37am UTC](https://mangoh.discourse.group/t/setting-up-mangoh-red-as-router-to-cellular-gateway/1241/12 "2020-08-18T02:37:13Z")

</div>

@jyijyi Is this done from the command line?

---

<div class="post-metadata">

**Author:** ![christopheradams1](https://avatars.discourse-cdn.com/v4/letter/c/e68b1a/32.png) [@christopheradams1](https://mangoh.discourse.group/u/christopheradams1)\
**Post date:** [August 18, 2020, 2:39am UTC](https://mangoh.discourse.group/t/setting-up-mangoh-red-as-router-to-cellular-gateway/1241/13 "2020-08-18T02:39:37Z")

</div>

Yes it is still not pinging after restarting my pc

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [August 18, 2020, 2:42am UTC](https://mangoh.discourse.group/t/setting-up-mangoh-red-as-router-to-cellular-gateway/1241/14 "2020-08-18T02:42:21Z")

</div>

you need to restart the mangoh board, not your pc!

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [August 18, 2020, 2:42am UTC](https://mangoh.discourse.group/t/setting-up-mangoh-red-as-router-to-cellular-gateway/1241/15 "2020-08-18T02:42:50Z")

</div>

modifying the cfg\_gateway.sh, not command line!

---

<div class="post-metadata">

**Author:** ![christopheradams1](https://avatars.discourse-cdn.com/v4/letter/c/e68b1a/32.png) [@christopheradams1](https://mangoh.discourse.group/u/christopheradams1)\
**Post date:** [August 18, 2020, 3:00am UTC](https://mangoh.discourse.group/t/setting-up-mangoh-red-as-router-to-cellular-gateway/1241/16 "2020-08-18T03:00:27Z")

</div>

Oh, I see. So I added this line (see image below), is that what you mean? I will save the file. Should I retry to ssh into mangoh red?

---

<div class="post-metadata">

**Author:** ![christopheradams1](https://avatars.discourse-cdn.com/v4/letter/c/e68b1a/32.png) [@christopheradams1](https://mangoh.discourse.group/u/christopheradams1)\
**Post date:** [August 18, 2020, 3:00am UTC](https://mangoh.discourse.group/t/setting-up-mangoh-red-as-router-to-cellular-gateway/1241/17 "2020-08-18T03:00:49Z")

</div>

Oh, I see. So I added this line (see image below), is that what you mean? I will save the file. Should I retry to ssh into mangoh red? ![Screenshot from 2020-08-17 21-59-02](https://us1.discourse-cdn.com/flex016/uploads/mangoh/original/2X/0/039f8333fce38dff81f8a656da37c334911ed010.png)

---

<div class="post-metadata">

**Author:** ![christopheradams1](https://avatars.discourse-cdn.com/v4/letter/c/e68b1a/32.png) [@christopheradams1](https://mangoh.discourse.group/u/christopheradams1)\
**Post date:** [August 18, 2020, 3:14am UTC](https://mangoh.discourse.group/t/setting-up-mangoh-red-as-router-to-cellular-gateway/1241/18 "2020-08-18T03:14:45Z")

</div>

This is what I am seeing when trying to ping and ssh to device

 ![Screenshot from 2020-08-17 22-13-54](https://us1.discourse-cdn.com/flex016/uploads/mangoh/original/2X/3/31baaafe927b1d1b140a133e4f5f49b67750bd9e.png)

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [August 18, 2020, 3:20am UTC](https://mangoh.discourse.group/t/setting-up-mangoh-red-as-router-to-cellular-gateway/1241/19 "2020-08-18T03:20:46Z")

</div>

you might remove the IOT card, not running cfg\_gateway.sh, reboot the mangoh red board, then retry the SSH via ECM.  
If it does not work from scratch, then I have no idea.

---

<div class="post-metadata">

**Author:** ![christopheradams1](https://avatars.discourse-cdn.com/v4/letter/c/e68b1a/32.png) [@christopheradams1](https://mangoh.discourse.group/u/christopheradams1)\
**Post date:** [August 18, 2020, 5:58am UTC](https://mangoh.discourse.group/t/setting-up-mangoh-red-as-router-to-cellular-gateway/1241/20 "2020-08-18T05:58:39Z")

</div>

Do you think it had something to do with setting it up as a router, then editing the cfg\_gateway.sh file. Maybe it can only be ssh’d into via ethernet. I dont know, I am very confused. When I do ssh [root@192.168.1.141](mailto:root@192.168.1.141) i get packets to send and received 100% (received by who’m… i dont know) from what I recall the IP address 192.168.1.141 is associated with the raspberry pi.

What I have done so far is re-installed swiflash, then used swiflash to re-flash the wp77xx module (dip switch pin 7 in on position), doing so has the module stuck in reboot (see image)

 ![Screenshot from 2020-08-18 00-58-17](https://us1.discourse-cdn.com/flex016/uploads/mangoh/original/2X/2/2cdb5c3797610a470acba011dade72ae17282e11.png)

---

<div class="post-metadata">

**Author:** ![christopheradams1](https://avatars.discourse-cdn.com/v4/letter/c/e68b1a/32.png) [@christopheradams1](https://mangoh.discourse.group/u/christopheradams1)\
**Post date:** [August 18, 2020, 6:00am UTC](https://mangoh.discourse.group/t/setting-up-mangoh-red-as-router-to-cellular-gateway/1241/21 "2020-08-18T06:00:49Z")

</div>

It appears my computer does not even recognize that anything is connected to the usb port when i run ifconfig

 ![Screenshot from 2020-08-18 01-00-31](https://us1.discourse-cdn.com/flex016/uploads/mangoh/original/2X/8/83c2629276b8770fc36faf60bd0348be82839c93.png)

[Next page](https://mangoh.discourse.group/t/setting-up-mangoh-red-as-router-to-cellular-gateway/1241.md?page=2)
