Search Windows and Linux Networking

Tuesday, October 25, 2011

Configure Cisco Router with OSPF and DHCP Relay Agent

Configure Network with using  Cisco Router and DHCP server

Today we will see how to configure cisco router with ospf and act as relay agent.


For example we have a DHCP Server that is configure to provide IP address two different network  192.168.0.0/24 and 192.168.2.0/24.  DHCP is providing correct ip in same network(head office) but in other network client are not getting ip address from DHCP server.
Problem is occurring  because by default router break broadcast domain .to fix the problem we have told router to allow DHCP DORA process



Head office Router

Router>
Router>enable
Router#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
HeadOffice(config)#hostname HeadOffice
HeadOffice(config)#interface FastEthernet 0/0
HeadOffice(config-if)#ip address 192.168.0.1 255.255.255.0
HeadOffice(config-if)#no shutdown

%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up

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

HeadOffice(config-if)#exit
HeadOffice(config)#interface FastEthernet 1/0
HeadOffice(config-if)#ip address 192.168.1.1 255.255.255.0
HeadOffice(config-if)#no shutdown

%LINK-5-CHANGED: Interface FastEthernet1/0, changed state to up

HeadOffice(config-if)#exit
HeadOffice(config)#

Configure routing with ospf:-

HeadOffice(config)#router ospf 1
HeadOffice(config-router)#network 192.168.0.0 0.0.0.255 area 0
HeadOffice(config-router)#network 192.168.1.0 0.0.0.255 area 0
HeadOffice(config-router)#

00:53:17: %OSPF-5-ADJCHG: Process 1, Nbr 192.168.2.1 on FastEthernet1/0 from LOADING to FULL, Loading Done

HeadOffice(config-router)#exit
HeadOffice(config)#exit

%SYS-5-CONFIG_I: Configured from console by console
HeadOffice#show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
       * - candidate default, U - per-user static route, o - ODR
       P - periodic downloaded static route

Gateway of last resort is not set

C    192.168.0.0/24 is directly connected, FastEthernet0/0
C    192.168.1.0/24 is directly connected, FastEthernet1/0
O    192.168.2.0/24 [110/2] via 192.168.1.2, 00:00:18, FastEthernet1/0

HeadOffice#

Saving Our Configuration 

HeadOffice#copy running-config startup-config
Destination filename [startup-config]? [Press Enter Key]
Building configuration...
[OK]
HeadOffice#

Branch Office Router
Router> [Press Enter key]
Router>enable
Router#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#hostname branchoffice
branchoffice(config)#interface fastEthernet 1/0
branchoffice(config-if)#ip address 192.168.1.2 255.255.255.0
branchoffice(config-if)#no shutdown

%LINK-5-CHANGED: Interface FastEthernet1/0, changed state to up

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

branchoffice(config-if)#exit
branchoffice(config)#interface fastEthernet 0/0
branchoffice(config-if)#ip address 192.168.2.1 255.255.255.0
branchoffice(config-if)#no shutdown

%LINK-5-CHANGED: Interface FastEthernet1/0, changed state to up

Configure routing with ospf

branchoffice(config)#router ospf 1
branchoffice(config-router)#network 192.168.1.0 0.0.0.255 area 0
branchoffice(config-router)#network 192.168.2.0 0.0.0.255 area 0
branchoffice(config-router)#exit
branchoffice(config)#exit
Verity Route:-

Verify all network are now known to router by show ip route command

branchoffice#show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
       * - candidate default, U - per-user static route, o - ODR
       P - periodic downloaded static route

Gateway of last resort is not set

O    192.168.0.0/24 [110/2] via 192.168.1.1, 00:00:33, FastEthernet1/0
C    192.168.1.0/24 is directly connected, FastEthernet1/0
C    192.168.2.0/24 is directly connected, FastEthernet0/0
Check our network are accessible or not by ping command :- 

branchoffice#ping 192.168.0.2

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.0.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 31/31/32 ms


Configure Router for DHCP Relay agent 
By default Router break brodcast domain and dhcp DORA process run by brodcasting for DHCP Server to get IP address information so we need to told router to send dhcp brodcast to DHCP Server.

branchoffice#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
branchoffice(config)#interface fastEthernet 0/0
branchoffice(config-if)#ip helper-address 192.168.0.2
branchoffice(config-if)#exit
branchoffice(config)#exit
branchoffice#

Saving Our Configuration 


branchoffice#copy running-config startup-config
Destination filename [startup-config]? [Press Enter Key]
Building configuration...
[OK]
branchoffice#

Now DHCP server will provide correct ip address by looking at network request coming from for example 192.168.2.0 /24 network. it simple

No comments:

Post a Comment