1. 程式人生 > >cisco交換機開啟dhcp服務

cisco交換機開啟dhcp服務

cisco、dhcp


拓撲圖如下:

技術分享

上述設備用途說明:

1、使用R1做dhcp server

2、使用R2和R3代替電腦做dhcp client

3、SW1用做傻瓜交換機。


dhcp server配置(R1配置):

R1#disable
#############使用 disable 命令退出特權模式

R1>
R1>enable 
#############使用 enable 命令進入特權模式
   
R1#show privilege 
Current privilege level is 15
#############查看特權模式的級別

############# 進入配置模式
R1#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#exit

#############查看接口狀態
R1#show ip interface brief
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            unassigned      YES unset  administratively down down    
FastEthernet0/1            unassigned      YES unset  administratively down down    
Serial1/0                  unassigned      YES unset  administratively down down    
Serial1/1                  unassigned      YES unset  administratively down down    
Serial1/2                  unassigned      YES unset  administratively down down    
Serial1/3                  unassigned      YES unset  administratively down down    

R1#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.

#############進入接口進行配置
R1(config)#int fastEthernet 0/0

R1(config-if)#no shutdown 
R1(config-if)#
*Aug  1 19:39:28.523: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Aug  1 19:39:29.523: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

R1(config-if)#ip address 123.1.1.1 255.255.255.0
R1(config-if)#
R1(config-if)#

#############在配置模式中查看接口狀態需要加 do 前綴
R1(config-if)#do show ip interface brief
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            123.1.1.1       YES manual up                    up      
FastEthernet0/1            unassigned      YES unset  administratively down down    
Serial1/0                  unassigned      YES unset  administratively down down    
Serial1/1                  unassigned      YES unset  administratively down down    
Serial1/2                  unassigned      YES unset  administratively down down    
Serial1/3                  unassigned      YES unset  administratively down down    
R1(config-if)#

#############也可使用 end 命令退出配置模式
R1(config-if)#end
R1#
R1#
*Aug  1 19:43:17.991: %SYS-5-CONFIG_I: Configured from console by console
R1#

R1#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.

#############開啟dhcp server 功能
R1(config)#service dhcp
R1(config)#ip dhcp pool R123

R1(dhcp-config)#network 123.1.1.0 255.255.255.0

#############將客戶端的網關指向 dhcp server 接口的IP
R1(dhcp-config)#default-router 123.1.1.1

#############將客戶端的DNS指向 dhcp server 接口的IP
R1(dhcp-config)#dns-server 123.1.1.1

#############設置租期為1天0時1分
R1(dhcp-config)#lease 1 0 1

#############配置域名為cisco.com
R1(dhcp-config)#domain-name cisco.com
R1(dhcp-config)#



dhcp client配置(R2和R3配置):

R2#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.

#############禁用ip routing路由轉發表,將路由器模擬為pc
R2(config)#no ip routing 

R2(config)#int fastEthernet 0/0 
R2(config-if)#no shutdown
R2(config-if)#
*Aug  1 19:07:41.279: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Aug  1 19:07:42.279: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

#############開啟dhcp動態獲取
R2(config-if)#ip address dhcp
R2(config-if)#
*Aug  1 19:11:47.891: %DHCP-6-ADDRESS_ASSIGN: Interface FastEthernet0/0 assigned DHCP address 123.1.1.2, mask 255.255.255.0, hostname R2

R2(config-if)#end

#############查看接口狀態
R2#show ip interface brief
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            123.1.1.2       YES DHCP   up                    up      
FastEthernet0/1            unassigned      YES unset  administratively down down    
Serial1/0                  unassigned      YES unset  administratively down down    
Serial1/1                  unassigned      YES unset  administratively down down    
Serial1/2                  unassigned      YES unset  administratively down down    
Serial1/3                  unassigned      YES unset  administratively down down    
R2#

#############查看單獨接口狀態
R2#show running-config interface fastEthernet 0/0
Building configuration...

Current configuration : 94 bytes
!
interface FastEthernet0/0
 ip address dhcp
 no ip route-cache
 duplex auto
 speed auto
end





本文出自 “甘木” 博客,請務必保留此出處http://ganmu.blog.51cto.com/9305511/1952781

cisco交換機開啟dhcp服務