Różnice między wybraną wersją a wersją aktualną.
Nowa wersja | Poprzednia wersja | ||
sk1:vlan [2017/04/26 13:53] jkonczak utworzono |
sk1:vlan [2020/05/19 13:18] (aktualna) jkonczak [Konfiguracja switchy CISCO] |
||
---|---|---|---|
Linia 35: | Linia 35: | ||
* ''enable'' – wejście w tryb uprzywilejowany | * ''enable'' – wejście w tryb uprzywilejowany | ||
* tryb uprzywilejowany ''#'' | * tryb uprzywilejowany ''#'' | ||
+ | * ''show interfaces status'' – pokazanie listę i stan interfejsów | ||
* ''configure terminal'' (''conf t'') – wejście w tryb konfiguracji | * ''configure terminal'' (''conf t'') – wejście w tryb konfiguracji | ||
* ''show vlan [brief]'' (''sh vlan [br]'') – pokazanie konfiguracji vlanów | * ''show vlan [brief]'' (''sh vlan [br]'') – pokazanie konfiguracji vlanów | ||
* ''show interfaces trunk'' – pokazanie aktywnych połączeń typu trunk | * ''show interfaces trunk'' – pokazanie aktywnych połączeń typu trunk | ||
+ | * tryb konfiguracji ''(config)#'' | ||
* <html><small></html>''vlan <nr_vlana>'' – wejście w konfigurację sieci vlan <html></small></html> | * <html><small></html>''vlan <nr_vlana>'' – wejście w konfigurację sieci vlan <html></small></html> | ||
* <html><small></html> ''name <nazwa>'' – nazwanie vlana <html></small></html> | * <html><small></html> ''name <nazwa>'' – nazwanie vlana <html></small></html> | ||
- | * tryb konfiguracji ''(config)#'' | ||
* ''interface <nazwa_interfejsu>'' – konfiguracja interfejsu, np. \\ ''interface //FastEthernet 0/1//'' (''interface //Fa0/1//'') | * ''interface <nazwa_interfejsu>'' – konfiguracja interfejsu, np. \\ ''interface //FastEthernet 0/1//'' (''interface //Fa0/1//'') | ||
* ''interface range <lista interfejsów>'' – konfiguracja wielu interfejsów naraz, np. \\ ''interface range //FastEthernet 0/1-5, FastEthernet 0/11-15//'' | * ''interface range <lista interfejsów>'' – konfiguracja wielu interfejsów naraz, np. \\ ''interface range //FastEthernet 0/1-5, FastEthernet 0/11-15//'' | ||
* tryb konfiguracji interfejsu ''(config-if)#'' | * tryb konfiguracji interfejsu ''(config-if)#'' | ||
* ''switchport access vlan <nr_vlana>'' – dołącza port do wybranego vlanu, np. \\ ''switchport access vlan //5//'' | * ''switchport access vlan <nr_vlana>'' – dołącza port do wybranego vlanu, np. \\ ''switchport access vlan //5//'' | ||
- | * ''switchport mode access'' – ustawia port nie by był trunkiem | + | * ''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 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 | * ''switchport mode trunk'' – ustawia port by był trunkiem | ||
Linia 51: | Linia 52: | ||
<html><small></html>VLAN a STP – [[https://en.wikipedia.org/wiki/Spanning_Tree_Protocol#Multiple_Spanning_Tree_Protocol|MSTP]] i pomysły CSICO<html></small></html> | <html><small></html>VLAN a STP – [[https://en.wikipedia.org/wiki/Spanning_Tree_Protocol#Multiple_Spanning_Tree_Protocol|MSTP]] i pomysły CSICO<html></small></html> | ||
+ | ++++ Przykład konfiguracji i diagnostyki switchy CISCO: | | ||
+ | <html><pre> | ||
+ | Switch>ena | ||
+ | Switch#conf t | ||
+ | Enter configuration commands, one per line. End with CNTL/Z. | ||
+ | Switch(config)#<span title="Konfiguracja vlan 10 na portach 0-6" style="background-color:rgba(0,255,255,0.2)">interface range FastEthernet 1/0 - 6</span> | ||
+ | Switch(config-if)#<span title="Konfiguracja vlan 10 na portach 0-6" style="background-color:rgba(0,255,255,0.2)"><b>switchport access vlan 10</b></span> | ||
+ | Switch(config-if)#<span title="Konfiguracja vlan 10 na portach 0-6" style="background-color:rgba(0,255,255,0.2)">switchport mode access</span> | ||
+ | Switch(config-if)#exit | ||
+ | Switch(config)#<span title="Konfiguracja vlan 20 na portach 7-13" style="background-color:rgba(255,255,0,0.4)">interface range FastEthernet 1/7 - 13</span> | ||
+ | Switch(config-if)#<span title="Konfiguracja vlan 20 na portach 7-13" style="background-color:rgba(255,255,0,0.4)"><b>switchport access vlan 20</b></span> | ||
+ | Switch(config-if)#<span title="Konfiguracja vlan 20 na portach 7-13" style="background-color:rgba(255,255,0,0.4)">switchport mode access</span> | ||
+ | Switch(config-if)#exit | ||
+ | Switch(config)#<span title="Konfiguracja połączenia trunk na porcie 15" style="background-color:rgba(255,0,0,0.2)">interface FastEthernet 1/15</span> | ||
+ | Switch(config-if)#<span title="Konfiguracja połączenia trunk na porcie 15" style="background-color:rgba(255,0,0,0.2)"><b>switchport trunk encapsulation dot1q</b></span> | ||
+ | Switch(config-if)#<span title="Konfiguracja połączenia trunk na porcie 15" style="background-color:rgba(255,0,0,0.2)"><b>switchport mode trunk</b></span> | ||
+ | Switch#end | ||
+ | Switch#<b>show vlan brief</b> | ||
+ | |||
+ | VLAN Name Status Ports | ||
+ | ---- -------------------------------- --------- ------------------------------- | ||
+ | 1 default active Fa1/14 | ||
+ | <span style="background-color:rgba(0,255,255,0.2)">10</span> VLAN0010 active <span style="background-color:rgba(0,255,255,0.2)">Fa1/0, Fa1/1, Fa1/2, Fa1/3</span> | ||
+ | <span style="background-color:rgba(0,255,255,0.2)">Fa1/4, Fa1/5, Fa1/6,</span> | ||
+ | <span style="background-color:rgba(255,255,0,0.4)">20</span> VLAN0020 active <span style="background-color:rgba(255,255,0,0.4)">Fa1/7, Fa1/8, Fa1/9, Fa1/10</span> | ||
+ | <span style="background-color:rgba(255,255,0,0.4)">Fa1/11, Fa1/12, Fa1/13</span> | ||
+ | 1002 fddi-default active | ||
+ | 1003 token-ring-default active | ||
+ | 1004 fddinet-default active | ||
+ | 1005 trnet-default active | ||
+ | |||
+ | Switch#<b>show interfaces trunk</b> | ||
+ | |||
+ | Port Mode Encapsulation Status Native vlan | ||
+ | <span style="background-color:rgba(255,0,0,0.2)">Fa1/15 on 802.1q trunking 1</span> | ||
+ | |||
+ | 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 | ||
+ | </pre></html> ++++ | ||
===== Konfiguracja na Linuksie ===== | ===== Konfiguracja na Linuksie ===== | ||
Linia 57: | Linia 103: | ||
* ''ip l add link <nazwa_nadinterfejsu> <nazwa_nowego_interfejsu> type vlan id <numer_vlan>'' \\ dodanie interfejsu reprezentującego vlan, np: \\ ''ip l add link //eth0// //eth0.2// type vlan id //2//'' | * ''ip l add link <nazwa_nadinterfejsu> <nazwa_nowego_interfejsu> type vlan id <numer_vlan>'' \\ dodanie interfejsu reprezentującego vlan, np: \\ ''ip l add link //eth0// //eth0.2// type vlan id //2//'' | ||
* ''ip l del <nazwa>'' usunięcie interfejsu | * ''ip l del <nazwa>'' usunięcie interfejsu | ||
+ | |||
+ | ++++ Przykład konfiguracji routera na Linuksie: | | ||
+ | <html><pre> | ||
+ | # 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 | ||
+ | # | ||
+ | # <span title="Stworzenie na eth0 podinterfejsu dopiętego do sieci o identyfikatorze 10" style="background-color:rgba(0,255,255,0.2)">ip link add eth0.10 link eth0 type <b>vlan id 10</b></span> | ||
+ | # <span title="Stworzenie na eth0 podinterfejsu dopiętego do sieci o identyfikatorze 20" style="background-color:rgba(255,255,0,0.4)">ip link add eth0.20 link eth0 type <b>vlan id 20</b></span> | ||
+ | # | ||
+ | <span title="Włączenie interfejsów" style="background-color:rgba(0,0,0,0.1)"># ip link set eth0 up | ||
+ | # ip link set eth0.10 up | ||
+ | # ip link set eth0.20 up</span> | ||
+ | # | ||
+ | <span title="Ustawienie IP z odpowiednich sieci" style="background-color:rgba(0,0,0,0.1)"># ip link add 192.168.10.1/24 dev eth0.10 | ||
+ | # ip link add 192.168.20.1/24 dev eth0.20</span> | ||
+ | # | ||
+ | # 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: <span style="background-color:rgba(0,255,255,0.2)">eth0.10</span>@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 | ||
+ | <span style="background-color:rgba(0,255,255,0.2)">vlan protocol 802.1Q id 10</span> <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: <span style="background-color:rgba(255,255,0,0.4)">eth0.20</span>@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 | ||
+ | <span style="background-color:rgba(255,255,0,0.4)">vlan protocol 802.1Q id 20</span> <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 | ||
+ | <span title="Zabronienie nawiązywania połączeń z VLANu 10 do VLANu 20" style="background-color:rgba(0,0,0,0.1)"># iptables -A FORWARD -i eth0.10 -o eth0.20 -m conntrack --ctstate NEW -j DROP</span> | ||
+ | <span title="Włączenie przekazywania pakietów" style="background-color:rgba(0,0,0,0.1)"># sysctl net.ipv4.conf.all.forwarding=1</span> | ||
+ | </pre></html> ++++ | ||
===== Konfiguracja routerów CISCO ===== | ===== Konfiguracja routerów CISCO ===== | ||
Linia 68: | Linia 156: | ||
* ''no shut''– żeby podinterfejs działał, trzeba włączyć cały interfejs | * ''no shut''– żeby podinterfejs działał, trzeba włączyć cały interfejs | ||
+ | ++++ Przykładowa konfiguracja routera CISCO: | | ||
+ | <html><pre> | ||
+ | R1# | ||
+ | R1#conf t | ||
+ | R1(config)#<span title="Stworzenie na eth0 podinterfejsu dopiętego do sieci o identyfikatorze 10" style="background-color:rgba(0,255,255,0.2)">interface GigabitEthernet 0/0.10</span> | ||
+ | R1(config-subif)#<span title="Stworzenie na eth0 podinterfejsu dopiętego do sieci o identyfikatorze 10" style="background-color:rgba(0,255,255,0.2)">encapsulation dot1Q 10</span> | ||
+ | R1(config-subif)#<span title="Ustawienie IP z odpowiedniej sieci" style="background-color:rgba(0,0,0,0.1)">ip address 192.168.10.254 255.255.255.0</span> | ||
+ | R1(config-subif)#exit | ||
+ | R1(config)#<span title="Stworzenie na eth0 podinterfejsu dopiętego do sieci o identyfikatorze 20" style="background-color:rgba(255,255,0,0.4)">interface GigabitEthernet 0/0.20</span> | ||
+ | R1(config-subif)#<span title="Stworzenie na eth0 podinterfejsu dopiętego do sieci o identyfikatorze 20" style="background-color:rgba(255,255,0,0.4)">encapsulation dot1Q 20</span> | ||
+ | R1(config-subif)#<span title="Ustawienie IP z odpowiedniej sieci" style="background-color:rgba(0,0,0,0.1)">ip address 192.168.20.254 255.255.255.0</span> | ||
+ | R1(config-subif)#exit | ||
+ | R1(config)#interface GigabitEthernet 0/0 | ||
+ | R1(config-if)#<span title="Włączenie interfejsów" style="background-color:rgba(0,0,0,0.1)">no shutdown</span> | ||
+ | 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 | ||
+ | <span style="background-color:rgba(0,255,255,0.2)">GigabitEthernet0/0.10</span> 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 | ||
+ | <span style="background-color:rgba(0,255,255,0.2)">Encapsulation 802.1Q Virtual LAN, Vlan ID 10.</span> | ||
+ | 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 | ||
+ | <span title="Pakiety z native VLAN – domyślnie VLAN 1 – będą odbierane na głównym interfejsie" style="background-color:rgba(0,0,0,0.1)">Encapsulation 802.1Q Virtual LAN, Vlan ID 1., loopback not set</span> | ||
+ | ... | ||
+ | </pre></html>++++ |