How Do I Set Up and Test VLAN Function
Background: I need to test VLAN function in a server platform, so I need to know the following questions:
- What is VLAN?
- Why do we need VLAN?
- What is VLAN mechanism?
- How to enable and test VLAN function?
VLAN Basic Concepts
For the first three questions, you can get the anwsers from reference link, so I don’t plan to talk about it in this article.
How to enable and test VLAN function?
After understanding VLAN basic concepts and mechanism, I can go back to my original question. My original question is to enable and test VLAN function in a server management system.
In this scenario, we used the following steps to test VLAN.
- Set static IP address in server side.
- Connect server and client A(This client could be Windows or Linux) with network cable directly.
- Set static IP address in client A.
- Ping each other.
- Enable VLAN and set VLAN ID in server side.
- Enable VLAN and set VLAN ID in client A.
- Ping each other again.
Step 1: Set static IP address in server side.
There are some server managment interfaces used to set static IP address or you can use ifconfig command to do it.
ifconfig command as below:
ifconfig <interface> <IP Address> netmask <Subnet Mask> up
route add default gw <Gateway address>
For instance:
ifconfig dev0 10.211.138.50 netmask 255.255.254.0 up
route add default gw 10.211.138.1
Step 2: Connect server and client A(This client could be Windows or Linux) with network cable directly.
Step 3: Set static IP address in client A.
Do the same thing as step 1, what we need to pay attention to is make them in the same subnet. We can set the static IP address as below.
ifconfig np5s0 10.211.138.55 netmask 255.255.254.0 up
route add default gw 10.211.138.1
Note: Maybe there are more than one network interface in your client, make sure use the one plugged.
Step 4: Ping each other.
If you have already set static IP address both server and client correctly, they can ping each other successfully.
Step 5: Enable VLAN and set VLAN ID in server side.
It has its specific method to set VLAN in server management system side. After setting VLAN ID(such as 2000, this value should be > 0 && < 4096) and priority, there is another network interface dev0.2000 will be created, which has the same static IP address(10.211.138.50) with dev0 and dev0 interface will lost the IP address in my server platform. You don’t need to refer to this behavior because it is a specific server management interface in my side.
Step 6: Enable VLAN and set VLAN ID in client A.
In client side, my client is a Ubuntu system. You can access this offcial website to know how to do it. Now I set a static IP address(10.211.138.60) for np5s0.2000 interface.
Step 7: Ping each other again.
In client side, run “ping 10.211.138.50” command to check if it can access server successfully.
In server side, run “ping 10.211.138.60” command to check if it can access client successfully.
If they can ping each other successfully, it means the VLAN function works well.
Have a good day.
If you have any feedback, please let me know and thank you so much.
Reference:
- https://www.computernetworkingnotes.com/ccna-study-guide/vlan-basic-concepts-explained-with-examples.html
- https://zhuanlan.zhihu.com/p/35616289