====== VLAN ====== [[http://www.cs.put.poznan.pl/ddwornikowski/sieci/sieci2/vlans.html|Materiały o VLANach]] Topologia fizyczna sieci – urządzenia i połączenia między nimi W ramach fizycznej topologii można tworzyć sieci wirtualne – VLANy. Przykładowo firmową sieć (fizyczną) można podzielić na sieci: * dla pracowników – serwer domeny AD i komputery pracowników * dla działu administracji (księgowość, płace, etc.) – serwery baz danych i komputery pracowników * służącą do zarządzania siecią – dostęp do konfiguracji urządzeń sieciowych * bezprzewodowe punkty dostępowe dla gości Typowo do budowy sieci VLAN używa się zarządzanych przełączników, a ruch z sieci wirtualnych trafia na router (i firewall) który decyduje o trasowaniu do/z internetu jak i między VLANami. Sieci VLAN są identyfikowane przez numer (VID) z zakresu 1÷4094.\\ CISCO i VLAN nr 1 Zalety sieci VLAN: * możliwość zmiany "fizycznej" topologii sieci bez zmiany sprzętu * separacja urządzeń * ograniczanie ruchu rozgłoszeniowego Łączenie switchy użwających VLAN ze sobą * "naiwne" łączenie * trunk / vlan tagging / [[https://en.wikipedia.org/wiki/IEEE_802.1Q|802.1Q]] * native vlan ===== Konfiguracja switchy CISCO ===== Konfiguracja przełączników (switchy) CISCO: * tryb użytkownika ''>'' * ''enable'' – wejście w tryb uprzywilejowany * tryb uprzywilejowany ''#'' * ''show interfaces status'' – pokazanie listę i stan interfejsów * ''configure terminal'' (''conf t'') – wejście w tryb konfiguracji * ''show vlan [brief]'' (''sh vlan [br]'') – pokazanie konfiguracji vlanów * ''show interfaces trunk'' – pokazanie aktywnych połączeń typu trunk * tryb konfiguracji ''(config)#'' * ''vlan '' – wejście w konfigurację sieci vlan * ''name '' – nazwanie vlana * ''interface '' – konfiguracja interfejsu, np. \\ ''interface //FastEthernet 0/1//'' (''interface //Fa0/1//'') * ''interface range '' – konfiguracja wielu interfejsów naraz, np. \\ ''interface range //FastEthernet 0/1-5, FastEthernet 0/11-15//'' * tryb konfiguracji interfejsu ''(config-if)#'' * ''switchport access vlan '' – dołącza port do wybranego vlanu, np. \\ ''switchport access vlan //5//'' * ''switchport mode access'' – ustawia port by nie był trunkiem * ''switchport trunk encapsulation dot1q'' – ustawia by używać standardu kropka 1 q, czyli 802.1Q, do połączeń typu trunk na tym porcie * ''switchport mode trunk'' – ustawia port by był trunkiem VLAN a STP – [[https://en.wikipedia.org/wiki/Spanning_Tree_Protocol#Multiple_Spanning_Tree_Protocol|MSTP]] i pomysły CSICO ++++ Przykład konfiguracji i diagnostyki switchy CISCO: |
Switch>ena
Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#interface range FastEthernet 1/0 - 6
Switch(config-if)#switchport access vlan 10
Switch(config-if)#switchport mode access
Switch(config-if)#exit
Switch(config)#interface range FastEthernet 1/7 - 13
Switch(config-if)#switchport access vlan 20
Switch(config-if)#switchport mode access
Switch(config-if)#exit
Switch(config)#interface FastEthernet 1/15
Switch(config-if)#switchport trunk encapsulation dot1q
Switch(config-if)#switchport mode trunk
Switch#end
Switch#show vlan brief

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa1/14
10   VLAN0010                         active    Fa1/0, Fa1/1, Fa1/2, Fa1/3
                                                Fa1/4, Fa1/5, Fa1/6, 
20   VLAN0020                         active    Fa1/7, Fa1/8, Fa1/9, Fa1/10
                                                Fa1/11, Fa1/12, Fa1/13
1002 fddi-default                     active    
1003 token-ring-default               active    
1004 fddinet-default                  active    
1005 trnet-default                    active    

Switch#show interfaces trunk 

Port      Mode         Encapsulation  Status        Native vlan
Fa1/15    on           802.1q         trunking      1

Port      Vlans allowed on trunk
Fa1/15    1-1005

Port      Vlans allowed and active in management domain
Fa1/15    1,10,20

Port      Vlans in spanning tree forwarding state and not pruned
Fa1/15    1,10,20
++++ ===== Konfiguracja na Linuksie ===== VLAN w Linuksie: * ''ip -d l'' wyświetlanie list interfejsów z detalami (pełne polecenie: ''ip --detail link show'') * ''ip l add link type vlan id '' \\ dodanie interfejsu reprezentującego vlan, np: \\ ''ip l add link //eth0// //eth0.2// type vlan id //2//'' * ''ip l del '' usunięcie interfejsu ++++ Przykład konfiguracji routera na Linuksie: |
# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether 00:11:38:f0:41:00 brd ff:ff:ff:ff:ff:ff
#
# ip link add eth0.10 link eth0 type vlan id 10
# ip link add eth0.20 link eth0 type vlan id 20
#
# ip link set eth0 up
# ip link set eth0.10 up
# ip link set eth0.20 up
#
# ip link add 192.168.10.1/24 dev eth0.10
# ip link add 192.168.20.1/24 dev eth0.20
#
# ip -d address
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 promiscuity 0 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:11:38:f0:41:00 brd ff:ff:ff:ff:ff:ff promiscuity 0 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 
3: eth0.10@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:11:38:f0:41:00 brd ff:ff:ff:ff:ff:ff promiscuity 0 
    vlan protocol 802.1Q id 10 <REORDER_HDR> numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 
    inet 192.168.10.1/24 brd 192.168.10.255 scope global
       valid_lft forever preferred_lft forever
4: eth0.20@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:11:38:f0:41:00 brd ff:ff:ff:ff:ff:ff promiscuity 0 
    vlan protocol 802.1Q id 20 <REORDER_HDR> numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 
    inet 192.168.20.1/24 brd 192.168.20.255 scope global
       valid_lft forever preferred_lft forever
# ip route
192.168.10.0/24 dev eth0.10 proto kernel scope link src 192.168.10.1 
192.168.20.0/24 dev eth0.20 proto kernel scope link src 192.168.20.1
# iptables -A FORWARD -i eth0.10 -o eth0.20 -m conntrack --ctstate NEW -j DROP
# sysctl net.ipv4.conf.all.forwarding=1
++++ ===== Konfiguracja routerów CISCO ===== * tryb konfiguracji ''(config)#'' * ''interface .'' – konfiguracja podinterfejsu, np. \\ ''interface //FastEthernet 0/1.5//'' (skracając: ''interface //Fa0/1.5//'') * tryb konfiguracji podinterfejsu ''(config-subif)#'' * ''encapsulation dot1Q '' – przypisanie interfejsu do sieci vlan, np: \\ ''encapsulation dot1Q 5'' * ''ip address '' * tryb konfiguracji interfejsu ''(config-if)#'' * ''no shut''– żeby podinterfejs działał, trzeba włączyć cały interfejs ++++ Przykładowa konfiguracja routera CISCO: |
R1#           
R1#conf t
R1(config)#interface GigabitEthernet 0/0.10
R1(config-subif)#encapsulation dot1Q 10
R1(config-subif)#ip address 192.168.10.254 255.255.255.0
R1(config-subif)#exit
R1(config)#interface GigabitEthernet 0/0.20
R1(config-subif)#encapsulation dot1Q 20
R1(config-subif)#ip address 192.168.20.254 255.255.255.0
R1(config-subif)#exit
R1(config)#interface GigabitEthernet 0/0
R1(config-if)#no shutdown
R1(config-if)#end
R1#sh ip interface brief 
Interface                  IP-Address      OK? Method Status                Protocol
GigabitEthernet0/0         unassigned      YES unset  up                    up      
GigabitEthernet0/0.10      192.168.10.254  YES manual up                    up      
GigabitEthernet0/0.20      192.168.20.254  YES manual up                    up      
GigabitEthernet1/0         unassigned      YES unset  administratively down down    
R1#show interfaces GigabitEthernet 0/0.10
GigabitEthernet0/0.10 is up, line protocol is up 
  Hardware is i82543 (Livengood), address is ca03.485d.0008 (bia ca03.485d.0008)
  Internet address is 192.168.10.254/24
  MTU 1500 bytes, BW 1000000 Kbit, DLY 10 usec, 
     reliability 255/255, txload 1/255, rxload 1/255
  Encapsulation 802.1Q Virtual LAN, Vlan ID  10.
  ARP type: ARPA, ARP Timeout 04:00:00
  Last clearing of "show interface" counters never
R1#show interfaces GigabitEthernet 0/0
GigabitEthernet0/0 is up, line protocol is up 
  Hardware is i82543 (Livengood), address is ca03.485d.0008 (bia ca03.485d.0008)
  MTU 1500 bytes, BW 1000000 Kbit, DLY 10 usec, 
     reliability 255/255, txload 1/255, rxload 1/255
  Encapsulation 802.1Q Virtual LAN, Vlan ID  1., loopback not set
  ...
++++