blob: fdae5d49e4fd59611d222a503b0afe194eea6b96 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001How to use VLAN base on ETH to separate multiple PDN
2========================================
3Here we take 1803 as example, the host PC system tested in this paper is Ubuntu 5.4.0-6Ubuntu 1~16.04.12.
4Here we explains both the IPv4 and IPv6, you can ignore the IPv6 part if deploy the IPv4 only.
5
61, PIPE mode
71) Diag
8 default PDN:
9 "serial_client"
10 AT+ZGDCONT=1,IPV4V6,CMNET
11 AT+ZGACT=1,1
12 PDN2:
13 AT*ZGDCONT=2,IPV4V6,CMWAP,1
14 AT+ZGACT=1,2
15 PDN3:
16 AT*ZGDCONT=3,IPV4V6,GPRS,1
17 AT+ZGACT=1,3
18
19 Query the dial results with command "AT+CGCONTRDP", you will get some information like this:
20
21 +CGCONTRDP: 1,5,"cmnet.mnc002.mcc460.gprs","10.83.56.210","","211.138.180.2","211.138.180.3","","",0,0
22
23 +CGCONTRDP: 1,5,"cmnet.mnc002.mcc460.gprs","254.128.0.0.0.0.0.0.64.146.26.57.99.145.79.134","","36.9.128.48.32.0.0.0.0.0.0.0.0.0.0.1","36.9.128.48.32.0.0.0.0.0.0.0.0.0.0.2","","",0,0
24
25 +CGCONTRDP: 2,6,"cmnet.mnc002.mcc460.gprs","10.83.152.65","","211.138.180.2","211.138.180.3","","",0,0
26
27 +CGCONTRDP: 2,6,"cmnet.mnc002.mcc460.gprs","254.128.0.0.0.0.0.0.147.189.59.114.229.84.73.203","","36.9.128.48.32.0.0.0.0.0.0.0.0.0.0.1","36.9.128.48.32.0.0.0.0.0.0.0.0.0.0.2","","",0,0
28
29 +CGCONTRDP: 3,7,"cmnet.mnc002.mcc460.gprs","10.83.223.9","","211.138.180.2","211.138.180.3","","",0,0
30
31 +CGCONTRDP: 3,7,"cmnet.mnc002.mcc460.gprs","254.128.0.0.0.0.0.0.119.145.137.164.221.238.176.216","","36.9.128.48.32.0.0.0.0.0.0.0.0.0.0.1","36.9.128.48.32.0.0.0.0.0.0.0.0.0.0.2","","",0,0
32
33 As listed above , "10.83.56.210" is the IPv4 address of PDN1 and same for the others.
34
352) Configure /etc/config/network
36 Add the following configuration to "/etc/config/network":
37 LAN4 is used to login to WebUI or connect module with fixed IP addresses.
38
39 config switch
40 option name 'switch0'
41 option reset '1'
42 option enable_vlan '1'
43
44 config interface 'lan2'
45 option ifname 'eth0.100'
46 option type 'bridge'
47 option bridge_empty '1'
48 option proto 'static'
49 option ipaddr '10.83.152.190'
50 option netmask '255.255.255.0'
51 option ip6assign '60'
52
53 config interface 'lan3'
54 option ifname 'eth0.200'
55 option type 'bridge'
56 option bridge_empty '1'
57 option proto 'static'
58 option ipaddr '10.83.223.246'
59 option netmask '255.255.255.0'
60 option ip6assign '60'
61
62 config interface 'lan4'
63 option ifname 'eth0.300'
64 option type 'bridge'
65 option bridge_empty '1'
66 option proto 'static'
67 option ipaddr '192.168.1.1'
68 option netmask '255.255.255.0'
69 option ip6assign '60'
70
71 eth0.100 and eth0.200 represent VLAN100 and VLAN200, "option ipaddr" is the ip address of PDN,
72 but the last bit requires an xor operation.
73 Then execute "/etc/init.d/network reload" to apply the configuration.
74
753) Configure /etc/config/dhcp
76 Add the following configuration to "/etc/config/dhcp":
77
78 config dhcp 'lan2'
79 option interface 'lan2'
80 option leasetime '2h'
81 option dhcpv6 'server'
82 option ra 'relay'
83 option ndp 'relay'
84 option start '65'
85 option limit '0'
86 list dhcp_option '3,10.83.152.190'
87 list dhcp_option '1,255.255.255.0'
88 list dhcp_option '6,211.138.180.3,211.138.180.2'
89 list dns '2409:8030:2000::1'
90 list dns '2409:8030:2000::2'
91
92 config dhcp 'lan3'
93 option interface 'lan3'
94 option leasetime '2h'
95 option dhcpv6 'server'
96 option ra 'relay'
97 option ndp 'relay'
98 option start '9'
99 option limit '0'
100 list dhcp_option '3,10.83.223.246'
101 list dhcp_option '1,255.255.255.0'
102 list dhcp_option '6,211.138.180.3,211.138.180.2'
103 list dns '2409:8030:2000::1'
104 list dns '2409:8030:2000::2'
105
106 config dhcp 'lan4'
107 option interface 'lan4'
108 option start '192.168.1.100'
109 option end '192.168.1.249'
110 option limit '150'
111 option leasetime '43200'
112 option dhcpv6 'server'
113 option ra 'relay'
114 option ndp 'relay'
115
116 "option start" is the offset from the PDN address of the underlying interface to calculate the minimum address that may be leased to clients.
117 Then execute "/etc/init.d/dnsmasq reload" to apply the configuration.
118
1194) Bind the virtual LAN to PDN
120 Query the local IPv6 address for eth0:
121 Query the local IPv6 address for eth0:
122 ifconfig br-lan(*) | grep "inet6 addr" | awk '{print $3}'
123 For example, you will get the local IPv6 address for br-lan,
124 "fe80::30e1:7fff:febc:a4e1/64"
125
126 Configure virtual LAN:
127 "echo 192.168.0.1 > eth0/ipaddr"
128 "echo fe80::30e1:7fff:febc:a4e1 > eth0/ll6addr"
129 "echo 1 > eth0/up"
130 "echo 1 > eth0/up6"
131
132 "echo 192.168.100.1 > eth0.100/ipaddr"
133 "echo <br-lan2 local ipv6 addr> > eth0.100/ll6addr"
134 "echo 1 > eth0.100/up"
135 "echo 1 > eth0.100/up6"
136
137 "echo 192.168.200.1 > eth0.200/ipaddr"
138 "echo <br-lan3 local ipv6 addr> > eth0.200/ll6addr"
139 "echo 1 > eth0.200/up"
140 "echo 1 > eth0.200/up6"
141
142 "echo 192.168.1.1 > eth0.300/ipaddr"
143 "echo 1 > eth0.300/up"
144
145 Bind the virtual LAN to PDN
146 "echo eth0 > ccinet0/combineif"
147 "echo eth0.100 > ccinet1/combineif"
148 "echo eth0.200 > ccinet2/combineif"
149 Now the ccinet1 serves as VLAN100 and ccinet2 as VLAN200, ccinet0 has no vlan.
150
1515) Configuration in Ubuntu16.04
152 Add virtual network card:
153 "vconfig add eno1 100"
154 "vconfig add eno1 200"
155 "vconfig add eno1 300"
156
157 Get IP address through DHCP:
158 "dhcpcd eno1"
159 "dhcpcd eno1.100"
160 "dhcpcd eno1.200"
161 "dhcpcd eno1.200 -4"
162
163 # ifconfig
164 eno1 Link encap:Ethernet HWaddr fc:4d:d4:47:76:7c
165 inet addr:10.83.56.210 Bcast:10.83.56.255 Mask:255.255.255.0
166 inet6 addr: 2409:8930:265:340e:eaad:ceec:7eee:30ca/64 Scope:Global
167 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
168 RX packets:8382 errors:0 dropped:0 overruns:0 frame:0
169 TX packets:7057 errors:0 dropped:0 overruns:0 carrier:0
170 collisions:0 txqueuelen:1000
171 RX bytes:2229048 (2.2 MB) TX bytes:941209 (941.2 KB)
172 Interrupt:20 Memory:f7c00000-f7c20000
173
174 eno1.100 Link encap:Ethernet HWaddr fc:4d:d4:47:76:7c
175 inet addr:10.83.152.65 Bcast:10.83.152.255 Mask:255.255.255.0
176 inet6 addr: 2409:8930:265:3582:9561:16:150:31fc/64 Scope:Global
177 inet6 addr: 2409:8930:265:3582:884b:4cd7:ec22:1a8a/64 Scope:Global
178 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
179 RX packets:321 errors:0 dropped:0 overruns:0 frame:0
180 TX packets:982 errors:0 dropped:0 overruns:0 carrier:0
181 collisions:0 txqueuelen:1000
182 RX bytes:42395 (42.3 KB) TX bytes:136625 (136.6 KB)
183
184 eno1.200 Link encap:Ethernet HWaddr fc:4d:d4:47:76:7c
185 inet addr:10.83.223.9 Bcast:10.83.223.255 Mask:255.255.255.0
186 inet6 addr: 2409:8930:265:372a:3d07:6ef3:72e1:fb32/64 Scope:Global
187 inet6 addr: fe80::9e83:97a5:fce9:f67b/64 Scope:Link
188 inet6 addr: 2409:8930:265:372a:e040:801d:d009:6860/64 Scope:Global
189 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
190 RX packets:291 errors:0 dropped:0 overruns:0 frame:0
191 TX packets:662 errors:0 dropped:0 overruns:0 carrier:0
192 collisions:0 txqueuelen:1000
193 RX bytes:37415 (37.4 KB) TX bytes:94854 (94.8 KB)
194
195 eno1.300 Link encap:Ethernet HWaddr fc:4d:d4:47:76:7c
196 inet addr:192.168.1.244 Bcast:192.168.1.255 Mask:255.255.255.0
197 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
198 RX packets:2336 errors:0 dropped:0 overruns:0 frame:0
199 TX packets:2453 errors:0 dropped:0 overruns:0 carrier:0
200 collisions:0 txqueuelen:1000
201 RX bytes:277235 (277.2 KB) TX bytes:313953 (313.9 KB)
202
203 # route
204 Kernel IP routing table
205 Destination Gateway Genmask Flags Metric Ref Use Iface
206 default 10.83.56.45 0.0.0.0 UG 202 0 0 eno1
207 default 10.83.152.190 0.0.0.0 UG 203 0 0 eno1.100
208 default 10.83.223.246 0.0.0.0 UG 204 0 0 eno1.200
209 default 192.168.1.1 0.0.0.0 UG 205 0 0 eno1.300
210 10.83.56.0 * 255.255.255.0 U 202 0 0 eno1
211 10.83.152.0 * 255.255.255.0 U 203 0 0 eno1.100
212 10.83.223.0 * 255.255.255.0 U 204 0 0 eno1.200
213 192.168.1.0 * 255.255.255.0 U 205 0 0 eno1.300
214
2156) Test in Ubuntu16.04
216
217 # ping www.sohu.com -I eno1
218 PING fshyd.a.sohu.com (162.14.132.217) from 10.83.56.210 eno1: 56(84) bytes of data.
219 64 bytes from 162.14.132.217: icmp_seq=1 ttl=247 time=44.4 ms
220 64 bytes from 162.14.132.217: icmp_seq=2 ttl=247 time=44.9 ms
221
222 # route del default gw 10.83.56.45
223 # ping www.sohu.com -I eno1.100
224 PING fshyd.a.sohu.com (162.14.132.217) from 10.83.152.65 eno1.100: 56(84) bytes of data.
225 64 bytes from 162.14.132.217: icmp_seq=1 ttl=247 time=29.4 ms
226 64 bytes from 162.14.132.217: icmp_seq=2 ttl=247 time=27.1 ms
227
228 # route del default gw 10.83.152.190
229 # ping www.sohu.com -I eno1.200
230 PING fshyd.a.sohu.com (162.14.132.217) from 10.83.223.9 eno1.200: 56(84) bytes of data.
231 64 bytes from 162.14.132.217: icmp_seq=1 ttl=54 time=54.6 ms
232 64 bytes from 162.14.132.217: icmp_seq=2 ttl=54 time=43.0 ms
233
234 # ping 192.168.1.1
235 PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
236 64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=1.93 ms
237 64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=1.11 ms
238
239 # ping6 www.sohu.com -I eno1
240 PING www.sohu.com(2402:4e00:4010:1::20) from 2409:8930:265:340e:eaad:ceec:7eee:30ca eno1: 56 data bytes
241 64 bytes from 2402:4e00:4010:1::20: icmp_seq=2 ttl=50 time=63.9 ms
242 64 bytes from 2402:4e00:4010:1::20: icmp_seq=3 ttl=50 time=42.7 ms
243
244 # ping6 www.sohu.com -I eno1.100
245 PING www.sohu.com(2402:4e00:4010:1::21) from 2409:8930:265:3582:9561:16:150:31fc eno1.100: 56 data bytes
246 64 bytes from 2402:4e00:4010:1::21: icmp_seq=1 ttl=50 time=29.7 ms
247 64 bytes from 2402:4e00:4010:1::21: icmp_seq=2 ttl=50 time=38.3 ms
248
249 # ping6 www.sohu.com -I eno1.200
250 PING www.sohu.com(2402:4e00:4010:1::25) from 2409:8930:265:372a:e040:801d:d009:6860 eno1.200: 56 data bytes
251 64 bytes from 2402:4e00:4010:1::25: icmp_seq=1 ttl=50 time=52.9 ms
252 64 bytes from 2402:4e00:4010:1::25: icmp_seq=2 ttl=50 time=47.1 ms
253
2547) Note
255 If you disconnect the eth, you may need to follow the above steps to reconfigure after reconnect.