VLAN is a sort of Virtual LAN, a network that behaves as if they are connected to the same wire network even though they may actually be physically connected on different segments of a LAN. That mean in a same Local Area Network (LAN) environment we can segregate the network in a virtually.
Meanwhile, we can configure Routed VLAN interfaces (RVIs) to the switch for recognize packets that are being sent to local addresses. In this way we can route the IP address only when it required.
First Need to create a Vlan. Assign a VLAN name and VLAN-ID. Here I am using Vlan Name is Management and Vlan ID is 50.
#set vlan Management vlan-id 50
We need to make this VLAN as work with layer 3. Now Link the layer 2 VLAN to the layer 3 VLAN interface, Here VLAN 50 is now work in a Layer 2 and Layer 3 mode.
#set vlans Management l3-interface vlan.50
Finally setup IP address at VLAN number 50. And the configuration is given bellow.
#set interfaces vlan unit 50 family inet address 172.16.100.5/24
For check the final confirmation just review the configuration with bellow command:
user@geek# show vlans Management vlan-id 50; l3-interface vlan.50;
user@geek# show interfaces vlan unit 50 { family inet { address 172.16.100.5/24; } }
You can chock the routing table for confirmation and view the the next hop via vlan.50
user@geek# run show route inet.0: 5 destinations, 5 routes (5 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 172.16.100.5/32 *[Local/0] 3w6d 00:42:26 Reject 172.16.100.0/24 *[Direct/0] 3w6d 00:42:06 > via vlan.50
Check the reachability with ping your another ip address of your network
user@geek# run ping 172.16.100.6 PING 172.16.100.6 (172.16.100.6): 56 data bytes 64 bytes from 172.16.100.6: icmp_seq=0 ttl=64 time=3.685 ms 64 bytes from 172.16.100.6: icmp_seq=1 ttl=64 time=3.245 ms 64 bytes from 172.16.100.6: icmp_seq=2 ttl=64 time=2.143 ms 64 bytes from 172.16.100.6: icmp_seq=3 ttl=64 time=2.436 ms 64 bytes from 172.16.100.6: icmp_seq=4 ttl=64 time=2.757 ms ^C --- 172.16.100.6 ping statistics --- 5 packets transmitted, 5 packets received, 0% packet loss round-trip min/avg/max/stddev = 2.143/2.853/3.685/0.554 ms {master:5}[edit]