思科模擬器:交換機(jī)實(shí)現(xiàn)DHCP功能1,、打開(kāi)Cisco Packet Tracer,,點(diǎn)擊【交換機(jī)】,選擇第六個(gè)圖標(biāo)3560交換機(jī),,按住鼠標(biāo)左鍵拖動(dòng)到工作區(qū),。只有這個(gè)交換機(jī)及以上級(jí)別的才具備DHCP功能,我們之前講的2960只可以劃分Vlan,,不支持DHCP服務(wù) 2,、在工作區(qū)內(nèi)拖入3臺(tái)電腦,用直通線和交換機(jī)連接 3,、打開(kāi)交換機(jī)屬性界面,,在命令行中輸入代碼,,劃分Vlan 10和Vlan 20兩個(gè)Vlan 代碼如下: 【 Switch>enable Switch#vlan database % Warning: It is recommended to configure VLAN from config mode, as VLAN database mode is being deprecated. Please consult user documentation for configuring VTP/VLAN in config mode. Switch(vlan)#vlan 10 name v10 VLAN 10 modified: Name: v10 Switch(vlan)#vlan 20 name v20 VLAN 20 modified: Name: v20 Switch(vlan)#exit 4、設(shè)置vlan10和Vlan20的默認(rèn)地址池和網(wǎng)關(guān)dns,,代碼如下: 【 Switch(config)#ip dhcp pool vlan10 *設(shè)置相應(yīng)的VLAN Switch(dhcp-config)#default-router 192.168.1.254 *設(shè)置該地址池的默認(rèn)網(wǎng)關(guān) Switch(dhcp-config)#network 192.168.1.0 255.255.255.0 *設(shè)置分配的地址池 Switch(dhcp-config)#dns-server 202.1.1.1 *設(shè)置該地址池的默認(rèn)DNS地址,。 Switch(dhcp-config)#ip dhcp pool vlan20 Switch(dhcp-config)#default-router 192.168.2.254 Switch(dhcp-config)#network 192.168.2.0 255.255.255.0 Switch(dhcp-config)#dns-server 202.1.1.2 Switch(dhcp-config)#ip dhcp pool vlan30 Switch(dhcp-config)#default-router 192.168.3.254 Switch(dhcp-config)#network 192.168.3.0 255.255.255.0 Switch(dhcp-config)#exit 5、 將交換機(jī)0/1和0/2端口加入Vlan10,;0/3端口加入Vlan20,代碼如下 【 Switch(config)#interface range f0/1 -2 Switch(config-if-range)#switchport access vlan 10 Switch(config-if-range)#interface range f0/3 Switch(config-if-range)#switchport access vlan 20 6,、配置完成,,我們打開(kāi)主機(jī)0,讓其主動(dòng)獲取ip,,點(diǎn)擊【ip配置】 7,、在同一Vlan的主機(jī)0和主機(jī)1可以ping通 下面附上全部代碼 【 交換機(jī)的配置:
Switch>enable Switch#vlan database % Warning: It is recommended to configure VLAN from config mode, as VLAN database mode is being deprecated. Please consult user documentation for configuring VTP/VLAN in config mode. Switch(vlan)#vlan 10 name v10 VLAN 10 modified: Name: v10 Switch(vlan)#vlan 20 name v20 VLAN 20 modified: Name: v20 Switch(vlan)#vlan 30 name v30 VLAN 30 modified: Name: v30 Switch(vlan)#exit APPLY completed. Exiting.... Switch# Switch(config)#ip dhcp pool vlan10 *設(shè)置相應(yīng)的VLAN Switch(dhcp-config)#default-router 192.168.1.254 *設(shè)置該地址池的默認(rèn)網(wǎng)關(guān) Switch(dhcp-config)#network 192.168.1.0 255.255.255.0 *設(shè)置分配的地址池 Switch(dhcp-config)#dns-server 202.1.1.1 *設(shè)置該地址池的默認(rèn)DNS地址。 Switch(dhcp-config)#ip dhcp pool vlan20 Switch(dhcp-config)#default-router 192.168.2.254 Switch(dhcp-config)#network 192.168.2.0 255.255.255.0 Switch(dhcp-config)#dns-server 202.1.1.2 Switch(dhcp-config)#ip dhcp pool vlan30 Switch(dhcp-config)#default-router 192.168.3.254 Switch(dhcp-config)#network 192.168.3.0 255.255.255.0 Switch(dhcp-config)#exit Switch(config)#ip dhcp excluded-address 192.168.3.2 192.168.3.10 *設(shè)置保留地址,,此條命令不是保留192.168.3.2與192.168.3.10兩個(gè)地址,,而是保留192.168.3.2至192.168.3.10的全部地址。 Switch(config)#ip dhcp excluded-address 192.168.2.1 *保留單一的一個(gè)地址,。 Switch(config)# Switch(config)#interface range f 0/1 -24 Switch(config-if-range)#spanning-tree portfast Switch(config-if-range)#exit Switch(config)#int f 0/1 Switch(config-if)#switchport access vlan 10 Switch(config-if)#int f 0/2 Switch(config-if)#switchport access vlan 20 Switch(config-if)#int range f 0/3 -5 Switch(config-if-range)#switchport access vlan 30 Switch(config-if-range)#exit Switch(config)# Switch(config)#interface vlan 10 %LINK-5-CHANGED: Interface Vlan10, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to up Switch(config-if)#ip add 192.168.1.254 255.255.255.0 Switch(config-if)#interface vlan 20 %LINK-5-CHANGED: Interface Vlan20, changed state to up Switch(config-if)#ip add 192.168.2.254 255.255.255.0 Switch(config-if)#interface vlan 30 %LINK-5-CHANGED: Interface Vlan30, changed state to up Switch(config-if)#ip add 192.168.3.254 255.255.255.0 Switch(config-if)#exit Switch(config)#ip routing 】 |
|
來(lái)自: skyline6x5mygb > 《思科》