b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | How to create a dual APN and use the second APN to access the outer network |
| 2 | ======================================== |
| 3 | Here we take 1802s (i.e. NezhaS) as example, 1826 (i.e. Nezha3) is similar. |
| 4 | |
| 5 | 1, Create a dual APN |
| 6 | |
| 7 | In the openwrt top dir, |
| 8 | 1) Modify the following contents in “target/Linux/MMP/asr1802s/config-3.10” |
| 9 | CONFIG_USB_ETH_RNDIS_ECM=y |
| 10 | |
| 11 | 2) Modify the following contents in “target/linux/mmp/asr1802s/NEZAS201/base-files/etc/init.d/usb_init” |
| 12 | echo rndis,acm,marvell_diag,adb,ecm > /sys/class/android_usb/android0/functions |
| 13 | echo rndis,acm,marvell_diag,adb,ecm > /sys/class/android_usb/android0/win7 |
| 14 | echo rndis,acm,marvell_diag,adb,ecm > /sys/class/android_usb/android0/win8 |
| 15 | echo rndis,acm,marvell_diag,adb,ecm > /sys/class/android_usb/android0/olinux |
| 16 | |
| 17 | 3) Modify the following contents in “package/network/config/firewall/Makefile” |
| 18 | DUAL_APN_FLAG=1 |
| 19 | |
| 20 | 4) Choose the profile config |
| 21 | make defconfig_asr1802sp201 |
| 22 | and build |
| 23 | make -j8 V=99 |
| 24 | |
| 25 | 5) Use SWDownloader to burn all bin files into the board |
| 26 | |
| 27 | 6) Switch to pipe mode by AT command and reboot |
| 28 | AT+ACONFIG="PIPE=1" |
| 29 | |
| 30 | 7) Use the AT command to dial-up Internet |
| 31 | AT+CGDCONT=2,"IP","cmwap" |
| 32 | AT+CGACT=1,2 |
| 33 | and query the IP of CMWAP |
| 34 | AT+CGDCONT? |
| 35 | for example, you might get something like this: |
| 36 | +CGDCONT: 1,"IP","cmnet.mnc007.mcc460.gprs","10.36.148.238",0,0,,,, |
| 37 | |
| 38 | +CGDCONT: 2,"IP","cmwap.mnc007.mcc460.gprs","100.74.21.147",0,0,0,2,0,0 |
| 39 | |
| 40 | 8) Configure the network |
| 41 | ifconfig ccinet1 100.74.21.147 netmask 255.255.255.0 up |
| 42 | |
| 43 | 9) Test whether ccinet1 can ping the external network |
| 44 | ping -I ccinet1 8.8.8.8 |
| 45 | |
| 46 | |
| 47 | 2, Access the external network through the lan |
| 48 | |
| 49 | 1) Configure the Intranet network |
| 50 | Connect the usb to your PC, You can see two new network adapters by "ifconfig" command, |
| 51 | which corresponding to the virtual network cards usbnet0 and usbnet1 on 1802s. For example: |
| 52 | |
| 53 | enp0s26u1u1 Link encap:Ethernet HWaddr 06:83:32:53:f7:0b |
| 54 | inet addr:10.36.148.238 Bcast:10.36.148.255 Mask:255.255.255.0 |
| 55 | UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 |
| 56 | RX packets:16 errors:0 dropped:0 overruns:0 frame:0 |
| 57 | TX packets:52 errors:0 dropped:0 overruns:0 carrier:0 |
| 58 | collisions:0 txqueuelen:1000 |
| 59 | RX bytes:1823 (1.8 KB) TX bytes:8933 (8.9 KB) |
| 60 | |
| 61 | enp0s26u1u1i6 Link encap:Ethernet HWaddr 26:b9:7a:b6:be:4a |
| 62 | UP BROADCAST MULTICAST MTU:1500 Metric:1 |
| 63 | RX packets:0 errors:0 dropped:0 overruns:0 frame:0 |
| 64 | TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 |
| 65 | collisions:0 txqueuelen:1000 |
| 66 | RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) |
| 67 | |
| 68 | We need to configure the adapters enp0s26u1u1i6 and usbnet1 in the same small segment. |
| 69 | OpenWrt: |
| 70 | ifconfig usbnet1 192.168.20.1 netmask 255.255.255.0 up |
| 71 | Linux PC: |
| 72 | ifconfig enp0s26u1u1i6 192.168.20.100 netmask 255.255.255.0 up |
| 73 | |
| 74 | 2) Configure the Router |
| 75 | OpenWrt: |
| 76 | route add default gw 100.74.21.147 (the IP address of ccinet1) |
| 77 | Linux PC: |
| 78 | route add default gw 192.168.20.1 |
| 79 | |
| 80 | 3) Configure the firewall |
| 81 | Linux PC: |
| 82 | iptables -F |
| 83 | iptables -X |
| 84 | iptables -Z |
| 85 | iptables -A INPUT -j ACCEPT |
| 86 | iptables -A FORWARD -j ACCEPT |
| 87 | iptables -A OUTPUT -j ACCEPT |
| 88 | |
| 89 | 4) Test whether enp0s26u1u1i6 can ping the external network |
| 90 | Linux PC: |
| 91 | ping -I enp0s26u1u1i6 8.8.8.8 |
| 92 | |