| How to create a dual APN and use the second APN to access the outer network |
| ======================================== |
| Here we take 1802s (i.e. NezhaS) as example, 1826 (i.e. Nezha3) is similar. |
| |
| 1, Create a dual APN |
| |
| In the openwrt top dir, |
| 1) Modify the following contents in “target/Linux/MMP/asr1802s/config-3.10” |
| CONFIG_USB_ETH_RNDIS_ECM=y |
| |
| 2) Modify the following contents in “target/linux/mmp/asr1802s/NEZAS201/base-files/etc/init.d/usb_init” |
| echo rndis,acm,marvell_diag,adb,ecm > /sys/class/android_usb/android0/functions |
| echo rndis,acm,marvell_diag,adb,ecm > /sys/class/android_usb/android0/win7 |
| echo rndis,acm,marvell_diag,adb,ecm > /sys/class/android_usb/android0/win8 |
| echo rndis,acm,marvell_diag,adb,ecm > /sys/class/android_usb/android0/olinux |
| |
| 3) Modify the following contents in “package/network/config/firewall/Makefile” |
| DUAL_APN_FLAG=1 |
| |
| 4) Choose the profile config |
| make defconfig_asr1802sp201 |
| and build |
| make -j8 V=99 |
| |
| 5) Use SWDownloader to burn all bin files into the board |
| |
| 6) Switch to pipe mode by AT command and reboot |
| AT+ACONFIG="PIPE=1" |
| |
| 7) Use the AT command to dial-up Internet |
| AT+CGDCONT=2,"IP","cmwap" |
| AT+CGACT=1,2 |
| and query the IP of CMWAP |
| AT+CGDCONT? |
| for example, you might get something like this: |
| +CGDCONT: 1,"IP","cmnet.mnc007.mcc460.gprs","10.36.148.238",0,0,,,, |
| |
| +CGDCONT: 2,"IP","cmwap.mnc007.mcc460.gprs","100.74.21.147",0,0,0,2,0,0 |
| |
| 8) Configure the network |
| ifconfig ccinet1 100.74.21.147 netmask 255.255.255.0 up |
| |
| 9) Test whether ccinet1 can ping the external network |
| ping -I ccinet1 8.8.8.8 |
| |
| |
| 2, Access the external network through the lan |
| |
| 1) Configure the Intranet network |
| Connect the usb to your PC, You can see two new network adapters by "ifconfig" command, |
| which corresponding to the virtual network cards usbnet0 and usbnet1 on 1802s. For example: |
| |
| enp0s26u1u1 Link encap:Ethernet HWaddr 06:83:32:53:f7:0b |
| inet addr:10.36.148.238 Bcast:10.36.148.255 Mask:255.255.255.0 |
| UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 |
| RX packets:16 errors:0 dropped:0 overruns:0 frame:0 |
| TX packets:52 errors:0 dropped:0 overruns:0 carrier:0 |
| collisions:0 txqueuelen:1000 |
| RX bytes:1823 (1.8 KB) TX bytes:8933 (8.9 KB) |
| |
| enp0s26u1u1i6 Link encap:Ethernet HWaddr 26:b9:7a:b6:be:4a |
| UP BROADCAST MULTICAST MTU:1500 Metric:1 |
| RX packets:0 errors:0 dropped:0 overruns:0 frame:0 |
| TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 |
| collisions:0 txqueuelen:1000 |
| RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) |
| |
| We need to configure the adapters enp0s26u1u1i6 and usbnet1 in the same small segment. |
| OpenWrt: |
| ifconfig usbnet1 192.168.20.1 netmask 255.255.255.0 up |
| Linux PC: |
| ifconfig enp0s26u1u1i6 192.168.20.100 netmask 255.255.255.0 up |
| |
| 2) Configure the Router |
| OpenWrt: |
| route add default gw 100.74.21.147 (the IP address of ccinet1) |
| Linux PC: |
| route add default gw 192.168.20.1 |
| |
| 3) Configure the firewall |
| Linux PC: |
| iptables -F |
| iptables -X |
| iptables -Z |
| iptables -A INPUT -j ACCEPT |
| iptables -A FORWARD -j ACCEPT |
| iptables -A OUTPUT -j ACCEPT |
| |
| 4) Test whether enp0s26u1u1i6 can ping the external network |
| Linux PC: |
| ping -I enp0s26u1u1i6 8.8.8.8 |
| |