blob: fdae5d49e4fd59611d222a503b0afe194eea6b96 [file] [log] [blame]
How to use VLAN base on ETH to separate multiple PDN
========================================
Here we take 1803 as example, the host PC system tested in this paper is Ubuntu 5.4.0-6Ubuntu 1~16.04.12.
Here we explains both the IPv4 and IPv6, you can ignore the IPv6 part if deploy the IPv4 only.
1, PIPE mode
1) Diag
default PDN:
"serial_client"
AT+ZGDCONT=1,IPV4V6,CMNET
AT+ZGACT=1,1
PDN2:
AT*ZGDCONT=2,IPV4V6,CMWAP,1
AT+ZGACT=1,2
PDN3:
AT*ZGDCONT=3,IPV4V6,GPRS,1
AT+ZGACT=1,3
Query the dial results with command "AT+CGCONTRDP", you will get some information like this:
+CGCONTRDP: 1,5,"cmnet.mnc002.mcc460.gprs","10.83.56.210","","211.138.180.2","211.138.180.3","","",0,0
+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
+CGCONTRDP: 2,6,"cmnet.mnc002.mcc460.gprs","10.83.152.65","","211.138.180.2","211.138.180.3","","",0,0
+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
+CGCONTRDP: 3,7,"cmnet.mnc002.mcc460.gprs","10.83.223.9","","211.138.180.2","211.138.180.3","","",0,0
+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
As listed above , "10.83.56.210" is the IPv4 address of PDN1 and same for the others.
2) Configure /etc/config/network
Add the following configuration to "/etc/config/network":
LAN4 is used to login to WebUI or connect module with fixed IP addresses.
config switch
option name 'switch0'
option reset '1'
option enable_vlan '1'
config interface 'lan2'
option ifname 'eth0.100'
option type 'bridge'
option bridge_empty '1'
option proto 'static'
option ipaddr '10.83.152.190'
option netmask '255.255.255.0'
option ip6assign '60'
config interface 'lan3'
option ifname 'eth0.200'
option type 'bridge'
option bridge_empty '1'
option proto 'static'
option ipaddr '10.83.223.246'
option netmask '255.255.255.0'
option ip6assign '60'
config interface 'lan4'
option ifname 'eth0.300'
option type 'bridge'
option bridge_empty '1'
option proto 'static'
option ipaddr '192.168.1.1'
option netmask '255.255.255.0'
option ip6assign '60'
eth0.100 and eth0.200 represent VLAN100 and VLAN200, "option ipaddr" is the ip address of PDN,
but the last bit requires an xor operation.
Then execute "/etc/init.d/network reload" to apply the configuration.
3) Configure /etc/config/dhcp
Add the following configuration to "/etc/config/dhcp":
config dhcp 'lan2'
option interface 'lan2'
option leasetime '2h'
option dhcpv6 'server'
option ra 'relay'
option ndp 'relay'
option start '65'
option limit '0'
list dhcp_option '3,10.83.152.190'
list dhcp_option '1,255.255.255.0'
list dhcp_option '6,211.138.180.3,211.138.180.2'
list dns '2409:8030:2000::1'
list dns '2409:8030:2000::2'
config dhcp 'lan3'
option interface 'lan3'
option leasetime '2h'
option dhcpv6 'server'
option ra 'relay'
option ndp 'relay'
option start '9'
option limit '0'
list dhcp_option '3,10.83.223.246'
list dhcp_option '1,255.255.255.0'
list dhcp_option '6,211.138.180.3,211.138.180.2'
list dns '2409:8030:2000::1'
list dns '2409:8030:2000::2'
config dhcp 'lan4'
option interface 'lan4'
option start '192.168.1.100'
option end '192.168.1.249'
option limit '150'
option leasetime '43200'
option dhcpv6 'server'
option ra 'relay'
option ndp 'relay'
"option start" is the offset from the PDN address of the underlying interface to calculate the minimum address that may be leased to clients.
Then execute "/etc/init.d/dnsmasq reload" to apply the configuration.
4) Bind the virtual LAN to PDN
Query the local IPv6 address for eth0:
Query the local IPv6 address for eth0:
ifconfig br-lan(*) | grep "inet6 addr" | awk '{print $3}'
For example, you will get the local IPv6 address for br-lan,
"fe80::30e1:7fff:febc:a4e1/64"
Configure virtual LAN:
"echo 192.168.0.1 > eth0/ipaddr"
"echo fe80::30e1:7fff:febc:a4e1 > eth0/ll6addr"
"echo 1 > eth0/up"
"echo 1 > eth0/up6"
"echo 192.168.100.1 > eth0.100/ipaddr"
"echo <br-lan2 local ipv6 addr> > eth0.100/ll6addr"
"echo 1 > eth0.100/up"
"echo 1 > eth0.100/up6"
"echo 192.168.200.1 > eth0.200/ipaddr"
"echo <br-lan3 local ipv6 addr> > eth0.200/ll6addr"
"echo 1 > eth0.200/up"
"echo 1 > eth0.200/up6"
"echo 192.168.1.1 > eth0.300/ipaddr"
"echo 1 > eth0.300/up"
Bind the virtual LAN to PDN
"echo eth0 > ccinet0/combineif"
"echo eth0.100 > ccinet1/combineif"
"echo eth0.200 > ccinet2/combineif"
Now the ccinet1 serves as VLAN100 and ccinet2 as VLAN200, ccinet0 has no vlan.
5) Configuration in Ubuntu16.04
Add virtual network card:
"vconfig add eno1 100"
"vconfig add eno1 200"
"vconfig add eno1 300"
Get IP address through DHCP:
"dhcpcd eno1"
"dhcpcd eno1.100"
"dhcpcd eno1.200"
"dhcpcd eno1.200 -4"
# ifconfig
eno1 Link encap:Ethernet HWaddr fc:4d:d4:47:76:7c
inet addr:10.83.56.210 Bcast:10.83.56.255 Mask:255.255.255.0
inet6 addr: 2409:8930:265:340e:eaad:ceec:7eee:30ca/64 Scope:Global
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8382 errors:0 dropped:0 overruns:0 frame:0
TX packets:7057 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2229048 (2.2 MB) TX bytes:941209 (941.2 KB)
Interrupt:20 Memory:f7c00000-f7c20000
eno1.100 Link encap:Ethernet HWaddr fc:4d:d4:47:76:7c
inet addr:10.83.152.65 Bcast:10.83.152.255 Mask:255.255.255.0
inet6 addr: 2409:8930:265:3582:9561:16:150:31fc/64 Scope:Global
inet6 addr: 2409:8930:265:3582:884b:4cd7:ec22:1a8a/64 Scope:Global
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:321 errors:0 dropped:0 overruns:0 frame:0
TX packets:982 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:42395 (42.3 KB) TX bytes:136625 (136.6 KB)
eno1.200 Link encap:Ethernet HWaddr fc:4d:d4:47:76:7c
inet addr:10.83.223.9 Bcast:10.83.223.255 Mask:255.255.255.0
inet6 addr: 2409:8930:265:372a:3d07:6ef3:72e1:fb32/64 Scope:Global
inet6 addr: fe80::9e83:97a5:fce9:f67b/64 Scope:Link
inet6 addr: 2409:8930:265:372a:e040:801d:d009:6860/64 Scope:Global
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:291 errors:0 dropped:0 overruns:0 frame:0
TX packets:662 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:37415 (37.4 KB) TX bytes:94854 (94.8 KB)
eno1.300 Link encap:Ethernet HWaddr fc:4d:d4:47:76:7c
inet addr:192.168.1.244 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2336 errors:0 dropped:0 overruns:0 frame:0
TX packets:2453 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:277235 (277.2 KB) TX bytes:313953 (313.9 KB)
# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 10.83.56.45 0.0.0.0 UG 202 0 0 eno1
default 10.83.152.190 0.0.0.0 UG 203 0 0 eno1.100
default 10.83.223.246 0.0.0.0 UG 204 0 0 eno1.200
default 192.168.1.1 0.0.0.0 UG 205 0 0 eno1.300
10.83.56.0 * 255.255.255.0 U 202 0 0 eno1
10.83.152.0 * 255.255.255.0 U 203 0 0 eno1.100
10.83.223.0 * 255.255.255.0 U 204 0 0 eno1.200
192.168.1.0 * 255.255.255.0 U 205 0 0 eno1.300
6) Test in Ubuntu16.04
# ping www.sohu.com -I eno1
PING fshyd.a.sohu.com (162.14.132.217) from 10.83.56.210 eno1: 56(84) bytes of data.
64 bytes from 162.14.132.217: icmp_seq=1 ttl=247 time=44.4 ms
64 bytes from 162.14.132.217: icmp_seq=2 ttl=247 time=44.9 ms
# route del default gw 10.83.56.45
# ping www.sohu.com -I eno1.100
PING fshyd.a.sohu.com (162.14.132.217) from 10.83.152.65 eno1.100: 56(84) bytes of data.
64 bytes from 162.14.132.217: icmp_seq=1 ttl=247 time=29.4 ms
64 bytes from 162.14.132.217: icmp_seq=2 ttl=247 time=27.1 ms
# route del default gw 10.83.152.190
# ping www.sohu.com -I eno1.200
PING fshyd.a.sohu.com (162.14.132.217) from 10.83.223.9 eno1.200: 56(84) bytes of data.
64 bytes from 162.14.132.217: icmp_seq=1 ttl=54 time=54.6 ms
64 bytes from 162.14.132.217: icmp_seq=2 ttl=54 time=43.0 ms
# ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=1.93 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=1.11 ms
# ping6 www.sohu.com -I eno1
PING www.sohu.com(2402:4e00:4010:1::20) from 2409:8930:265:340e:eaad:ceec:7eee:30ca eno1: 56 data bytes
64 bytes from 2402:4e00:4010:1::20: icmp_seq=2 ttl=50 time=63.9 ms
64 bytes from 2402:4e00:4010:1::20: icmp_seq=3 ttl=50 time=42.7 ms
# ping6 www.sohu.com -I eno1.100
PING www.sohu.com(2402:4e00:4010:1::21) from 2409:8930:265:3582:9561:16:150:31fc eno1.100: 56 data bytes
64 bytes from 2402:4e00:4010:1::21: icmp_seq=1 ttl=50 time=29.7 ms
64 bytes from 2402:4e00:4010:1::21: icmp_seq=2 ttl=50 time=38.3 ms
# ping6 www.sohu.com -I eno1.200
PING www.sohu.com(2402:4e00:4010:1::25) from 2409:8930:265:372a:e040:801d:d009:6860 eno1.200: 56 data bytes
64 bytes from 2402:4e00:4010:1::25: icmp_seq=1 ttl=50 time=52.9 ms
64 bytes from 2402:4e00:4010:1::25: icmp_seq=2 ttl=50 time=47.1 ms
7) Note
If you disconnect the eth, you may need to follow the above steps to reconfigure after reconnect.