VswitchThe following figure shows the instance topology configuration:
Basic vswitch Configuration
- Switch> enable Switch# config ter
- Switch(config)# hostname Switch Switch(config)# interface vlan 1
- Switch(config-if)# ip address 192.168.1.10 255.255.255.0 Switch(config-if)# no shutdown
- Switch(config-if)# exit Switch(config)# ip default-gateway 192.168.1.1
- Switch(config)# end Switch#show int vlan 1
- Vlan1 is administratively down, line protocol is down Hardware is CPU Interface, address is 0001.9719.ab57 (bia 0001.9719.ab57)
- Internet address is 192.168.1.10/24 MTU 1500 bytes, BW 100000 Kbit, DLY 1000000 usec,
- reliability 255/255, txload 1/255, rxload 1/255 Encapsulation ARPA, loopback not set
- ARP type: ARPA, ARP Timeout 04:00:00 Last input 21:40:21, output never, output hang never
- Last clearing of “show interface” counters never Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
- Queueing strategy: fifo Output queue: 0/40 (size/max)
- 5 minute input rate 0 bits/sec, 0 packets/sec 5 minute output rate 0 bits/sec, 0 packets/sec
- 1682 packets input, 530955 bytes, 0 no buffer Received 0 broadcasts (0 IP multicast)
- 0 runts, 0 giants, 0 throttles 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
- 563859 packets output, 0 bytes, 0 underruns 0 output errors, 23 interface resets
- 0 output buffer failures, 0 output buffers swapped out Switch#
Configure the settings of each PC
- a) PC1 IP ADDRESS:192.168.1.100
- SUBMASK: 255.255.255.0 DEFAULT-GATEWAY: 192.168.1.1
- b) PC2 IP ADDRESS:192.168.1.101
- SUBMASK: 255.255.255.0 DEFAULT-GATEWAY: 192.168.1.1
- c) PC3 IP ADDRESS:192.168.1.102
- SUBMASK: 255.255.255.0 DEFAULT-GATEWAY: 192.168.1.1
Verify
- d) PC1
- ping 192.168.1.101
- ping 192.168.1.102
Nengtong
- e) PC2
- ping 192.168.1.100
- ping 192.168.1.102
Nengtong
View the MAC table dynamically learned by the vswitch
Because we access each other through the ping command, the switch will dynamically learn the MAC addresses of each PC!
- Switch#show mac-address-table Mac Address Table
- ——————————————-
- Vlan Mac Address Type Ports —- ———– ——– —–
- 1 0001.4246.a36c DYNAMIC Fa0/3
- 1 0009.7c35.7001 DYNAMIC Fa0/24 1 00d0.58b6.24da DYNAMIC Fa0/2
- 1 00d0.bc37.3d6b DYNAMIC Fa0/1
Currently, the F0/1 interface of the vswitch is configured to only allow access from PC0. If the access from other PCs is illegal, the interface is disabled and cannot be enabled.
- Switch # config term Switch (config) # interface f0/1
- Switch (config-if) # switchport mode access // set the interface to the access interface Switch (config-if) # switchport port-security // enable port security on the Interface
- Switch (config-if) # switchport port-security mac 00d0. 58b6. 24da // bind the MAC address of PC0 to this interface. The MAC address can be viewed in step 3.
- Switch (config-if) # switchport port-security maximum 1 // because we only allow PC0 access, set the access volume to 1
- Switch (config-if) # switchport port-security violation shutdown // The operation after illegal user access is disabled
Verification:
- Switch# show port-security interface f0/1 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 : 00D0.58B6.24DA:1
- Security Violation Count : 0