VLAN & Inter-VLAN Routing Follow
Reference model:
- Switch model name:
- AS7726-32X
- AS7326-56X
- AS7816-64X
- AS5835-54X(T)
- AS4630-54PE
- AS9716-32D
- AS8000(Minipack)
- Wedge100BF-32X
- Edgecore SONiC version:
- Edgecore-SONiC_20201123_130028_ec202006_74
- Edgecore-SONiC_20201229_070315_ec202006_101
- Edgecore-SONiC_20201229_070315_ec202006_bfn_65(Wedge100BF-32X)
Example: Create VLAN and set untagged or tagged VLAN member on the interface.
Topology :
Procedure :
Steps 1. Check IP interface before adding IP address to VLAN interface.
Caution: IP address has to be removed from physical interface
admin@sonic:~$ show ip interfaces
Interface Master IPv4 address/mask Pri/Sec Admin/Oper BGP Neighbor Neighbor IP
----------- -------- ------------------- --------- ------------ -------------- -------------
Ethernet48 192.168.1.1/24 Primary up/down N/A N/A
docker0 240.127.1.1/24 Primary up/down N/A N/A
eth0 188.188.97.28/16 Primary up/up N/A N/A
lo 127.0.0.1/8 Primary up/up N/A N/A
admin@sonic:~$ sudo config interface ip remove Ethernet48 192.168.1.1/24
Caution: Since there is IP address on physical interface "Ethernet48", we have to remove IP address from it, or we cannot add the VLAN to Ethernet48. In the current version, it has error handling as following.
admin@sonic:~$ sudo config vlan member add 1 Ethernet48
Usage: config vlan member add [OPTIONS] <vid> <interface_name>
Try "config vlan member add -h" for help.
Error: Ethernet48 is a L3 interface!
Steps 2. Create VLAN1 and VLAN2 on the switch
admin@sonic:~$ sudo config vlan add 1 admin@sonic:~$ sudo config vlan add 2
Steps 3. Let the Ethernet48 as VLAN1 untag member.
admin@sonic:~$ sudo config vlan member add -u 1 Ethernet48
Steps 4. Let the Ethernet52 as VLAN2 tag member.
admin@sonic:~$ sudo config vlan member add 2 Ethernet52
Caution: please make sure the port name is correct. Otherwise it does not work.
Since there's no warning messages for wrong command.
i.e use "show vlan brief" to double check above settings.
admin@sonic:~$ show vlan brief
+-----------+----------------+------------+----------------+-----------------------+
| VLAN ID | IP Address | Ports | Port Tagging | DHCP Helper Address |
+===========+================+============+================+=======================+
| 1 | | Ethernet48 | untagged | |
+-----------+----------------+------------+----------------+-----------------------+
| 2 | | Ethernet52 | tagged | |
+-----------+----------------+------------+----------------+-----------------------+
Example: Inter-VLAN routing
Steps 1. Configure IP addresses on VLAN1 and VLAN2
admin@sonic:~$ sudo config interface ip add Vlan1 192.168.1.2/24 admin@sonic:~$ sudo config interface ip add Vlan2 192.168.2.1/24
Caution: Vlan1 and Vlan2 are the Names of VLAN interface. So, "V" must be capital.
Steps 2. Check the VLAN setting and IP addresses
admin@sonic:~$ show vlan brief +-----------+----------------+------------+----------------+-----------------------+ | VLAN ID | IP Address | Ports | Port Tagging | DHCP Helper Address | +===========+================+============+================+=======================+ | 1 | 192.168.1.2/24 | Ethernet48 | untagged | | +-----------+----------------+------------+----------------+-----------------------+ | 2 | 192.168.2.1/24 | Ethernet52 | tagged | | +-----------+----------------+------------+----------------+-----------------------+ admin@sonic:~$ show ip interfaces
Interface Master IPv4 address/mask Pri/Sec Admin/Oper BGP Neighbor Neighbor IP
----------- -------- ------------------- --------- ------------ -------------- -------------
Vlan1 192.168.1.2/24 Primary up/up N/A N/A
Vlan2 192.168.2.1/24 Primary up/up N/A N/A
docker0 240.127.1.1/24 Primary up/down N/A N/A
eth0 188.188.97.28/16 Primary up/up N/A N/A
lo 127.0.0.1/8 Primary up/up N/A N/A
Steps 3. Check the native VLAN (PVID)
admin@sonic:~$ sudo bridge vlan port vlan ids
docker0 1 PVID Egress Untagged
Ethernet48 1 PVID Egress Untagged
Ethernet52 2
Bridge 1
2
dummy 1 PVID Egress Untagged
Steps 4. Save the setting to config_db.json
admin@sonic:~$ sudo config save -y
Steps 5. Check VLAN setting on config_db.json
admin@sonic:/etc/sonic$ sudo vi config_db.json { ... "VLAN_INTERFACE": {
"Vlan1": {},
"Vlan2": {},
"Vlan1|192.168.1.2/24": {},
"Vlan2|192.168.2.1/24": {}
},
"VLAN_MEMBER": {
"Vlan1|Ethernet48": {
"tagging_mode": "untagged"
},
"Vlan2|Ethernet52": {
"tagging_mode": "tagged"
}
}, ... }
Comments
1 comment
Hi 張恪睿,
Thanks for your sharing, I did the same procedure in my set up, unfortunately, the operational status is still down. not up/up but up/down. I can't ping from the server to the switch. Do you know what may cause this problem? Thanks!
Tong
Please sign in to leave a comment.