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
# 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
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 ...++++