Cisco switch DHCP configuration

Cisco switch DHCP configuration:

Topology

SW1 configuration:

Switch>enable ----- Enter privileged mode from user mode

Switch#configure terminal-----Enter global configuration mode from privileged mode

Switch(config)#hostname sw1-----Specify the host name of the switch as sw1

SW1(config)#vlan 10-----create vlan 10

SW1(config)#vlan 20-----Create vlan 20

SW1(config)#interface fastEthernet 0/2-----Enter interface configuration mode

SW1(config-if)#switchport mode access-----configure vlan access mode

SW1(config-if)#switchport access vlan 10-----Set the port to access VLAN 10

SW1(config-if)#no shutdown-----enable port

SW1(config)#interface fastEthernet 0/3-----Enter interface configuration mode

SW1(config-if)#switchport mode access-----configure vlan access mode

SW1(config-if)#switchport access vlan 20-----Set the port to access VLAN 20

SW1(config-if)#no shutdown-----enable port

SW1(config)#interface fastEthernet 0/1-----Enter interface configuration mode

SW1(config-if)#switchport mode trunk-----configure vlan access mode

SW1(config-if)#switchport trunk allowed vlan 10,20-----set port can access VLAN 10,20

SW1(config-if)#no shutdown-----enable port

SW2 configuration:

Switch>enable ----- Enter privileged mode from user mode

Switch#configure terminal-----Enter global configuration mode from privileged mode

Switch(config)#hostname sw2-----Specify the host name for the switch as sw2

SW2(config)#vlan 30-----create vlan 30

SW2(config)#vlan 40-----create vlan 40

SW2(config)#interface fastEthernet 0/2-----Enter interface configuration mode

SW2(config-if)#switchport mode access-----configure vlan access mode

SW2(config-if)#switchport access vlan 30-----set port can access VLAN 30

SW2(config-if)#no shutdown-----enable port

SW2(config)#interface fastEthernet 0/3-----Enter interface configuration mode

SW2(config-if)#switchport mode access-----configure vlan access mode

SW2(config-if)#switchport access vlan 40-----set port can access VLAN 40

SW2(config-if)#no shutdown-----enable port

SW2(config)#interface fastEthernet 0/1-----Enter interface configuration mode

SW2(config-if)#switchport mode trunk-----configure vlan access mode

SW2(config-if)#switchport trunk allowed vlan 30,40-----set port can access VLAN 30,40

SW2(config-if)#no shutdown-----enable port

SW3 configuration:

Switch>enable ----- Enter privileged mode from user mode

Switch#configure terminal-----Enter global configuration mode from privileged mode

Switch(config)#hostname sw3-----Specify the host name of the switch as sw3

SW3(config)#interface fastEthernet 0/1-----Enter interface configuration mode

SW3(config-if)#switchport trunk allowed vlan 10,20-----set port can access VLAN 10,20

SW3(config)#interface fastEthernet 0/2-----Enter interface configuration mode

SW3(config-if)#switchport trunk allowed vlan 30,40-----set port can access VLAN 30,40

SW3(config)#interface vlan 10-----Enter vlan 10 configuration mode

SW3(config-if)#ip address 192.168.10.1 255.255.255.0-----Configure IP address and subnet mask

SW3(config)#ip dhcp pool 10-----create address pool

SW3(config-if)# network 192.168.10.0 255.255.255.0---The network segment that can be delivered

SW3(dhcp-config)#default-router 192.168.10.1-----gateway

SW3(dhcp-config)#dns-server 114.114.114.114-----dns server

SW3(config)#interface vlan 20-----Enter vlan 20 configuration mode

SW3(config-if)#ip address 192.168.20.1 255.255.255.0-----Configure IP address and subnet mask

SW3(config)#ip dhcp pool20-----create address pool

SW3(config-if)# network 192.168.20.0 255.255.255.0---The network segment that can be delivered

SW3(dhcp-config)#default-router 192.168.20.1-----gateway

SW3(dhcp-config)#dns-server 114.114.114.114-----dns server

SW3(config)#interface vlan 30-----Enter vlan 30 configuration mode

SW3(config-if)#ip address 192.168.30.1 255.255.255.0-----Configure IP address and subnet mask

SW3(config)#ip dhcp pool 30-----create address pool

SW3(config-if)# network 192.168.30.0 255.255.255.0---The network segment that can be delivered

SW3(dhcp-config)#default-router 192.168.30.1-----gateway

SW3(dhcp-config)#dns-server 114.114.114.114----dns server

SW3(config)#interface vlan 40-----Enter vlan 40 configuration mode

SW3(config-if)#ip address 192.168.40.1 255.255.255.0-----Configure IP address and subnet mask

SW3(config)#ip dhcp pool 40-----create address pool

SW3(config-if)# network 192.168.40.0 255.255.255.0---The network segment that can be delivered

SW3(dhcp-config)#default-router 192.168.40.1-----gateway

SW3(dhcp-config)#dns-server 114.114.114.114-----dns server

The gateway address is reserved and not issued, and the address is excluded. configure in global mode

SW3(config)#ip dhcp excluded-address 192.168.10.1

SW3(config)#ip dhcp excluded-address 192.168.20.1

SW3(config)#ip dhcp excluded-address 192.168.30.1,

SW3(config)#ip dhcp excluded-address 192.168.40.1

Finally, go back to the PC, open Desktop, and select the first one (the one with 106 on the picture).

Guess you like

Origin blog.csdn.net/qq_42966610/article/details/129949063