Creating subinterfaces on Gi0/0
Router>en
Router(config)#int gi0/0.10
Router(config-subif)#encapsulation dot1Q 10
Router(config-subif)#ip add 192.168.1.1 255.255.255.0
Router(config)#int gi0/0.20
Router(config-subif)#enc dot1Q 20
Router(config-subif)#ip add 192.168.2.1 255.255.255.0
Router(config)#int gi0/0.30
Router(config-subif)#encapsulation dot1Q 30
Router(config-subif)#ip add 192.168.3.1 255.255.255.0
Power On The Gi0/0 Interface
Now you should exit from the sub-interface and go to Gi0/0 and turn on the physical interface.
Router(config)#int gi0/0
Router(config-if)#no shut
Allowing The VLAN On The Specific Interface
Interface Gi0/1 on the switch must be in the trunk mode and each interface is set to be allowed each VLAN. VLAN will be created if not existed already.
Switch 0
Switch>
Switch>en
Switch(config)#int gi0/1
Switch(config-if)#switchport mode trunk
Switch(config-if)#int fa0/1
Switch(config-if)#switchport access vlan 10
Switch(config)#int fa0/2
Switch(config-if)#switchport access vlan 20
Switch(config)#int fa0/3
Switch(config-if)#switchport access VLAN 30
Creating DHCP Pools
Actually, this is the main part for this tutorial. The first step is creating one pool for one VLAN
So here we are creating 3 pools for 3 VLANS. VLAN 10, VLAN 20, VLAN 30 those are named for each pool.
Router 0
Router(config)#ip dhcp pool vlan10
Router(dhcp-config)#network 192.168.1.0 255.255.255.0
Router(dhcp-config)#default-router 192.168.1.1
Router(dhcp-config)#dns 8.8.8.8
Router(config)#ip dhcp pool vlan20
Router(dhcp-config)#network 192.168.2.0 255.255.255.0
Router(dhcp-config)#default-router 192.168.2.1
Router(dhcp-config)#dns 8.8.8.8
Router(config)#ip dhcp pool vlan30
Router(dhcp-config)#network 192.168.3.0 255.255.255.0
Router(dhcp-config)#default-router 192.168.3.1
Router(dhcp-config)#dns 8.8.8.8
Excluding IP Addresses From The Pools
Here we excluding first 5 IP addresses from each pool so that Reserved IP addresses will not be assigned to hosts.
Router(config)#ip dhcp ex 192.168.1.1 192.168.1.5
Router(config)#ip dhcp ex 192.168.2.1 192.168.2.5
Router(config)#ip dhcp ex 192.168.3.1 192.168.3.5
Configuring DHCP Relay.
Everything is same here but DHCP server router is remotely connected which mean DHCP server router is not a directly connected network.
Configuring IP address on router 0
Router(config)#int gi0/1
Router(config-if)#ip add 172.17.0.1 255.255.252.0
Router(config-if)#no shutdown
Configuring IP address on router 1
Router 1
Router(config)#int gi0/2
Router(config-if)#ip add 172.17.0.2 255.255.252.0
Router(config-if)#no shut
Enabling Static Routing
Router 1 should know how it can reach the networks of 192.168.1.0, 192.168.2.0, 192.168.2.0
So that we are creating 3 routes that tell the router 1 it can reach these networks through the interface Gi0/1 of the router 0. we also use that interface id instead of that IP address.
Router(config)#ip route 192.168.1.0 255.255.255.0 172.17.0.1
Router(config)#ip route 192.168.2.0 255.255.255.0 172.17.0.1
Router(config)#ip route 192.168.3.0 255.255.255.0 172.17.0.1
Creating DHCP Pools on Router 1
Router(config)#ip dhcp pool vlan10
Router(dhcp-config)#network 192.168.1.0 255.255.255.0
Router(dhcp-config)#default-router 192.168.1.1
Router(dhcp-config)#dns 8.8.4.4
Router(config)#ip dhcp pool vlan20
Router(dhcp-config)#network 192.168.2.0 255.255.255.0
Router(dhcp-config)#default-router 192.168.2.1
Router(dhcp-config)#dns 8.8.4.4
Router(config)#ip dhcp pool vlan30
Router(dhcp-config)#network 192.168.3.0 255.255.255.0
Router(dhcp-config)#default-router 192.168.3.1
Router(dhcp-config)#dns 8.8.4.4
Excluding IP addresses
Router(config)#ip dhcp ex 192.168.1.1 192.168.1.5
Router(config)#ip dhcp ex 192.168.2.1 192.168.2.5
Router(config)#ip dhcp ex 192.168.3.1 192.168.3.5
Configuring IP Helper Address
This is little bit different IP address of DHCP server router will be placed on each subinterface of the Router 0 as IP helper agent’s address.
Router(config)#int gi0/0.10
Router(config-subif)#ip helper-address 172.17.0.2
Router(config)#int gi0/0.20
Router(config-subif)#ip helper-address 172.17.0.2
Router(config)#int gi0/0.30
Router(config-subif)#ip helper-address 172.17.0.2