blob: 161cb003ea015bc39f28e84913af8946926e6622 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001How to create a dual APN and use the second APN to access the outer network
2========================================
3Here we take 1802s (i.e. NezhaS) as example, 1826 (i.e. Nezha3) is similar.
4
51, Create a dual APN
6
7In the openwrt top dir,
81) Modify the following contents in “target/Linux/MMP/asr1802s/config-3.10”
9 CONFIG_USB_ETH_RNDIS_ECM=y
10
112) 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
173) Modify the following contents in “package/network/config/firewall/Makefile”
18 DUAL_APN_FLAG=1
19
204) Choose the profile config
21 make defconfig_asr1802sp201
22and build
23 make -j8 V=99
24
255) Use SWDownloader to burn all bin files into the board
26
276) Switch to pipe mode by AT command and reboot
28 AT+ACONFIG="PIPE=1"
29
307) Use the AT command to dial-up Internet
31 AT+CGDCONT=2,"IP","cmwap"
32 AT+CGACT=1,2
33and query the IP of CMWAP
34 AT+CGDCONT?
35for 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
408) Configure the network
41 ifconfig ccinet1 100.74.21.147 netmask 255.255.255.0 up
42
439) Test whether ccinet1 can ping the external network
44 ping -I ccinet1 8.8.8.8
45
46
472, Access the external network through the lan
48
491) Configure the Intranet network
50Connect the usb to your PC, You can see two new network adapters by "ifconfig" command,
51which 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
68We need to configure the adapters enp0s26u1u1i6 and usbnet1 in the same small segment.
69OpenWrt:
70 ifconfig usbnet1 192.168.20.1 netmask 255.255.255.0 up
71Linux PC:
72 ifconfig enp0s26u1u1i6 192.168.20.100 netmask 255.255.255.0 up
73
742) Configure the Router
75OpenWrt:
76 route add default gw 100.74.21.147 (the IP address of ccinet1)
77Linux PC:
78 route add default gw 192.168.20.1
79
803) Configure the firewall
81Linux 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
894) Test whether enp0s26u1u1i6 can ping the external network
90Linux PC:
91 ping -I enp0s26u1u1i6 8.8.8.8
92