思科交换机VLAN,DHCP配置模拟实例

1.要求:
左边的电脑自动获取IP为192.168.1.1段
右边的电脑自动获取IP为192.168.2.1段
思科交换机VLAN,DHCP配置模拟实例
2.开始准备工作,f0/1接左边交换机,f0/2接右边交换机,实际工作中,一定要接这个口,你要是接反了或者接到其他口去,获取的IP就不对了
思科交换机VLAN,DHCP配置模拟实例

3.点击最上面那个交换机,开始配置(图里的交换机型号有误,应该是2960)
思科交换机VLAN,DHCP配置模拟实例
4.建立 vlan 10并分配IP地址
Switch>
Switch>enable
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#interface vlan 10
Switch(config-if)#ip address 192.168.1.1 255.255.255.0
Switch(config-if)#no shutdown
Switch(config-if)#exit
Switch(config)#
思科交换机VLAN,DHCP配置模拟实例
5.配置DHCP地址池和相应参数(实际运用中你可能上不去网,改下DNS地址就行了)
Switch(config)#ip dhcp pool 10 (建立名为 10 的地址池)
Switch(dhcp-config)#network 192.168.1.0 255.255.255.0(网络地址)
Switch(dhcp-config)#dns-server 192.168.1.1(DNS 地址)
Switch(dhcp-config)#default-router 192.168.1.1(默认网关)
Switch(dhcp-config)#exit
Switch(config)#ip dhcp excluded-address 192.168.1.1(设置保留不分配的 IP地址)
Switch(config)#exit
Switch#
思科交换机VLAN,DHCP配置模拟实例
6.进入端口 f0/1 ,并把端口加入vlan 10
Switch(config)#interface f0/1
Switch(config-if)#switchport access vlan 10 (打完这个还要按一次回车,如图)
附:删除vlan和多个端口加入vlan,这个我没有试
思科交换机VLAN,DHCP配置模拟实例
思科交换机VLAN,DHCP配置模拟实例
7.查看电脑端是否能自动获取IP
思科交换机VLAN,DHCP配置模拟实例
思科交换机VLAN,DHCP配置模拟实例
8.再加两台电脑,依旧正常获取IP,左边设置完成思科交换机VLAN,DHCP配置模拟实例
9.设置右边交换机,重复456即可,依旧在最上面那个交换机里设置,全命令如下
Switch>enable
Switch#conf t
Switch(config)#interface vlan 20
Switch(config-if)#ip address 192.168.2.1 255.255.255.0
Switch(config-if)#no shutdown
Switch(config-if)#exit
Switch(config)#ip dhcp pool 20
Switch(dhcp-config)#network 192.168.2.1 255.255.255.0
Switch(dhcp-config)#dns-server 192.168.2.1
Switch(dhcp-config)#default-router 192.168.2.1
Switch(dhcp-config)#exit
Switch(config)#ip dhcp excluded-address 192.168.2.1
Switch(config)#exit

Switch#conf t
Switch(config)#interface f0/2
Switch(config-if)#switchport access vlan 20
思科交换机VLAN,DHCP配置模拟实例
思科交换机VLAN,DHCP配置模拟实例
10.模拟实验完成。
注:vlan 10和 vlan 20 是不能互通的,互通要额外的设置,这个还不会,哪天学会了补上来