Skip to main content

How to configure DHCP Server on a switch for different VLANs?

 

DHCP (Dynamic Host Configuration Protocol) servers provide all the basic information the client wants to operate on the network, including DNS address, Default Gateway, IP addresses, subnet masks, and many more in detail.

In this lab, we have one switch and 16 PCs. Our task is to assign all the PCs to their VLANs and configure the DHCP server for all VLANs. Ultimately, ensure all the PCs get their IP addresses from the DHCP server. 



  • configure the topology as per the diagram
  • configure VLAN 10,20,30, and 40
  • assign ports to their VLANs 
  • configure IP addresses for VLANs 
  • VLAN 10 192.168.1.1/24
  • VLAN 20 192.168.2.1/24
  • VLAN 30 192.168.3.1/24
  • VLAN 40 192.168.4.1/24
  • configure DHCP server for all VLANs
  • ensure that all PCs get IPs
  • verify with show commands
  • configure IP routing command 


SW-dhcp-(config)#vlan 10
SW-dhcp-(config-vlan)#name vlan10
SW-dhcp-(config-vlan)#exit

SW-dhcp-(config)#vlan 20
SW-dhcp-(config-vlan)#name vlan20
SW-dhcp-(config-vlan)#exit

SW-dhcp-(config)#vlan 30
SW-dhcp-(config-vlan)#name vlan30
SW-dhcp-(config-vlan)#exit

SW-dhcp-(config)#vlan 40
SW-dhcp-(config-vlan)#name vlan40
SW-dhcp-(config-vlan)#exit

SW-dhcp-(config)#interface range ethernet 0/0-3
SW-dhcp-(config-if-range)#switchport
SW-dhcp-(config-if-range)#switchport mode access
SW-dhcp-(config-if-range)#switchport access vlan 10
SW-dhcp-(config-if-range)#exit

SW-dhcp-(config)#interface range ethernet 1/0-3
SW-dhcp-(config-if-range)#switchport
SW-dhcp-(config-if-range)#switchport mode access
SW-dhcp-(config-if-range)#switchport access vlan 20
SW-dhcp-(config-if-range)#exit

SW-dhcp-(config)#interface range ethernet 2/0-3
SW-dhcp-(config-if-range)#switchport
SW-dhcp-(config-if-range)#switchport mode access
SW-dhcp-(config-if-range)#switchport access vlan 30
SW-dhcp-(config-if-range)#exit

SW-dhcp-(config)#interface range ethernet 3/0-3
SW-dhcp-(config-if-range)#switchport
SW-dhcp-(config-if-range)#switchport mode access
SW-dhcp-(config-if-range)#switchport access vlan 40
SW-dhcp-(config-if-range)#exit

SW-dhcp-#show vlan
VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active
10   vlan10                           active    Et0/0, Et0/1, Et0/2, Et0/3
20   vlan20                           active    Et1/0, Et1/1, Et1/2, Et1/3
30   vlan30                           active    Et2/0, Et2/1, Et2/2, Et2/3
40   vlan40                           active    Et3/0, Et3/1, Et3/2, Et3/3



SW-dhcp-(config)#interface vlan 10
SW-dhcp-(config-if)#ip address 192.168.1.1 255.255.255.0
SW-dhcp-(config-if)#no shutdown
SW-dhcp-(config-if)#exit

SW-dhcp-(config)#interface vlan 20
SW-dhcp-(config-if)#ip address 192.168.2.1 255.255.255.0
SW-dhcp-(config-if)#no shutdown
SW-dhcp-(config-if)#exit

SW-dhcp-(config)#interface vlan 30
SW-dhcp-(config-if)#ip address 192.168.3.1 255.255.255.0
SW-dhcp-(config-if)#no shutdown
SW-dhcp-(config-if)#exit


SW-dhcp-(config)#interface vlan 40
SW-dhcp-(config-if)#ip address 192.168.4.1 255.255.255.0
SW-dhcp-(config-if)#no shutdown
SW-dhcp-(config-if)#exit
SW-dhcp-(config)#end

SW-dhcp-#show ip interface brief
Interface              IP-Address      OK? Method Status                Protocol

Vlan10                 192.168.1.1     YES manual up                    up
Vlan20                 192.168.2.1     YES manual up                    up
Vlan30                 192.168.3.1     YES manual up                    up
Vlan40                 192.168.4.1     YES manual up                    up


SW-dhcp-(config)#service dhcp
SW-dhcp-(config)#ip dhcp pool vlan10
SW-dhcp-(dhcp-config)#network 192.168.1.2 255.255.255.0
SW-dhcp-(dhcp-config)#default-router 192.168.1.1
SW-dhcp-(dhcp-config)#dns-server 8.8.8.8
SW-dhcp-(dhcp-config)#exit

SW-dhcp-(config)#service dhcp
SW-dhcp-(config)#ip dhcp pool vlan20
SW-dhcp-(dhcp-config)#network 192.168.2.2 255.255.255.0
SW-dhcp-(dhcp-config)#default-router 192.168.2.1
SW-dhcp-(dhcp-config)#dns-server 8.8.8.8
SW-dhcp-(dhcp-config)#exit

SW-dhcp-(config)#service dhcp
SW-dhcp-(config)#ip dhcp pool vlan30
SW-dhcp-(dhcp-config)#network 192.168.3.2 255.255.255.0
SW-dhcp-(dhcp-config)#default-router 192.168.3.1
SW-dhcp-(dhcp-config)#dns-server 8.8.8.8
SW-dhcp-(dhcp-config)#exit

SW-dhcp-(config)#service dhcp
SW-dhcp-(config)#ip dhcp pool vlan40
SW-dhcp-(dhcp-config)#network 192.168.4.2 255.255.255.0
SW-dhcp-(dhcp-config)#default-router 192.168.4.1
SW-dhcp-(dhcp-config)#dns-server 8.8.8.8
SW-dhcp-(dhcp-config)#exit

SW-dhcp-(config)#ip routing
SW-dhcp-(config)#exit


SW-dhcp-#show ip dhcp binding
Bindings from all pools not associated with VRF:
IP address      Client-ID/              Lease expiration        Type       State      Interface
                Hardware address/
                User name
192.168.1.2     0100.5079.6668.00       Dec 15 2024 11:16 AM    Automatic  Active     Vlan10
192.168.1.3     0100.5079.6668.01       Dec 15 2024 11:16 AM    Automatic  Active     Vlan10
192.168.1.4     0100.5079.6668.02       Dec 15 2024 11:16 AM    Automatic  Active     Vlan10
192.168.1.5     0100.5079.6668.03       Dec 15 2024 11:16 AM    Automatic  Active     Vlan10
192.168.2.2     0100.5079.6668.04       Dec 15 2024 11:17 AM    Automatic  Active     Vlan20
192.168.2.3     0100.5079.6668.05       Dec 15 2024 11:17 AM    Automatic  Active     Vlan20
192.168.2.4     0100.5079.6668.06       Dec 15 2024 11:17 AM    Automatic  Active     Vlan20
192.168.2.5     0100.5079.6668.07       Dec 15 2024 11:17 AM    Automatic  Active     Vlan20
192.168.3.2     0100.5079.6668.0d       Dec 15 2024 11:17 AM    Automatic  Active     Vlan30
192.168.3.3     0100.5079.6668.0c       Dec 15 2024 11:17 AM    Automatic  Active     Vlan30
192.168.3.4     0100.5079.6668.0b       Dec 15 2024 11:17 AM    Automatic  Active     Vlan30
192.168.3.5     0100.5079.6668.0a       Dec 15 2024 11:18 AM    Automatic  Active     Vlan30
192.168.4.2     0100.5079.6668.14       Dec 15 2024 11:16 AM    Automatic  Active     Vlan40
192.168.4.3     0100.5079.6668.15       Dec 15 2024 11:16 AM    Automatic  Active     Vlan40
192.168.4.4     0100.5079.6668.16       Dec 15 2024 11:17 AM    Automatic  Active     Vlan40
192.168.4.5     0100.5079.6668.17       Dec 15 2024 11:17 AM    Automatic  Active     Vlan40



PC1> ip dhcp
DDORA IP 192.168.1.2/24 GW 192.168.1.1

PC1> show ip

NAME        : PC1[1]
IP/MASK     : 192.168.1.2/24
GATEWAY     : 192.168.1.1
DNS         : 8.8.8.8
DHCP SERVER : 192.168.1.1
DHCP LEASE  : 84926, 86400/43200/75600
MAC         : 00:50:79:66:68:00
LPORT       : 10018
RHOST:PORT  : 127.0.0.1:10019
MTU:        : 1500









Comments

Popular posts from this blog

What is Classification and marking? What is IP Precedence and DSCP Values? What is AF and EF?

  Classification and Marking Classification and marking are the processes of identifying the priority of each packet. This is the first step of QOS control and should be done near the source hosts. Classification is the process of identifying and categorising traffic into classes, typically based upon incoming interface IP precedence, DSCP Source or Destination address. Application classification is the most fundamental QOS building block. Without classification, all packets are treated the same.   The table lists the criteria of classification                                  Marking  Marking is the QOS feature component that colours a packet so it can be identified and distinguished from other packets in QOS treatment. Commonly used markers: link-layer: COS (ISL, 802.1q), MPLS EXP bits,...

What is of NBAR (network- based application recognition),classification QOS How to configure NBAR?

 When we implement Quality of Service (QoS ) the first step is classification, by default our router does not care about what kind of IP packets it is. Our router just looks at the routing table to find the correct destination IP address and forwards. When we configure QoS technologies like queuing, policing, or shaping before doing first we have to identify what kind of traffic is running on our routers so we can figure out what kind of application it belongs to. This is classification. What is Quality of Service (QOS)? What is Modular Quality of service CLI (MQC)? What is Classification and marking? What are IP Precedence and DSCP Values? What is AF and EF?     Once we identify our traffic (classify). Now we can mark and apply QoS policy to it. There are a few methods on IOS routers for classification: Header inspection It is a simple classification method and it works really good but has some disadvantages. Let’s say we configure our router all th...

OSPF Tunnels Vs Virtual-links

OSPF VIRTUAL LINKS  An Open Shortest Path First (OSPF) autonomous system has all areas physically connected to the backbone area (Area 0). In some cases, if this is not possible, we can use a virtual link to connect to the backbone (Area 0) through a non-backbone area. We can also use the virtual links to connect two parts of a partitioned backbone (Area 0) through a non-backbone area. The area through which we configure the virtual link, known as a transit area, must have full routing information. Remember, the transit area cannot be a stub area. Virtual link must be configuring both sides with the same area ID and the corresponding virtual link OSPF neighbor router ID. Show IP OSPF neighbors command give you the router ID information. OSPF Transit Area from Tunnel When configuring OSPF with tunnel interfaces as transit areas, there are several important considerations to ensure proper routing functionality. Here's what you need to know: Key Concepts Transit Area : In OS...