Cisco Routing/Switching – Router on a stick & DHCP

Configure a router on a stick with DHCP based on your two VLANS, IT & Accounting.

Using our topology below:

Let’s log into Switch 1 (Top Switch) and run a show cdp neighbours to find our neighboring devices and locate which port is connected with CO-R1

S1#sh cdp neigh
Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
                  S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone
Device ID    Local Intrfce   Holdtme    Capability   Platform    Port ID
CO-R1        Fas 0/1          121            R       C2900       Gig 0/0
S3           Fas 0/2          121            S       2960        Fas 0/1
S2           Fas 0/3          179            S       2960        Fas 0/1

Looks like Fa0/1 is the port connected to the Corporate Router 1

Lets send all VLAN Traffic over that interface

S1(config)#int fa0/1
S1(config-if)#switchport mode trunk

S1(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up

S1(config-if)#end

We are going to create two sub interfaces for our VLANS:

.2 – IT (VLAN2 – 10.1.1.0 /24)

.5 – Accounting (VLAN 5 10.1.2.0 /24)

CO-R1#sh ip int brief
Interface              IP-Address      OK? Method Status                Protocol 
GigabitEthernet0/0     10.1.0.1        YES manual up                    up 
GigabitEthernet0/1     unassigned      YES unset  administratively down down 
GigabitEthernet0/2     unassigned      YES unset  administratively down down 
Serial0/0/0            188.29.163.173  YES manual up                    up 
Serial0/0/1            unassigned      YES unset  administratively down down 
Vlan1                  unassigned      YES unset  administratively down down
CO-R1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
CO-R1(config)#int g0/0.2
CO-R1(config-subif)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0.2, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0.2, changed state to up

CO-R1(config-subif)#exit
CO-R1(config)#int g0/0.5
CO-R1(config-subif)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0.5, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0.5, changed state to up

CO-R1(config-subif)#exit

First of all identifying the interface you want to create your sub interfaces on in this case is 0/0 as the other interface is talking to our ISP, then creating the sub interfaces as above.

We now need to configure dot1q to encapsulate on that specified vlan

CO-R1(config)#int g0/0.2
CO-R1(config-subif)#encapsulation dot1q 2
CO-R1(config-subif)#ip address 10.1.1.1 255.255.255.0
CO-R1(config-subif)#end
CO-R1#
%SYS-5-CONFIG_I: Configured from console by console

CO-R1#

Lets configure the other sub interface

CO-R1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
CO-R1(config)#int g0/0.5
CO-R1(config-subif)#encapsulation dot1q 5
CO-R1(config-subif)#ip address 10.1.2.1 255.255.255.0
CO-R1(config-subif)#exit
CO-R1(config)#

Lets verify our sub interfaces are configured

CO-R1#sh ip int brief
Interface              IP-Address      OK? Method Status                Protocol 
GigabitEthernet0/0     10.1.0.1        YES manual up                    up 
GigabitEthernet0/0.2   10.1.1.1        YES manual up                    up 
GigabitEthernet0/0.5   10.1.2.1        YES manual up                    up 
GigabitEthernet0/1     unassigned      YES unset  administratively down down 
GigabitEthernet0/2     unassigned      YES unset  administratively down down 
Serial0/0/0            188.29.163.173  YES manual up                    up 
Serial0/0/1            unassigned      YES unset  administratively down down 
Vlan1                  unassigned      YES unset  administratively down down
CO-R1#

As you can see from above, the sub interfaces are now configured.

Lets configure our DHCP, first of all exclude the address you don’t want to be handed out via DHCP

CO-R1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
CO-R1(config)#ip dhcp excluded-address 10.1.1.1 10.1.1.99
CO-R1(config)#ip dhcp excluded-address 10.1.1.151 10.1.1.255
CO-R1(config)#ip dhcp excluded-address 10.1.2.1 10.1.2.99
CO-R1(config)#ip dhcp excluded-address 10.1.2.151 10.1.2.255
CO-R1(config)#

So above we have excluded 10.1.1.1 & 10.1.2.1 (Our interface addresses) up to 99 and 151 to 255. this means only address .100 – .150 will be assigned

Create the DHCP pools with DNS and Default gateway:

CO-R1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
CO-R1(config)#ip dhcp pool IT
CO-R1(dhcp-config)#network 10.1.1.0 255.255.255.0
CO-R1(dhcp-config)#dns-server 4.2.2.2
CO-R1(dhcp-config)#default-router 10.1.1.1
CO-R1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
CO-R1(config)#
CO-R1(config)#ip dhcp pool Accounting
CO-R1(dhcp-config)#network 10.1.2.0 255.255.255.0
CO-R1(dhcp-config)#dns-server 4.2.2.2
CO-R1(dhcp-config)#default-router 10.1.2.1

Ensure your PC’s are in the relevant VLAN’s on the switch they are connected to, feel free to do this which ever way you want

S2#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
S2(config)#int fa0/3
S2(config-if)#switchport access vlan 2
S2(config-if)#end
S3#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
S3(config)#int fa0/2
S3(config-if)#switchport access vlan 5
S3(config-if)#end
S3#
%SYS-5-CONFIG_I: Configured from console by console

S3#

On your PC’s if your run an ipconfig /renew you should find they have an ip address for their specified VLAN:

C:\>ipconfig /renew

   IP Address......................: 10.1.2.100
   Subnet Mask.....................: 255.255.255.0
   Default Gateway.................: 10.1.2.1
   DNS Server......................: 4.2.2.2

C:\>
C:\>ipconfig /renew

   IP Address......................: 10.1.1.100
   Subnet Mask.....................: 255.255.255.0
   Default Gateway.................: 10.1.1.1
   DNS Server......................: 4.2.2.2

C:\>

You should find you should also be able to ping the other PC also

C:\>ping 10.1.2.100

Pinging 10.1.2.100 with 32 bytes of data:

Reply from 10.1.2.100: bytes=32 time=1ms TTL=127
Reply from 10.1.2.100: bytes=32 time<1ms TTL=127
Reply from 10.1.2.100: bytes=32 time<1ms TTL=127
Reply from 10.1.2.100: bytes=32 time<1ms TTL=127

Ping statistics for 10.1.2.100:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 1ms, Average = 0ms

C:\>

 

Leave a Reply

Your email address will not be published. Required fields are marked *