Switch(config)# interface vlan 1
Switch(config-if)# ip address 192.168.10.1 255.255.255.0
Switch(config-if)# description Link to VLAN 1
Switch(config-if)# no shutdownSwitch(config)# ip default-gateway 192.168.10.254Switch(config)# interface FastEthernet 0/3
Switch(config-if)# shutdown
%LINK-5-CHANGED: Interface FastEthernet0/3, changed state to administratively down
Switch(config-if)# exit
Switch(config)#Switch(config)# interface range FastEthernet 0/4 - FastEthernet 0/24
Switch(config)# !* interface range FastEthernet 0/4 - 24
Switch(config-if-range)#shutdown
%LINK-5-CHANGED: Interface FastEthernet0/4, changed state to administratively down
…
%LINK-5-CHANGED: Interface FastEthernet0/24, changed state to administratively down
Switch(config-if-range)# end
Switch#Format
Switch(config)# vlan ID
Switch(config-vlan)# name vlanName
Switch(config-vlan)# exitExample:
Switch(config)# vlan 99
Switch(config-vlan)# name Management
Switch(config-vlan)# exitFormat
Switch(config)# interface interfaceID
Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan ID
Switch(config-if)# exitExample:
Switch(config)# interface Fa 0/5
Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan 99
Switch(config-if)# exit⚠️WARNING ⚠️
Before the deletion of the VLAN, the assigned ports have to be re-assigned to another VLAN.
Format
Switch(config)# no vlan IDExample:
Switch(config)# no vlan 99Switch(config)# interface Fa 0/5
Switch(config-if)# no switchport access vlan⚠️WARNING Never use VLAN 1 as native. ⚠️
- The native VLAN has to be the same on each end
- By default, all VLANs are allowed. To filter the VLANs, use allowed.
Format
Switch(config)# interface interfaceID
Switch(config-if)# switchport mode trunk
Switch(config-if)# switchport trunk native vlan ID
Switch(config-if)# switchport trunk allowed vlan ID1,ID2,ID3
Switch(config-if)# endExample:
Switch(config)# interface Fa 0/5
Switch(config-if)# switchport mode trunk
Switch(config-if)# switchport trunk native vlan 99
Switch(config-if)# endFormat
Switch(config)# interface vlan ID
Switch(config-if)# ip address IPAddress subnetMask
Switch(config-if)# no shutdown
Switch(config-if)# endExample:
Switch(config)# interface vlan 99
Switch(config-if)# ip address 192.168.10.1 255.255.255.0
Switch(config-if)# no shutdown
Switch(config-if)# endSwitch#show vlan brief
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4
Fa0/7, Fa0/8, Fa0/9, Fa0/10
Fa0/11, Fa0/12, Fa0/13, Fa0/14
Fa0/15, Fa0/16, Fa0/17, Fa0/18
Fa0/19, Fa0/20, Fa0/21, Fa0/22
Fa0/23, Fa0/24, Gig0/1, Gig0/2
99 Management active Fa0/5, Fa0/6
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active
Switch#Switch(config)# ip dhcp snooping
Switch(config)# ip dhcp snooping vlan ID1,ID2
Switch(config)# interface FastEthernet 0/1
Switch(config-if)# ip dhcp snooping trustThe range is 1 to 2048. It's recommended to trust not more than 100 packets per second.
On the other hand, the limit should be increased if the port is a trunk port assigned to more than one VLAN on which DHCP snooping is enabled.
Switch(config)# ip dhcp snooping
Switch(config)# ip dhcp snooping vlan ID1,ID2
Switch(config)# interface FastEthernet 0/1
Switch(config-if)# ip dhcp snooping trust
Switch(config-if)# ip dhcp snooping limit rate Switch# show mac-address-table
Mac Address Table
-------------------------------------------
Vlan Mac Address Type Ports
---- ----------- -------- -----
99 0060.3e71.9902 STATIC Fa0/5
99 0090.2b03.5b13 STATIC Fa0/6
Switch#⚠️WARNING ⚠️
Without the following command, none of this will work !!!
RQ: It sets the maximal number of MAC addresses to 1 and the violation action type to shutdown.
Switch(config-if)# switchport port-securityWe choose the interface, shut it down and activate the port security on it.
Switch(config)# interface interfaceID
Switch(config-if)# shutdown
Switch(config-if)# switchport port-securityThen we activate the security for the MAC address of the chosen interface
(from show interfaces interfaceID).
Switch(config-if)# switchport port-security mac-address macAddress
Switch(config-if)# no shutdown
Switch(config-if)# endThe default value is 1 and the maximum number of addresses is 3072.
Switch(config-if)# switchport port-security maximum valueThe default type is shutdwon but there are three of them.
Switch(config-if)# switchport port-security violation typeIn this mode, any port security violation immediately causes the deactivation of the interface errors recording as well as the port LED. The violation counter is incremented.
When the secure MAC addresses number reaches the authorized limit on the port, packets with unknown source addresses are ignored until a sufficient number of secure MAC addresses are deleted or the maximum number of addresses to be authorized is increased. Using this mode produces no notification when a security violation has occurred.
When the secure MAC addresses number reaches the authorized limit on the port, packets with unknown source addresses are ignored until a sufficient number of secure MAC addresses are deleted or the maximum number of addresses to be authorized is increased. In this mode, a notification indicates that a security violation has occurred.
Switch(config)# interface interfaceID
Switch(config-if)# switchport port-security mac-address stickySwitch(config)# interface interfaceID
Switch(config-if)# switchport port-security mac-address sticky macAddressSwitch# configure terminal
Switch(config)# interface FastEthernet 0/5
Switch(config-if)# shutdown
Switch(config-if)# no shutdownSwitch# show port-security
Secure Port MaxSecureAddr CurrentAddr SecurityViolation Security Action
(Count) (Count) (Count)
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
Fa0/5 1 1 0 Shutdown
Fa0/6 1 1 0 Shutdown
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
Switch#Switch# show port-security interface FastEthernet 0/5
Port Security : Enabled
Port Status : Secure-up
Violation Mode : Shutdown
Aging Time : 0 mins
Aging Type : Absolute
SecureStatic Address Aging : Disabled
Maximum MAC Addresses : 1
Total MAC Addresses : 1
Configured MAC Addresses : 1
Sticky MAC Addresses : 0
Last Source Address:Vlan : 0060.3E71.9902:99
Security Violation Count : 0
Switch#Switch# show port-security address
Secure Mac Address Table
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
Vlan Mac Address Type Ports Remaining Age
(mins)
−−−− −−−−−−−−−−− −−−− −−−−− −−−−−−−−−−−−−
99 0060.3E71.9902 SecureConfigured FastEthernet0/5 -
99 0090.2B03.5B13 SecureConfigured FastEthernet0/6 -
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
Total Addresses in System (excluding one mac per port) : 0
Max Addresses limit in System (excluding one mac per port) : 1024
Switch#