思科交换机DHCP配置

思科交换机DHCP配置:

拓扑图

SW1配置:

Switch>enable -----从用户模式进入特权模式

Switch#configure terminal-----从特权模式进入全局配置模式

Switch(config)#hostname sw1-----给交换机指定主机名为sw1

SW1(config)#vlan 10-----创建vlan 10

SW1(config)#vlan 20-----创建vlan 20

SW1(config)#interface fastEthernet 0/2-----进入接口配置模式

SW1(config-if)#switchport mode access-----配置vlan 访问模式

SW1(config-if)#switchport access vlan 10-----设置端口可以访问VLAN 10

SW1(config-if)#no shutdown-----启用端口

SW1(config)#interface fastEthernet 0/3-----进入接口配置模式

SW1(config-if)#switchport mode access-----配置vlan 访问模式

SW1(config-if)#switchport access vlan 20-----设置端口可以访问VLAN 20

SW1(config-if)#no shutdown-----启用端口

SW1(config)#interface fastEthernet 0/1-----进入接口配置模式

SW1(config-if)#switchport mode trunk-----配置vlan 访问模式

SW1(config-if)#switchport trunk allowed vlan 10,20-----设置端口可以访问VLAN 10,20

SW1(config-if)#no shutdown-----启用端口

SW2配置:

Switch>enable -----从用户模式进入特权模式

Switch#configure terminal-----从特权模式进入全局配置模式

Switch(config)#hostname sw2-----给交换机指定主机名为sw2

SW2(config)#vlan 30-----创建vlan 30

SW2(config)#vlan 40-----创建vlan 40

SW2(config)#interface fastEthernet 0/2-----进入接口配置模式

SW2(config-if)#switchport mode access-----配置vlan 访问模式

SW2(config-if)#switchport access vlan 30-----设置端口可以访问VLAN 30

SW2(config-if)#no shutdown-----启用端口

SW2(config)#interface fastEthernet 0/3-----进入接口配置模式

SW2(config-if)#switchport mode access-----配置vlan 访问模式

SW2(config-if)#switchport access vlan 40-----设置端口可以访问VLAN 40

SW2(config-if)#no shutdown-----启用端口

SW2(config)#interface fastEthernet 0/1-----进入接口配置模式

SW2(config-if)#switchport mode trunk-----配置vlan 访问模式

SW2(config-if)#switchport trunk allowed vlan 30,40-----设置端口可以访问VLAN 30,40

SW2(config-if)#no shutdown-----启用端口

SW3配置:

Switch>enable -----从用户模式进入特权模式

Switch#configure terminal-----从特权模式进入全局配置模式

Switch(config)#hostname sw3-----给交换机指定主机名为sw3

SW3(config)#interface fastEthernet 0/1-----进入接口配置模式

SW3(config-if)#switchport trunk allowed vlan 10,20-----设置端口可以访问VLAN 10,20

SW3(config)#interface fastEthernet 0/2-----进入接口配置模式

SW3(config-if)#switchport trunk allowed vlan 30,40-----设置端口可以访问VLAN 30,40

SW3(config)#interface  vlan 10-----进入vlan 10配置模式

SW3(config-if)#ip address 192.168.10.1 255.255.255.0-----配置IP地址和子网掩码

SW3(config)#ip dhcp pool 10-----创建地址池

SW3(config-if)# network 192.168.10.0 255.255.255.0---可以下发的网段

SW3(dhcp-config)#default-router 192.168.10.1-----网关

SW3(dhcp-config)#dns-server 114.114.114.114-----dns服务器

SW3(config)#interface  vlan 20-----进入vlan 20配置模式

SW3(config-if)#ip address 192.168.20.1 255.255.255.0-----配置IP地址和子网掩码

SW3(config)#ip dhcp pool20-----创建地址池

SW3(config-if)# network 192.168.20.0 255.255.255.0---可以下发的网段

SW3(dhcp-config)#default-router 192.168.20.1-----网关

SW3(dhcp-config)#dns-server 114.114.114.114-----dns服务器

SW3(config)#interface  vlan 30-----进入vlan 30配置模式

SW3(config-if)#ip address 192.168.30.1 255.255.255.0-----配置IP地址和子网掩码

SW3(config)#ip dhcp pool 30-----创建地址池

SW3(config-if)# network 192.168.30.0 255.255.255.0---可以下发的网段

SW3(dhcp-config)#default-router 192.168.30.1-----网关

SW3(dhcp-config)#dns-server 114.114.114.114----dns服务器

SW3(config)#interface  vlan 40-----进入vlan 40配置模式

SW3(config-if)#ip address 192.168.40.1 255.255.255.0-----配置IP地址和子网掩码

SW3(config)#ip dhcp pool 40-----创建地址池

SW3(config-if)# network 192.168.40.0 255.255.255.0---可以下发的网段

SW3(dhcp-config)#default-router 192.168.40.1-----网关

SW3(dhcp-config)#dns-server 114.114.114.114-----dns服务器

保留网关地址不下发,排除地址。在全局模式下配置

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

最后回到pc上,打开Desktop,选择第一个(图片上带106的)。

猜你喜欢

转载自blog.csdn.net/qq_42966610/article/details/129949063