VLAN Significa Virtual Local Area Network, treballen en la capa 2Ethernet i tenen un alt rendiment.
Les VLAN ens permeten tenir diferents segments de xarxa virtuals en una sola interfície de xarxa.
Hi ha dos tipus de ports en les VLAN:
Es coneixen els següents tipus de Virtual LANs:
switch pla: És un switch que no esta configurat, switch "tonto".
Les Vlan, aporten flexibilitat, per que podem fer que una màquina que no es troba en el nostre segment de xarxa i pugui accedir. Això ho fem amb troncals
Pregunta trampa, si dos Pc's estan en el mateix segment de xarxa, connectats per Vlan, no es poden veure si no passen pel router.
$ sudo apt-get install vlan
$ dpkg -L vlan /. /lib /lib/udev /lib/udev/rules.d /lib/udev/rules.d/40-vlan-network-interface.rules /lib/udev/vlan-network-interface /usr /usr/share /usr/share/doc /usr/share/doc/vlan /usr/share/doc/vlan/howto.html /usr/share/doc/vlan/vlan.html /usr/share/doc/vlan/TODO.Debian /usr/share/doc/vlan/copyright /usr/share/doc/vlan/NEWS.Debian.gz /usr/share/doc/vlan/changelog.Debian.gz /usr/share/man /usr/share/man/man5 /usr/share/man/man5/vlan-interfaces.5.gz /usr/share/man/man8 /usr/share/man/man8/vconfig.8.gz /etc /etc/network /etc/network/if-pre-up.d /etc/network/if-pre-up.d/vlan /etc/network/if-post-down.d /etc/network/if-post-down.d/vlan /etc/network/if-up.d /etc/network/if-up.d/ip /sbin /sbin/vconfig
$ ifconfig eth0 Link encap:Ethernet HWaddr c8:60:00:11:c2:dd UP 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:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) Interrupt:58 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:1766 errors:0 dropped:0 overruns:0 frame:0 TX packets:1766 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:218990 (218.9 KB) TX bytes:218990 (218.9 KB) wlan0 Link encap:Ethernet HWaddr 78:92:9c:80:3c:f8 inet addr:192.168.130.134 Bcast:192.168.130.255 Mask:255.255.255.0 inet6 addr: fe80::7a92:9cff:fe80:3cf8/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:87088 errors:0 dropped:0 overruns:0 frame:0 TX packets:10162 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:40280485 (40.2 MB) TX bytes:1829470 (1.8 MB)
$ sudo vconfig add eth0 2 Added VLAN with VID == 2 to IF -:eth0:-
$ sudo lsmod | grep 802 8021q 24084 0 garp 14602 1 8021q mac80211 506816 1 iwlwifi cfg80211 205544 2 iwlwifi,mac80211
$ ifconfig -a eth0 Link encap:Ethernet HWaddr c8:60:00:11:c2:dd UP 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:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) Interrupt:58 eth0.2 Link encap:Ethernet HWaddr c8:60:00:11:c2:dd UP 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) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:1831 errors:0 dropped:0 overruns:0 frame:0 TX packets:1831 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:226142 (226.1 KB) TX bytes:226142 (226.1 KB) wlan0 Link encap:Ethernet HWaddr 78:92:9c:80:3c:f8 inet addr:192.168.130.134 Bcast:192.168.130.255 Mask:255.255.255.0 inet6 addr: fe80::7a92:9cff:fe80:3cf8/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:91726 errors:0 dropped:0 overruns:0 frame:0 TX packets:10342 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:41481502 (41.4 MB) TX bytes:1861818 (1.8 MB)
$ sudo ifconfig eth0.2 192.168.2.134
$ sudo apt-get install vlan
$ dpkg -L vlan | grep etc /etc /etc/network //Configuracions de xarxa de Linux// /etc/network/if-pre-up.d /etc/network/if-pre-up.d/vlan /etc/network/if-post-down.d /etc/network/if-post-down.d/vlan /etc/network/if-up.d /etc/network/if-up.d/ip
$ /etc/network if-down.d if-post-down.d if-pre-up.d if-up.d interfaces //directori on es configuren VLAN//
El fitxer if-pre-up.d fa que les configuracions de VLAN siguin efectives a l'iniciar el sistema.
# IP address for VLAN 3: auto eth6.3 //arranca automàticament a l'inici del sistema// iface eth6.3 inet static // address 10.0.0.1 netmask 255.255.255.0 network 10.0.0.0 broadcast 10.0.0.255
És una comanda que ens permet configurar tot el relacionat amb la xarxa. La resta de comandes es consideren obsoletes, però encara s'utilitzen i s'utilitzaran durant molt temps.
La comanda ip substitueix ifconfig, route, arp, vlan...
La comanda següent serveix per configurar una VLAN:
$ sudo ip link add link INTERFACE name INTERFACE.VID type vlan id VID
Exemple:
$ sudo ip link add link eth0 name eth0.7 type vlan id 7
$ ip address show 4: [email protected]: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN link/ether 00:30:05:eb:38:d6 brd ff:ff:ff:ff:ff:ff
$ ifconfig -a eth0.7 Link encap:Ethernet HWaddr 00:30:05:eb:38:d6 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)
Afegim una ip:
$ sudo ip addr add 192.168.22.7/24 brd 192.168.22.255 dev eth0.7
$ ifconfig -a eth0.7 Link encap:Ethernet HWaddr 00:30:05:eb:38:d6 inet addr:192.168.22.7 Bcast:192.168.22.255 Mask:255.255.255.0 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)
Podem veure que una interfície és de tipus VLAN perquè l'acompanya una @.
$ ip link 4: eth0.7@eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN link/ether 00:30:05:eb:38:d6 brd ff:ff:ff:ff:ff:ff