Most of you already know about LAN , It is very basic concept in computer network, if you don’t know what a LAN is, you can’t understand what is a VLAN ?
LAN stands for local area network. LANs are short-range, high-speed networks typically found in schools, offices, and, more recently, homes.. They are widely used to connect personal computers and workstations in company offices and factories to share resources (e.g., printers) and exchange information etc..
What are VLAN’s?
When you plug a bunch of PCs in to a switch and give them all IP addresses in the same network, you can called it is a LAN. A VLAN is a Virtual LAN. The difference is that with VLANs, you still connect all the PCs to a single switch but you make the switch behave as if it were multiple, independent switches. Each VLAN is its own broadcast domain and IP subnet. In this way, you get the ability to use switches to segment broadcast domains, which up to this point was possible only with routers. VLAN is a logical entity, its creation and configuration is done completely in software.
Why do you need VLANs
The advantages of using VLANs are as follows:
- Provide a High Security
- Easy to management
- Increase the flexibility of network equipment.
- Increase the number of broadcast domains while reducing their size.
Implementing VLANs is done in three steps:
- Create the VLAN.
- Name the VLAN (this is optional but expected).
- Assign switch ports to the VLAN.
How to configure VLAN ?
The vconfig command is used to create and remove vlan-devices on a vlan enabled kernel. Vlan-devices are virtual ethernet devices which represents the virtual lans on the physical LAN .
Add VLAN ID 99 with following command for eth0:
root@server [~]# vconfig add eth0 99 Added VLAN with VID == 99 to IF -:eth0:-
The vconfig add command creates a vlan-device on eth0 which result into eth0.99 interface.
You can use normal ifconfig command to see device information:
root@server [~]# ifconfig eth0.99 Eth0.99 Link encap:Ethernet HWaddr 00:15:17:4B:D2:46 BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Use ifconfig to assign IP address to vlan interfere :
# ifconfig eth0.99 192.168.0.100 netmask 255.255.255.0 broadcast 192.168.0.255 up
Get detailed information about VLAN interface:
root@server [~]# cat /proc/net/vlan/eth0.99 eth0.99 VID: 99 REORDER_HDR: 1 dev->priv_flags: 1 total frames received 0 total bytes received 0 Broadcast/Multicast Rcvd 0 total frames transmitted 27 total bytes transmitted 7412 total headroom inc 0 total encap on xmit 0 Device: eth0 INGRESS priority mappings: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0 EGRESSS priority Mappings:
If you want to delete VLAN interface delete command:
# ifconfig eth0.99 down # vconfig rem eth0.99