cisco dhcp 配置
Cisco交换机配置DHCP方案

ip helper-address 192.168.0.69 DHCP Server IP
interface Vlan12
ip address 192.168.2.254 255.255.255.0
ip helper-address 192.168.0.69 DHCP Server IP
Switch(Config-pool)Dns-server 192.168.2.10
Switch(Config-pool)Default-router 192.168.3.1
/*配置VLAN 4所用的地址池和相应参数*/
Switch(Config)Ip Dhcp Pool Test03
Switch(Config-pool)Network 192.168.4.0 255.255.255.0
Switch(Config-vlan)No Shut
Switch(Config-vlan)>Int Vlan 3
Switch(Config-vlan)Ip Address 192.168.3.1 255.255.255.0
Switch(Config-vlan)No Shut
Switch(Config-vlan)>Int Vlan 4
安全要求:
VLAN 3和VLAN 4 不允许互相访问,但都可以访问服务器所在的VLAN 2,
默认访问控制列表的规则是拒绝所有包.
配置命令及步骤如下:
第一步:创建VLAN:
Switch>en
Switch#Vlan Database
Switch(Vlan)>Vlan 2 Name server
Switch(Config)Ip Dhcp Pool Test01
Cisco dhcp server 配置文档

Configuring DHCPThis chapter describes how to configure Dynamic Host Configuration Protocol(DHCP).For a completedescription of the DHCP commands listed in this chapter, refer to the “DHCP Commands” chapter ofthe Cisco IOS IP and IP Routing Command Reference publication. To locate documentation of othercommands that appear in this chapter, use the command reference master index or search online.As explained in RFC2131,Dynamic Host Configuration Protocol, DHCP provides configurationparameters to Internet hosts.DHCP consists of two components:a protocol for delivering host-specificconfiguration parameters from a DHCP server to a host and a mechanism for allocating networkaddresses to hosts.DHCP is built on a client/server model,where designated DHCP server hosts allocatenetwork addresses and deliver configuration parameters to dynamically configured hosts.DHCP supports three mechanisms for IP address allocation:•Automatic allocation—DHCP assigns a permanent IP address to a client.•Dynamic allocation—DHCP assigns an IP address to a client for a limited period of time (or until the client explicitly relinquishes the address).•Manual allocation—The network administrator assigns an IP address to a client and DHCP is used simply to convey the assigned address to the client.The format of DHCP messages is based on the format of Bootstrap Protocol(BOOTP)messages,whichensures support for BOOTP relay agent functionality and interoperability between BOOTP clients andDHCP servers. BOOTP relay agents eliminate the need for deploying a DHCP server on each physicalnetwork segment. BOOTP is explained in RFC951,Bootstrap Protocol (BOOTP), and RFC1542,Clarifications and Extensions for the Bootstrap Protocol.DHCP Server OverviewThe Cisco IOS DHCP server feature is a full DHCP server implementation that assigns and manages IPaddresses from specified address pools within the router to DHCP clients.If the Cisco IOS DHCP servercannot satisfy a DHCP request from its own database, it can forward the request to one or moresecondary DHCP servers defined by the network administrator.Figure14 shows the basic steps that occur when a DHCP client requests an IP address from a DHCPserver. The client, Host A, sends a DHCPDISCOVER broadcast message to locate a Cisco IOS DHCPserver.A DHCP server offers configuration parameters(such as an IP address,a MAC address,a domainname, and a lease for the IP address) to the client in a DHCPOFFER unicast message.Configuring DHCPDHCP Server Overview Figure 14DHCP Request for an IP Address from a DHCP Server Note A DHCP client may receive offers from multiple DHCP servers and can accept any one ofthe offers; however, the client usually accepts the first offer it receives. Additionally, theoffer from the DHCP server is not a guarantee that the IP address will be allocated to theclient;however,the server usually reserves the address until the client has had a chance toformally request the address.The client returns a formal request for the offered IP address to the DHCP server in a DHCPREQUESTbroadcast message. The DHCP server confirms that the IP address has been allocated to the client byreturning a DHCPACK unicast message to the client.Note The formal request for the offered IP address (the DHCPREQUEST message) that is sentby the client is broadcast so that all other DHCP servers that received theDHCPDISCOVER broadcast message from the client can reclaim the IP addresses that theyoffered to the client.If the configuration parameters sent to the client in the DHCPOFFER unicast message bythe DHCP server are invalid (a misconfiguration error exists), the client returns aDHCPDECLINE broadcast message to the DHCP server.The DHCP server will send to the client a DHCPNAK denial broadcast message, whichmeans the offered configuration parameters have not been assigned,if an error has occurredduring the negotiation of the parameters or the client has been slow in responding to theDHCPOFFER message (the DHCP server assigned the parameters to another client)of theDHCP server.The Cisco IOS DHCP server feature offers the following benefits:•Reduced Internet access costsUsing automatic IP address assignment at each remote site substantially reduces Internet accesscosts. Static IP addresses are considerably more expensive to purchase than are automaticallyallocated IP addresses.•Reduced client configuration tasks and cost sBecause DHCP is easy to configure, it minimizes operational overhead and costs associated withdevice configuration tasks and eases deployment by nontechnical users.•Centralized managementBecause the DHCP server maintains configurations for several subnets,an administrator only needsto update a single, central server when configuration parameters change.Host A DHCP ACK (unicast)DHCPREQUEST (broadcast)DHCPOFFER (unicast)DHCPDISCOVER (broadcast)Cisco IOS DHCP server 32369Configuring DHCPDHCP Configuration Task ListBefore you configure the Cisco IOS DHCP server feature, complete the following tasks:•Identify an external File Transport Protocol(FTP),Trivial File Transfer Protocol(TFTP),or remote copy protocol (rcp) server that you will use to store the DHCP bindings database.•Identify the IP addresses that you will enable the DHCP server to assign,and the IP addresses that you will exclude.•Identify DHCP options for devices where necessary, including:–Default boot image name–Default router(s)–Domain Name System (DNS) server(s)–NetBIOS name server•Decide on a NetBIOS node type (b, p, m, or h).•Decide on a DNS domain name.DHCP Configuration Task ListThe DHCP server database is organized as a tree. The root of the tree is the address pool for naturalnetworks, branches are subnetwork address pools, and leaves are manual bindings to clients.Subnetworks inherit network parameters and clients inherit subnetwork parameters.Therefore,commonparameters,for example the domain name,should be configured at the highest(network or subnetwork)level of the tree.Note Inherited parameters can be overridden.For example,if a parameter is defined in both thenatural network and a subnetwork, the definition of the subnetwork is used.Address leases are not inherited.If a lease is not specified for an IP address,by default,theDHCP server assigns a one-day lease for the address.To configure the Cisco IOS DHCP server feature, first configure a database agent or disable conflictlogging, then configure IP addresses that the DHCP server should not assign (excluded addresses) andshould assign (a pool of available IP addresses) to requesting clients. These configuration tasks areexplained in the following sections. Each task in the following list is identified as required or optional.•Configuring a DHCP Database Agent or Disabling DHCP Conflict Logging (Required)•Excluding IP Addresses (Required)•Configuring a DHCP Address Pool (Required)•Configuring Manual Bindings (Optional)•Configuring a DHCP Server Boot File (Optional)•Configuring the Number of Ping Packets (Optional)•Configuring the Timeout Value for Ping Packets (Optional)•Enabling the Cisco IOS DHCP Server and Relay Agent Features (Optional)Configuring DHCPDHCP Configuration Task List Configuring a DHCP Database Agent or Disabling DHCP Conflict LoggingA DHCP database agent is any host, for example, an FTP, TFTP, or RCP server that stores the DHCPbindings database.You can configure multiple DHCP database agents and you can configure the intervalbetween database updates and transfers for each agent.To configure a database agent and database agentparameters, use the following command in global configuration mode:If you choose not to configure a DHCP database agent,disable the recording of DHCP address conflictson the DHCP server. To disable DHCP address conflict logging, use the following command in globalconfiguration mode:Excluding IP AddressesThe DHCP server assumes that all IP addresses in a DHCP address pool subnet are available forassigning to DHCP clients. You must specify the IP address that the DHCP server should not assign toclients. To do so, use the following command in global configuration mode:Configuring a DHCP Address PoolYou can configure a DHCP address pool with a name that is a symbolic string (such as “engineering”)or an integer (such as 0).Configuring a DHCP address pool also places you in DHCP pool configurationmode—identified by the (config-dhcp)# prompt—from which you can configure pool parameters (forexample,the IP subnet number and default router list).To configure a DHCP address pool,complete therequired tasks in the following sections.Configuring the DHCP Address Pool Name and Entering DHCP Pool Configuration ModeTo configure the DHCP address pool name and enter DHCP pool configuration mode,use the followingcommand in global configuration mode:CommandPurpose Router(config)#ip dhcp database url[timeout seconds | write-delay seconds ]Configures the database agent and the interval between database updates and database transfers.CommandPurpose Router(config)#no ip dhcp conflict logging Disables DHCP address conflict logging.CommandPurpose Router(config)#ip dhcp excluded-addresslow-address [high-address ]Specifies the IP addresses that the DHCP server should not assign to DHCP clients.CommandPurpose Router(config)# ip dhcp pool name Creates a name for the DHCP server address pool and places you in DHCPpool configuration mode (identified by the config-dhcp# prompt).Configuring DHCPDHCP Configuration Task List Configuring the DHCP Address Pool Subnet and MaskTo configure a subnet and mask for the newly created DHCP address pool,which contains the range of available IP addresses that the DHCP server may assign to clients,use the following command in DHCP pool configuration mode:Note You can not configure manual bindings within the same pool that is configured with thenetwork command.To configure manual bindings,see the “Configuring Manual Bindings”section.Configuring the Domain Name for the ClientThe domain name for a DHCP client places the client in the general grouping of networks that make up the domain.To configure a domain name string for the client,use the following command in DHCP pool configuration mode:Configuring the Domain Name System IP Servers for the ClientDHCP clients query DNS IP servers when they need to correlate host names to IP addresses. Toconfigure the DNS IP servers that are available to a DHCP client,use the following command in DHCP pool configuration mode:Configuring the NetBIOS Windows Internet Naming Service IP Servers for the ClientWindows Internet Naming Service (WINS)is a name resolution service that Microsoft DHCP clients use to correlate host names to IP addresses within a general grouping of networks.To configure the NetBIOS WINS servers that are available to a Microsoft DHCP client,use the following command in DHCP pool configuration mode:CommandPurpose Router(config-dhcp)#network network-number[mask |/prefix-length ]Specifies the subnet network number and mask of the DHCP address pool.The prefix length specifies the number of bits that comprise theaddress prefix. The prefix is an alternative way of specifying thenetwork mask of the client.The prefix length must be preceded bya forward slash (/).CommandPurpose Router(config-dhcp)#domain-name domain Specifies the domain name for the client.CommandPurpose Router(config-dhcp)#dns-server address[address2...address8]Specifies the IP address of a DNS server that is available to a DHCP client.One IP address is required; however, you can specify up to eight IPaddresses in one command line.Configuring DHCPDHCP Configuration Task List Configuring the NetBIOS Node Type for the ClientThe NetBIOS node type for Microsoft DHCP clients can be one of four settings:broadcast,peer-to-peer,mixed, or hybrid. To configure the NetBIOS node type for a Microsoft DHCP, use the followingcommand in DHCP pool configuration mode:Configuring the Default Router for the ClientAfter a DHCP client has booted, the client begins sending packets to its default router. The IP address of the default router should be on the same subnet as the client.To configure a default router for a DHCP client, use the following command in DHCP pool configuration mode:Configuring the Address Lease TimeBy default,each IP address assigned by a DHCP server comes with a one-day lease,which is the amount of time that the address is valid.To change the lease value for an IP address,use the following command in DHCP pool configuration mode:Configuring Manual BindingsAn address binding is a mapping between the IP address and MAC address of a client. The IP address of a client can be assigned manually by an administrator or assigned automatically from a pool by aDHCP server.Manual bindings are IP addresses that have been manually mapped to the MAC addresses of hosts that are found in the DHCP database.Manual bindings are stored in NVRAM on the DHCP server.Manual bindings are just special address pools.There is no limit on the number of manual bindings but you can only configure one manual binding per host pool.CommandPurpose Router(config-dhcp)#netbios-name-serveraddress [address2...address8]Specifies the NetBIOS WINS server that is available to a Microsoft DHCP client. One address is required; however, you can specify up toeight addresses in one command line.CommandPurpose Router(config-dhcp)#netbios-node-type type Specifies the NetBIOS node type for a Microsoft DHCP mandPurpose Router(config-dhcp)#default-routeraddress [address2... address8]Specifies the IP address of the default router for a DHCP client. One IP address is required,although you can specify up to eight addresses in onecommand line.CommandPurpose Router(config-dhcp)# lease {days[hours ][minutes ]| infinite }Specifies the duration of the lease. The default is a one-day lease.Configuring DHCPDHCP Configuration Task List Automatic bindings are IP addresses that have been automatically mapped to the MAC addresses of hoststhat are found in the DHCP database.Automatic bindings are stored on a remote host called a databaseagent. The bindings are saved as text records for easy maintenance.To configure a manual binding, first create a host pool, then specify the IP address of the client andhardware address or client identifier. The hardware address is the MAC address. The client identifier,which is required for Microsoft clients(instead of hardware addresses),is formed by concatenating themedia type and the MAC address of the client. Refer to the “Address Resolution Protocol Parameters”section of RFC1700,Assigned Numbers, for a list of media type codes.To configure manual bindings, use the following commands beginning in global configuration mode:Command PurposeStep1Router(config)# ip dhcp pool name Creates a name for the a DHCP server address pool and places youin DHCP pool configuration mode—identified by the(config-dhcp)# prompt.Step2Router(config-dhcp)#host address [mask| /prefix-length]Specifies the IP address and subnet mask of the client.The prefix length specifies the number of bits that comprise the address prefix. The prefix is an alternative way of specifying the network mask of the client.The prefix length must be preceded by a forward slash(/).Step3Router(config-dhcp)# hardware-address hardware-address typeorRouter(config-dhcp)#client-identifierunique-identifier Specifies a hardware address for the client.The type value:•Indicates the protocol of the hardware platform. Strings and values are acceptable. The string options are:–ethernet–ieee802•The value options are:– 1 10Mb Ethernet– 6 IEEE 802If no type is specified, the default protocol is Ethernet.orSpecifies the distinct identification of the client in dotted hexadecimal notation, for example, 01b7.0813.8811.66, where 01 represents the Ethernet media type.Step4Router(config-dhcp)# client-name name(Optional) Specifies the name of the client using any standardASCII character. The client name should not include the domainname. For example, the name mars should not be specified as.Configuring DHCP DHCP Configuration Task ListConfiguring a DHCP Server Boot FileThe boot file is used to store the boot image for the client. The boot image is generally the operatingsystem the client uses to load.To specify a boot file for the DHCP client,use the following command inDHCP pool configuration mode:Command PurposeRouter(config-dhcp)# bootfile filename Specifies the name of the file that is used as a boot image. Configuring the Number of Ping PacketsBy default, the DHCP server pings a pool address twice before assigning the address to a requestingclient.If the ping is unanswered,the DHCP server assumes(with a high probability)that the address isnot in use and assigns the address to the requesting client. To change the number of ping packets theDHCP server should send to the pool address before assigning the address,use the following commandin global configuration mode:Command PurposeRouter(config)#ip dhcp ping packets number Specifies the number of ping packets the DHCP server sends to a pooladdress before assigning the address to a requesting client.The defaultis two packets.Configuring the Timeout Value for Ping PacketsBy default, the DHCP server waits 500milliseconds before timing out a ping packet. To change theamount of time the server waits, use the following command in global configuration mode:Command PurposeRouter(config)# ip dhcp ping timeout milliseconds Specifies the amount of time the DHCP server must wait beforetiming out a ping packet. The default 500 milliseconds. Enabling the Cisco IOS DHCP Server and Relay Agent FeaturesBy default,the Cisco IOS DHCP server and relay agent features are enabled on your router.To reenablethese features if they are disabled, use the following command in global configuration mode:Command PurposeRouter(config)#service dhcp Enables the Cisco IOS DHCP server and relay features on your router.Use the no form of this command to disable the Cisco IOS DHCP server and relayfeatures.Configuring DHCPMonitoring and Maintaining the DHCP ServerMonitoring and Maintaining the DHCP ServerTo clear DHCP server variables, use the following commands in privileged EXEC mode, as needed:Command PurposeRouter#clear ip dhcp binding address |*Deletes an automatic address binding from the DHCP database.Specifying address clears the automatic binding for a specific(client)IPaddress, whereas specifying asterisk (*) clears all automatic bindings. Router#clear ip dhcp conflict address |*Clears an address conflict from the DHCP database.Specifying addressclears the conflict for a specific IP address whereas specifying an asterisk(*) clears conflicts for all addresses.Router#clear ip dhcp server statistics Resets all DHCP server counters to 0.To enable DHCP server debugging, use the following command in privileged EXEC mode:Command PurposeRouter# debug ip dhcp server{events | packets | linkage}Enables debugging on the DHCP server.To display DHCP server information, use the following commands in EXEC mode, as needed:Command PurposeRouter> show ip dhcp binding[address]Displays a list of all bindings created on a specific DHCP server. Router> show ip dhcp conflict[address]Displays a list of all address conflicts recorded by a specific DHCP server. Router#show ip dhcp database[url]Displays recent activity on the DHCP database.Note Use this command in privileged EXEC mode.Router> show ip dhcp server statistics Displays count information about server statistics and messages sent andreceived.Configuration ExamplesThis section provides the following configuration examples:•DHCP Database Agent Configuration Example•DHCP Address Pool Configuration Example•Manual Bindings Configuration ExampleConfiguring DHCPConfiguration Examples DHCP Database Agent Configuration ExampleThe following example stores bindings on host 172.16.4.253. The file transfer protocol is FTP. Theserver should wait 2 minutes (120 seconds) before writing database changes.ip dhcp database ftp://user:password@172.16.4.253/router-dhcp write-delay 120DHCP Address Pool Configuration ExampleIn the following example, three DHCP address pools are created: one in network 172.16.0.0, one insubnetwork 172.16.1.0,and one in subnetwork 172.16.2.0.Attributes from network 172.16.0.0,such as the domain name, DNS server, NetBIOS name server, and NetBIOS node type, are inherited insubnetworks 172.16.1.0and 172.16.2.0.In each pool,clients are granted 30-day leases and all addresses in each subnetwork, except the excluded addresses, are available to the DHCP server for assigning toclients. Table 5 lists the IP addresses for the devices in three DHCP address pools.ip dhcp database ftp://user:password@172.16.4.253/router-dhcp write-delay 120ip dhcp excluded-address 172.16.1.100 172.16.1.103ip dhcp excluded-address 172.16.2.100 172.16.2.103!ip dhcp pool 0network 172.16.0.0 /16domain-name dns-server 172.16.1.102 172.16.2.102netbios-name-server 172.16.1.103 172.16.2.103netbios-node-type h-node!ip dhcp pool 1network 172.16.1.0 /24default-router 172.16.1.100 172.16.1.101lease 30!ip dhcp pool 2network 172.16.2.0 /24default-router 172.16.2.100 172.16.2.101lease 30T able 5DHCP Address Pool DevicesPool 0 (Network 172.16.0.0)Pool 1 (Subnetwork 172.16.1.0)Pool 2 (Subnetwork 172.16.2.0)DeviceIP Address Device IP Address Device IP Address Default routers–Default routers 172.16.1.100172.16.1.101Default routers 172.16.2.100172.16.2.101DNS server 172.16.1.102—172.16.2.102————NetBIOS name server 172.16.1.103—172.16.2.103————NetBIOS node type h-node ————Configuring DHCPConfiguration ExamplesManual Bindings Configuration ExampleThe following example creates a manual binding for a client named .The MAC addressof the client is 02c7.f800.0422 and the IP address of the client is 172.16.2.254.ip dhcp pool Marshost 172.16.2.254hardware-address 02c7.f800.0422 ieee802client-name MarsBecause attributes are inherited, the previous configuration is equivalent to the following:ip dhcp pool Marshost 172.16.2.254 mask 255.255.255.0hardware-address 02c7.f800.0422 ieee802client-name Marsdefault-router 172.16.2.100 172.16.2.101domain-name dns-server 172.16.1.102 172.16.2.102netbios-name-server 172.16.1.103 172.16.2.103netbios-node-type h-nodeCisco IOS IP and IP Routing Configuration GuideP1C-73Configuring DHCP Configuration ExamplesCisco IOS IP and IP Routing Configuration GuideP1C-74。
Cisco路由器DHCP配置过程全解析

2600路由器我们标识为:Cisco进入全局模式Cisco(config)#ip dhcp pool server "server"为DHCP服务标识名,不属于命令Cisco(dhcp-config)#network 192.168.1.0 255.255.255.0Cisco(dhcp-config)#default-router 192.168.1.1Cisco(dhcp-config)#dns-server 202.96.209.5 202.96.209.133到此,基本的DHCP功能已经实现,但又有一个问题,当局域网内有一部分电脑已经手动配置过IP后,如果手动配置的电脑没有开机,其他电脑通过DHCP获取了相同的IP地址后,手动配置的电脑开机,那就会造成IP冲突。
不要紧,下面的步骤可以帮助我们解决问题。
回到全局模式Cisco(config)#ip dhcp pool client0 "client0"为另一DHCP服务标识名,使具体的IP可以映射固定的MACCisco(dhcp-config)#host 192.168.1.20 255.255.255.0Cisco(dhcp-config)#client-identifier 0100.d0b7.1af8.4f 注意“01”不为MAC地址,是用来标记MAC属于局域网的备注,添加的client0只能标识一个IP对应MAC的映射,如要标识多个IP映射MAC,需要增加多个DHCP服务标识名,如(client1,client2,client3.......)最后一个问题,局域网内一部分IP可能是用来分配给文件服务器等固定电脑的,就需要将这一部分IP预留,解决方法如下:Cisco(config)#ip dhcp excluded-address 192.168.1.1 192.168.1.10"1...10"标识从192.168.1.1到192.168.1.10之间的地址将不会被自动分配,这个地址段可以根据实际情况进行设定。
思科DHCP 服务器&IP Helper Address 实验

DHCP服务器&IP Helper Address实验讲义一.实验目的本实验的目的是让学员掌握在路由器上配置DHCP服务器的方法,并通过配置帮助地址将客户向DHCP服务器发出的广播转发成定点广播,以通过路由器到达服务器。
二.实验设备Cisco路由器两部(1600系列一部,1700系列一部),带超级终端的PC机两台。
三.实验拓朴四.实验步骤1.配置路由器端口的IP地址:1)Cisco1600的配置:Cisco1600#config tCisco1600 (config)#int e0Cisco1600 (config-if)#ip address 192.168.1.1 255.255.255.0Cisco1600 (config-if)#no shutCisco1600 (config-if)#int s0Cisco1600 (config-if)#ip address 192.168.3.1 255.255.255.0Cisco1600 (config-if)#clock rate 56000Cisco1600(config-if)#no shut2)Cisco1700的配置:Cisco1700#config tCisco1700 (config)#int e0Cisco1700 (config-if)#ip address 192.168.2.1 255.255.255.0Cisco1700 (config-if)#no shutCisco1700 (config-if)#int s0Cisco1700 (config-if)#ip address 192.168.3.2 255.255.255.0Cisco1700(config-if)#no shut2.使用RIP协议作为该网络的路由协议,实现网络的动态路由配置。
完成配置后使用show ip route,show interface,show running-configuration查看路由配置的正确性或者使用ping命令验证网络之间是否完全互连。
思科cisco路由器dhcp动态分配ip地址实现方法

思科cisco路由器dhcp动态分配ip地址实现⽅法本⽂实例讲述了思科cisco路由器dhcp动态分配ip地址实现⽅法。
分享给⼤家供⼤家参考,具体如下:⼀、拓扑图Router1 F0/0 <----> Switch5 F0/0Router1 E1/0 <----> VPCS V0/5Switch5 F0/1 <----> Switch1 F0/0Switch5 F0/2 <----> Switch2 F0/0Switch5 F0/3 <----> Switch3 F0/0Switch5 F0/4 <----> Switch4 F0/0Switch1 F0/1 <----> VPCS V0/1Switch2 F0/1 <----> VPCS V0/2Switch3 F0/1 <----> VPCS V0/3⼆、dhcp服务器就是通过主机分配ip的⼀项服务。
路由是通过那个⼝来分配的。
接⼏个分配⼏个。
要使客户机能从⽤作DHCP Server的路由器中⾃动获得IP地址。
三、实验要求:1、vlan之间的通信通过三层交换机来实现2、路由器为4个vlan来分配ip地址3、pc1 - 4分别属于4个部门,能够⾃动得到ip地址4、pc1 - 5直接可以ping通四、实验思路:1、⾸先配置⼆层交换机上的vlan、trunk并把接⼝加⼊vlan2、三层交换中配置vlan、trunk并启⽤ip routing路由功能3、三层交换中配置vlan ip地址,三层交换机是带有三层路由功能的交换机,也就是这台交换机的端⼝既有三层路由功能,也具有⼆层交换功能。
三层交换机端⼝默认为⼆层⼝,如果需要启⽤三层功能就需要在此端⼝输⼊no switchport命令。
运⾏router rip协议(其他协议也⾏)查看路由表 show ip router4、配置路由器dhcp服务建⽴地址持ip dhcp pool apple(apple为地址池名称可以随便起)运⾏router rip协议5、保存设置:在全局配置模式下 Router#copy running-config startup-config //保存当前的配置或 Router#write 也⾏6、查看!五、实验过程:1、配置⼆层交换机valn trunk 并将接⼝加⼊vlansw1#vlan datasw1#vlan databasesw1(vlan)#vlan 10VLAN 10 added:Name: VLAN0010sw1(vlan)#exitAPPLY completed.Exiting....sw1#conf tEnter configuration commansw1(config)#interface f0/0sw1(config-if)#sw m tsw1(config-if)#interface f0/1sw1(config-if)#sw ac vlan 10sw1(config-if)#exitsw1(config)#exitsw1#show vlan-switchsw2 - 4相同配置2、配置三层交换(vlan、trunk、vlan ip)sw3-1#vlan dasw3-1(vlan)#vlan 10VLAN 10 added:Name: VLAN0010sw3-1(vlan)#vlan 20VLAN 20 added:Name: VLAN0020sw3-1(vlan)#vlan 30VLAN 30 added:Name: VLAN0030sw3-1(vlan)#vlan 40VLAN 40 added:Name: VLAN0040sw3-1(config)#ip routing 在三层交换中启动路由功能sw3-1(config)#interface vlan 10sw3-1(config-if)#ip ad 192.168.1.1 255.255.255.0 配置vlan ipsw3-1(config-if)#no shutsw3-1(config-if)#exitsw3-1(config)#interface vlan 20sw3-1(config-if)#ip ad 192.168.2.1 255.255.255.0sw3-1(config-if)#no shutsw3-1(config-if)#exitsw3-1(config)#interface vlan 30sw3-1(config-if)#ip address 192.168.3.1 255.255.255.0sw3-1(config-if)#no shutsw3-1(config-if)#interface vlan 40sw3-1(config-if)#ip ad 192.168.4.1 255.255.255.0sw3-1(config-if)#no shutsw3-1(config-if)#exitsw3-1(config)#interface rang f0/1 - 4 配置trunksw3-1(config-if-range)#sw m tsw3-1(config-if-range)#exitsw3-1(config)#interface f0/0sw3-1(config-if)#no switchport 启动三层接⼝sw3-1(config)#interface f0/0sw3-1(config-if)#ip address 10.0.0.1 255.0.0.0 配置接⼝ipsw3-1(config-if)#no shutsw3-1(config)#ip route 0.0.0.0 0.0.0.0 10.0.0.3 配置默认路由sw3-1(config)#router rip 启⽤rip协议sw3-1(config-router)#network 192.168.1.0sw3-1(config-router)#network 192.168.2.0sw3-1(config-router)#network 192.168.3.0sw3-1(config-router)#network 192.168.4.0sw3-1(config-router)#network 10.0.0.0查看路由表3、配置dhcp路由器dhcp(config)#interface f0/0dhcp(config-if)#ip addressdhcp(config-if)#ip address 10.0.0.3 255.0.0.0dhcp(config-if)#interface 192.168.237.1 255.255.255.0dhcp(config)#inte e1/0dhcp(config-if)#ip add 192.168.237.1 255.255.255.0dhcp(config-if)#no shutdhcp(config-if)#exitdhcp(config)#router ripdhcp(config-router)#network 10.0.0.0dhcp(config-router)#network 192.168.237.0show ip route 同上dhcp(config)#ip dhcp pool apple 建⽴地址池dhcp(dhcp-config)#network 192.168.0.0 255.255.0.04、在三层交换指定dhcp服务器即路由器的ip 地址。
CiscoDHCP配置方法

CiscoDHCP配置⽅法⾸先假设两台思科路由器,R1(服务端)连接R2(客户端),组成⼀个简单的链式局域⽹,下⾯就来实现DHCP,配置的命令及其解释如下:1、R1 dhcp服务的配置dhcp#configure terminal //进⼊全局模式dhcp(config)#service dhcp //打开dhcp功能dhcp(config)#no ip dhcp conflictlogging //关闭dhcp⽇志记录dhcp(config)#ip dhcp pool cisco //配置dhcp服务器的名称为ciscodhcp(dhcp-config)#network 192.168.1.0 255.255.255.0 //配置dhcp服务器要分配的⽹段dhcp(dhcp-config)#default-router 192.168.1.1 //配置默认⽹关为192.168.1.1dhcp(dhcp-config)#dns-server 192.168.1.1 //配置dns服务器为192.168.1.1dhcp(dhcp-config)#lease 3 //地址租⽤期限: 3天dhcp(dhcp-config)#exit //退出dhcp配置模式dhcp(config)#ip dhcp excluded-address 192.168.1.200 192.168.1.254 //配置dhcp不分配的地址2、R2客户端获取IP地址Client#configureterminal //进⼊全局模式dhcp(config)#interfacefastethernet0/0 //进⼊fastethernet0/0接⼝dhcp(config-if)#ip address dhcp //从dhcp服务器获取IP地址实例Cisco设备上设置DHCP实例⼀位客户想把DHCP SERVER迁移到6509交换机的MSFC上,要求还挺复杂:1.同时为多个VLAN的客户机分配地址2.VLAN内有部分地址采⽤⼿⼯分配的⽅式3.为客户指定⽹关、Wins服务器等4.VLAN 2的地址租⽤有效期限为1天,其它为3天5.按MAC地址为特定⽤户分配指定的IP地址最终配置如下:ip dhcp excluded-address 10.1.1.1 10.1.1.19 //不⽤于动态地址分配的地址ip dhcp excluded-address 10.1.1.240 10.1.1.254ip dhcp excluded-address 10.1.2.1 10.1.2.19!ip dhcp pool global //global是pool name,由⽤户指定network 10.1.0.0 255.255.0.0 //动态分配的地址段domain-name //为客户机配置域后缀dns-server 10.1.1.1 10.1.1.2 //为客户机配置dns服务器netbios-name-server 10.1.1.5 10.1.1.6 //为客户机配置wins服务器netbios-node-type h-node //为客户机配置节点模式(影响名称解释的顺利,如h-node=先通过wins服务器解释...)lease 3 //地址租⽤期限: 3天ip dhcp pool vlan1network 10.1.1.0 255.255.255.0 //本pool是global的⼦pool, 将从global pool继承domain-name等optiondefault-router 10.1.1.100 10.1.1.101 //为客户机配置默认⽹关!ip dhcp pool vlan2 //为另⼀VLAN配置的poolnetwork 10.1.2.0 255.255.255.0default-router 10.1.2.100 10.1.2.101lease 1!ip dhcp pool vlan1_john //总是为MAC地址为...的机器分配...地址host 10.1.1.21 255.255.255.0client-identifier 010050.bade.6384 //client-identifier=01加上客户机⽹卡地址!ip dhcp pool vlan1_tomhost 10.1.1.50 255.255.255.0client-identifier 010010.3ab1.eac8相关的DHCP调试命令:no service dhcp //停⽌DHCP服务[默认为启⽤DHCP服务]sh ip dhcp binding //显⽰地址分配情况show ip dhcp conflict //显⽰地址冲突情况clear ip dhcp binding 192.168.1.2 //清理已经分配的IPdebug ip dhcp server {events | packets | linkage} //观察DHCP服务器⼯作情况如果DHCP客户机分配不到IP地址,常见的原因有两个。
cisco-DHCP及相关命令

目录第1章DHCP配置命令 ............................................................. 1-11.1 DHCP服务器配置命令 ..................................................................... 1-11.1.1 bootfile...................................................................................................... 1-11.1.2 clear ip dhcp binding .............................................................................. 1-11.1.3 clear ip dhcp conflict .............................................................................. 1-21.1.4 clear ip dhcp server statistics ............................................................... 1-21.1.5 client-identifier ........................................................................................ 1-31.1.6 client-name .............................................................................................. 1-31.1.7 debug ip dhcp server .............................................................................. 1-31.1.8 default-router ........................................................................................... 1-41.1.9 dns-server ................................................................................................ 1-41.1.10 domain-name ......................................................................................... 1-41.1.11 hardware-address ................................................................................. 1-51.1.12 host ......................................................................................................... 1-51.1.13 ip dhcp conflict logging ....................................................................... 1-61.1.14 ip dhcp excluded-address .................................................................... 1-71.1.15 ip dhcp pool ........................................................................................... 1-71.1.16 ip dhcp conflict ping-detection enable ............................................... 1-71.1.17 ip dhcp ping packets ............................................................................ 1-81.1.18 ip dhcp ping timeout ............................................................................. 1-81.1.19 lease ....................................................................................................... 1-91.1.20 netbios-name-server ............................................................................. 1-91.1.21 netbios-node-type ...............................................................................1-101.1.22 network-address .................................................................................1-101.1.23 next-server ........................................................................................... 1-111.1.24 option ................................................................................................... 1-111.1.25 service dhcp ........................................................................................1-121.1.26 show ip dhcp binding .........................................................................1-121.1.27 show ip dhcp conflict .........................................................................1-131.1.28 show ip dhcp server statistics ...........................................................1-13第2章DHCP snooping 配置命令 ........................................... 2-12.1 debug ip dhcp snooping packet interface .................................... 2-12.2 debug ip dhcp snooping packet .................................................... 2-12.3 debug ip dhcp snooping update ................................................... 2-12.4 debug ip dhcp snooping event ...................................................... 2-22.5 debug ip dhcp snooping binding .................................................. 2-22.6 ip dhcp snooping ............................................................................ 2-22.7 ip dhcp snooping binding .............................................................. 2-32.8 ip dhcp snooping binding user ..................................................... 2-32.9 ip dhcp snooping binding arp ....................................................... 2-42.10 ip dhcp snooping binding dot1x ................................................. 2-42.11 ip dhcp snooping binding user-control ...................................... 2-52.12 ip dhcp snooping binding user-control max-user ..................... 2-52.13 ip dhcp snooping trust ................................................................. 2-62.14 ip dhcp snooping action .............................................................. 2-72.15 ip dhcp snooping action MaxNum .............................................. 2-72.16 ip dhcp snooping limit-rate .......................................................... 2-82.17 ip dhcp snooping information enable ......................................... 2-82.18 ip dhcp snooping option82 enable .............................................. 2-92.19 enable trustview key ................................................................... 2-102.20 ip user private packet version two ............................................ 2-10 2.21 ip user helper-address ............................................................... 2-11 2.22 show trustview status ................................................................ 2-12 2.23 show ip dhcp snooping .............................................................. 2-12第1章DHCP配置命令1.1 DHCP服务器配置命令1.1.1 bootfile命令:bootfile <filename>no bootfile功能:配置DHCP客户机启动时的导入文件名;本命令的no操作删除配置的导入文件。
cisco DHCP

CISCO的路由器(IOS12.0 T1以后),可以配置为dhcp的中继设备,DHCP的客户端设备,也可以配置为DHCP的服务器。
Cisco设备上设置DHCP实例一位客户想把DHCP SERVER迁移到6509交换机的MSFC上,要求还挺复杂:1.同时为多个VLAN的客户机分配地址2.VLAN内有部分地址采用手工分配的方式3.为客户指定网关、Wins服务器等4.VLAN 2的地址租用有效期限为1天,其它为3天5.按MAC地址为特定用户分配指定的IP地址最终配置如下:ip dhcp excluded-address 10.1.1.1 10.1.1.19 //不用于动态地址分配的地址ip dhcp excluded-address 10.1.1.240 10.1.1.254ip dhcp excluded-address 10.1.2.1 10.1.2.19!ip dhcp pool global //global是pool name,由用户指定network 10.1.0.0 255.255.0.0 //动态分配的地址段domain-name //为客户机配置域后缀dns-server 10.1.1.1 10.1.1.2 //为客户机配置dns服务器netbios-name-server 10.1.1.5 10.1.1.6 //为客户机配置wins服务器netbios-node-type h-node //为客户机配置节点模式(影响名称解释的顺利,如h-node=先通过wins服务器解释...)lease 3 //地址租用期限: 3天ip dhcp pool vlan1network 10.1.1.0 255.255.255.0 //本pool是global的子pool, 将从global pool继承domain-name等option default-router 10.1.1.100 10.1.1.101 //为客户机配置默认网关!ip dhcp pool vlan2 //为另一VLAN配置的poolnetwork 10.1.2.0 255.255.255.0default-router 10.1.2.100 10.1.2.101lease 1!ip dhcp pool vlan1_john //总是为MAC地址为...的机器分配...地址host 10.1.1.21 255.255.255.0client-identifier 010050.bade.6384 //client-identifier=01加上客户机网卡地址!ip dhcp pool vlan1_tomhost 10.1.1.50 255.255.255.0client-identifier 010010.3ab1.eac8相关的DHCP调试命令:no service dhcp //停止DHCP服务[默认为启用DHCP服务]sh ip dhcp binding //显示地址分配情况show ip dhcp conflict //显示地址冲突情况debug ip dhcp server {events | packets | linkage} //观察DHCP服务器工作情况如果DHCP客户机分配不到IP地址,常见的原因有两个。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
总监推荐:Cisco路由器上配置DHCP全程详解
2007-12-09 15:21
某单位使用Cisco 3620作为IOS DHCP Server,它和内网相连的fastethernet0端口的IP地址为192.168.1.4,二层交换机采用两台Cisco 2950,三层交换机采用一台Cisco 3550。
在整个网络中有二个VLAN,为简化描述,假设每个VLAN都采用24位网络地址,其中VLAN1的IP地址为192.168.1.254,VLAN2 的IP地址为192.168.2.254。
在Cisco设备上实现IOS DHCP Server功能以使各VLAN中的主机自动获得IP地址,如下图所示。
配置DHCP地址池、附加信息以及租约期限
DHCP服务器的数据库被组织成一个树形结构,树根是用于动态分配的所有网络段的地址池,树枝是子网地址池,树叶是手工绑定给节点的地址。
具体操作步骤如下:
ﻫ首先登陆到Cisco3640路由器上:
ghq>enable
Password (输入路由器的特权口令)
ghq #configterminal (进入配置模式)
Enter configuration commandsoneper line. End with CNT L/Z.ﻫghq config # ip dhcp pool global(配置一个根地址池,global是地址池的名称,你可以采用有意义的字符串来表示)
ﻫghq dhcp-config #network 192.168.0.0 255.255.0.0(动态分配的地址段)
ghqdhcp-config #domain-name ghq.com(为客户机配置域后缀) ghq dhcp-config #dns-server 192.168.1.1(为客户机配置DNS服务器)ﻫ
ghq dhcp-config #netbios-name-server192.168.1.1(为客户机配置wins服务器)ﻫghq dhcp-config #netbios-node-typeh-node(为客户机配置h节点模式)ﻫghq dhcp-config #lease 30 (地址租用期为30天)ﻫghqdhcp-config#ip dhcp pool vlan1(为VLAN1配置地址池,本池是global池的子池,将从global继承域后缀、DNS服务器、wins服务器等参数)
ﻫghq dhcp-config #network 192.168.1.0 255.255.255.0 (VLAN1动态分配192.168.1这个网段内可以被分配的地址,没有被排除的地址)ﻫghq dhcp-config#default-router 192.168.1.254 (为客户机配置默认的网关,即VLAN1的IP地址)
ﻫghqdhcp-config #ipdhcp pool vlan2(为VLAN2配置地址池,本池是global池的子池,将从global继承域后缀、DNS服务器、wins服务器等可继承的参数)
ghq dhcp-config#network 192.168.2.0255.255.255.0
ghq dhcp-config #default-router 192.168.2.254ﻫ
设置不能用于动态分配的IP地址
ﻫ在整个网络中,有些IP地址需要静态的指定给一些特定的设备,例如路由器的端口、DNS服务器、wins服务器以及VLAN的地址等。
显然,这些静态IP地址是不能用于动态分配的,这就需要将它们排除掉。
其步骤如下:ﻫﻫghq confi g#ip dhcp excluded-address 192.168.1.1192.168.1.5 (IP地址 192.168.1.1至192.168.1.5不能用于动态分配)
ghq config # ip dhcp excluded-address 192.168.1.254
(IP地址192.168.1.254固定为VLAN1的地址,不能用于动态分配)ﻫ
ghqconfig # ip dhcp excluded-address 192.168.2.254 (IP地址192.168.2.254固定为VLAN2的地址,不能用于动态分配)
ﻫ设置DHCP数据库代理
ﻫDHCP数据库代理是用于存储DHCP绑定信息的一台主机,它可以是或者是RCP
服务器。
当然,如有必要,你可以配置多个DHCP数据库代理。
同样,不配置DHCP数据库代理也是允许的,但这是以不能在DHCP数据库代理上存储地址冲突日志为代价的。
如果我们不想配置数据库代理,只要取消掉地址冲突日志的记录功能即可,操作命令如下:
ghq config# no ip dhcp conflict logging (取消地址冲突记录日志)ﻫ
配置路由器的静态路由表ﻫ
要使客户机能从用作DHCPServer的路由器中自动获得IP地址,首要条件就是各个VLAN中的客户机都能和路由器通信,因此首先就需要在路由器中设置一个路由以使路由器能和各个客户机通信。
我们可以按如下设置:
ﻫghqconfig #ip route 192.168.1.0 255.255.255.0 FastEthe rnet0ﻫ(FastEthernet0为路由器和内网相连的以太网接口,该命令的作用是在以太网接口和VLAN1192.168.1.254间建立一条静态路由。
)ﻫ
ghq config #ip route192.168.2.0255.255.255.0 FastEt hernet0。