Static NAT Dynamic NAT Dynamic PAT DST NAT
Static NAT
..........
Configure the router's Define inside & Outside
interface fa0/0
ip nat outside
interface fa0/1
ip nat inside
ip nat inside source static 192.168.10.10 202.202.10.1
Dynamic NAT
............
int f0/0
ip nat outside
exit
int f1/0
ip nat inside
exit
ip nat pool saikat 20.1.1.5 20.1.1.20 netmask 255.255.255.0
access-list 1 permit 192.168.1.0 0.0.0.255
ip nat inside source list 1 pool pool1
show ip nat translations
Dynamic PAT
...........
int f0/0
ip nat outside
exit
int f1/0
ip nat inside
exit
access-list 1 permit 192.168.123.0 0.0.0.255
ip nat inside source list 1 interface fastEthernet 1/0 overload
show ip nat translations
Port Forwarding Commnds
.......................
WAN Interface
.............
conf t
interface gigabitEthernet 0/0
ip address 50.50.50.1 255.255.255.0
ip nat outside <– Configure the WAN as NAT outside interface
no shutdown
exit
LAN Interface
.............
interface gigabitEthernet 0/1
ip address 192.168.1.1 255.255.255.0
ip nat inside <– Configure the LAN as NAT inside interface
no shutdown
exit
ip route 0.0.0.0 0.0.0.0 50.50.50.2 <– Configure default route
access-list 1 permit 192.168.1.0 0.0.0.255 <– Configure ACL to be used for PAT
ip nat inside source list 1 interface GigabitEthernet0/0 overload <– Configure PAT (NAT overload)
ip nat inside source static tcp 192.168.1.10 80 50.50.50.1 80 <– Port Forwarding for Web Server
ip nat inside source static tcp 192.168.1.11 25 50.50.50.1 25 <– Port Forwarding for SMTP Server
show ip nat translations <---- Checking For NAT Working Or Not
HSRP VRRP GLBP Configuration
HSRP Configuration
..................
R1
--
interface Ethernet0/1
description LAN Interface of Active Router
ip address 192.168.1.1 255.255.255.0
standby 1 ip 192.168.1.254 <—- Create HSRP Group 1 and assign Virtual IP
standby 1 priority 101 <—- Assign priority above 100 to make this the primary router
standby 1 preempt <—- Makes router active if it has higher priority
R2
--
interface Ethernet0/1
description LAN Interface of Standby Router
ip address 192.168.1.2 255.255.255.0
standby 1 ip 192.168.1.254 <—- Create HSRP Group 1 and assign Virtual IP
standby 1 preempt <—- Makes router active if it has higher priority
VRRP Configuration
...........................
R1
--
interface Ethernet0/1
description LAN Interface of Active Routerip address
ip address 192.168.1.1 255.255.255.0
vrrp 1 ip 192.168.1.254 <—- Create VRRP Group 1 and assign Virtual IP
vrrp 1 priority 101 <—- Assign priority above 100 to make this the primary router
vrrp 1 preempt <—- Makes router active if it has higher priority
R2
..
interface Ethernet0/1
description LAN Interface of Standby Router
ip address 192.168.1.2 255.255.255.0
vrrp 1 ip 192.168.1.254 <—- Create VRRP Group 1 and assign Virtual IP
vrrp 1 preempt <—- Makes router active if it has higher priority
GLBP Configuration
..................
R1
..
interface Ethernet0/1
description LAN Interface of Primary Router
ip address 192.168.1.1 255.255.255.0
glbp 1 ip 192.168.1.254 <—- Create GLBP Group 1 and assign Virtual IP
glbp 1 priority 101 <—- Assign priority above 100 to make this the primary router
glbp 1 preempt <—- Makes router active if it has higher priority
glbp 1 load-balancing round-robin <—- Configure round-robin balancing of traffic
R2
..
interface Ethernet0/1
description LAN Interface of Secondary Router
ip address 192.168.1.2 255.255.255.0
glbp 1 ip 192.168.1.254 <—- Create GLBP Group 1 and assign Virtual IP
glbp 1 preempt <—- Makes router active if it has higher priority
glbp 1 load-balancing round-robin <—- Configure round-robin balancing of traffic
Additional Commnd
.................
show glbp brief
show glbp
Timers – The default hello timer is 3 seconds. The default hold timer is 10 seconds.
R1(config-if)#glbp 10 timers ?
..............................
<1-60> Hello interval in seconds
msec Specify hello interval in milliseconds
redirect Specify timeout values for failed forwarders
Authentication – A router will ignore incoming GLBP packets from routers that
do not have the same
authentication configuration for a GLBP group.
R1(config-if)#glbp 10 authentication ?
......................................
md5 MD5 authentication
text Plain text authentication
By default, GLBP will load balance traffic using the round-robin method.
But we can change it by using the following command:
R1(config-if)#glbp 10 load-balancing ?
.......................................
host-dependent Load balance equally, source MAC determines forwarder choice
round-robin Load balance equally using each forwarder in turn
weighted Load balance in proportion to forwarder weighting
Let’s try changing it from round-robin to weighted
..................................................
R1(config-if)#glbp 10 load-balancing weighted
R1(config-if)#glbp 10 weighting 50
For verification, let’s use the ‘show glbp’ command
...................................................
R1#sh glbp | inc weight
Load balancing: weighted
Active is local, weighting 150
Active is 10.10.10.2 (primary), weighting 100 (expires in 11.424 sec)
Interface Tracking For ISP Link Router s0/0 Port
track 10 interface s0/0 line-protocol
show track
interface fa0/0
glbp 1 weighting track 10 decrement 10
glbp 1 weighting 120
hostname router-A
!
track 1 interface Serial0/0 line-protocol
!
interface FastEthernet0/0
ip address 192.168.10.1 255.255.255.0
glbp 10 ip 192.168.10.254
glbp 10 priority 255
glbp 10 weighting track 1 decrement 100
!
hostname router-B
!
track 1 interface Serial0/0 line-protocol
!
interface FastEthernet0/0
ip address 192.168.10.2 255.255.255.0
glbp 10 ip 192.168.10.254
glbp 10 priority 254
glbp 10 weighting track 1 decrement 100
!
IPSLA Configuration
ip sla 10
icmp-echo 8.8.8.8 source-ip 192.168.1.250
frequency 5
timeout 2000
exit
ip sla schedule 10 start-time now life forever
track 10 rtr 10
exit
interface fa0/0
glbp 10 weighting 110 lower 85 upper 105
glbp 10 weighting track 12 decrement 30
show glbp | include Active
show track
..........
Response Time Reporter 10 state
State is Up
1 change, last change 00:01:57
Latest operation return code: OK
Latest RTT (millisecs) 48
HSRP Configration
.................
interface fa0/1 (Lan interface)
stanby 1 ip 10.10.10.250 (Virtual IP Gateway Configration)
standby 1 preempt
stanby 1 priyority 105
ACL configuration
Standard ACL
............
Deny Traffic Commnd
...................
Method-1
access-list 1 deny 192.168.1.53 0.0.0.0
Method-2
access-list 1 deny host 192.168.1.53
access-list 1 permit any
show access-list
Assign an ACL Router Interface
..............................
int fa 0/0
ip access-group 1 outbound
Standard Named ACL
...................
ip access-list standard ABC
deny host 192.168.1.53
deny host 192.168.1.54
permit any
show access-list
int fa 0/0
ip access-group ABC outbound
Modify ACL
..........
ip access-list standard ABC
25 deny host 192.168.1.55
no 25
Remove ACL From Interface OR Full Remove
----------------------------------------
no ip access-list standard ABC
int fa 0/0
no ip access-group ABC outbound
Extended Numbered ACL
----------------------
access-list 100 deny tcp host 192.168.1.50 host 192.168.10.4 eq 80
access-list 100 deny icmp host 192.168.1.50 host 192.168.10.4
access-list 100 deny tcp host 192.168.1.50 host 192.168.10.4 eq 23
access-list 100 deny ip host 192.168.1.50 host 192.168.10.4
access-list 100 permit any any
Extended Named ACL
-------------------
ip access-list extended ABC
deny tcp host 192.168.1.50 host 192.168.10.4 eq 80
deny icmp host 192.168.1.50 host 192.168.10.4
permit ip any any
int fa 0/0
ip access-group ABC outbound
DHCP Server Configuration
DHCP Server Configuration
.........................
config t
ip dhcp pool 10
network 10.10.10.0 255.255.255.0
default router 10.10.10.1
dns-server 8.8.8.8
exit
config t
ip dhcp pool 20
network 10.10.20.0 255.255.255.0
default router 10.10.20.1
dns-server 8.8.8.8
exit
config t
ip dhcp pool 30
network 10.10.30.0 255.255.255.0
default router 10.10.30.1
dns-server 8.8.8.8
exit
CDP & LLDP Configuration
CDP (Cisco Discovery Protocol) Devolop By Cisco
...............................................
Show Commnds
............
show cdp
show cdp neighbor
show cdp neighbor detail
Commnds To enable the CDP
.........................
cdp run
Commnds To disable the CDP
.........................
no cdp run
Commnds To disable the CDP on Port
..................................
interface fa0/1
no cdp run
LLDP (IEEE 802.1AB standard.) Support All Vendor
.................................................
Show Commnds
............
show lldp
show lldp neighbor
show cdp neighbor detail
Commnds To Activate lldp on cisco devices
.........................................
lldp run
no lldp run
Commnds To disable/enable the LLDP on Port
..........................................
interface fa0/1
no lldp transmit
no lldp receive
lldp transmit
lldp receive
Router Backup & Restore & Upgarde
How to Installing an IOS CISCO Router
.....................................
Prerequisites
.............
Router: Ensure your Cisco router is compatible with the IOS version you plan to install.
IOS Image: Obtain the IOS image file (typically a .bin file).
TFTP Server: Set up a TFTP server on your PC.
Console Cable: Connect your PC to the router via a console cable.
Terminal Emulator: Use a terminal emulator like PuTTY, Tera Term, or HyperTerminal.
Step-by-Step Installation
.........................
Connect to the Router: Use your terminal emulator to connect to the router’s console port.
Enter ROMMON Mode (if necessary):If the router does not boot,
you may need to interrupt the boot sequence
by pressing Ctrl + Break. This will take you to ROMMON mode.
Configure TFTP Settings:In ROMMON mode, set the IP address of the router and the TFTP server
IP_ADDRESS=192.168.1.1
IP_SUBNET_MASK=255.255.255.0
DEFAULT_GATEWAY=192.168.1.254
TFTP_SERVER=192.168.1.100
TFTP_File=iosvbgfjuyng2rrgh.bin
tftpdnld
boot
How To IOS Upgrade Process Router
Upgrading Cisco IOS on a router involves a few key steps to ensure
a smooth transition to a newer version. Here’s a step-by-step guide
for upgrading IOS:
..................................................................
Prerequisites
.............
IOS Image: Download the desired IOS image file from Cisco’s website.
TFTP Server: Set up a TFTP server on your computer.
Console Connection: Connect to the router using a console cable.
Backup: Back up the current configuration.
...........................................
Step-by-Step Upgrade Process
............................
Open a terminal emulator (like PuTTY or Tera Term) and
connect to the router via the console port.
Check Current IOS Version:
..........................
Use the following command to check the current IOS version:
show version
Backup Current Configuration:
.............................
It’s good practice to back up your current configuration:
copy running-config startup-config
copy startup-config tftp
Copy the New IOS Image to the Router:
.....................................
conf t
interface fa0/1
ip address 192.168.1.1 255.255.255.0
no shutdown
exit
copy tftp: flash:
Follow the prompts to enter the TFTP server IP and the filename of the IOS image.
Verify the New IOS Image:
........................
dir flash:
Set the Boot Variable:
Set the router to boot from the new IOS image:
..............................................
conf t
boot system flash flash:
exit
Save the Configuration:
Save the updated configuration Commnd
.....................................
write memory
Reboot the Router:
Reload the router to apply the new IOS:
.......................................
reload
Post-Upgrade Checks
...................
show version
Translating "192.168.1.100t"...domain server For Cancel
.......................................................
press Ctrl+Shift+6 to immediately cancel
ping 192.168.1.100 repeat 1000
How to Check Switch Or Router Firmware
show version
show flash
How To Backup Router Or Switch IOS Firmware
copy flash tftp
source file 10215nbcisco.bin
remote host tftp ip 192.168.1.100
How to Delete IOS
delete flash://2012546873201mkfd320.bin
show flash
How to New IOS Restore TFTP
copy tftp flash
tftp adress 192.168.1.100
source filename
destination filename
show flash
copy run startup-config
reloade
How To Backup And Restore Router Configuraion File
Notes- First Setup Router Interfaces IP Address Then working TFTP Server
1. Router Configuration Backup
copy nvram: tftp:
source filename startup-config
Address remote host 192.168.1.100
Destination filename enter
2. Router Configuration Restore
Notes- Router IP Setup
copy tftp: nvram
Address remote host 192.168.1.100
Source filename Itindex-confg
Destination filename enter
Router Configurtion backup Commnd Testing By Packet Tracer
..........................................................
copy startup-config tftp:
remote host 192.168.1.100
Router Configurtion Restore Commnd Testing By Packet Tracer
.............................................................
copy tftp startup-config
remote host 192.168.1.100
OSPF Routing Protocol Commnds
hostname R1
interface GigabitEthernet0/0
ip address 10.0.0.1 255.255.255.0
no shutdown
interface GigabitEthernet0/4
ip address 10.0.14.1 255.255.255.0
no shutdown
router ospf 1
router-id 1.1.1.1
network 10.0.14.1 0.0.0.0 area 0
network 10.0.0.1 0.0.0.0 area 0
hostname R2
interface GigabitEthernet0/0
ip address 10.0.0.2 255.255.255.0
no shutdown
interface GigabitEthernet0/3
ip address 10.0.23.2 255.255.255.0
no shutdown
router ospf 1
router-id 2.2.2.2
network 10.0.23.2 0.0.0.0 area 0
network 10.0.0.2 0.0.0.0 area 0
hostname R3
interface GigabitEthernet0/0
ip address 10.0.0.3 255.255.255.0
no shutdown
interface GigabitEthernet0/2
ip address 10.0.23.3 255.255.255.0
no shutdown
router ospf 1
router-id 3.3.3.3
network 10.0.23.3 0.0.0.0 area 0
network 10.0.0.3 0.0.0.0 area 0
hostname R4
interface GigabitEthernet0/0
ip address 10.0.0.4 255.255.255.0
no shutdown
interface GigabitEthernet0/1
ip address 10.0.14.4 255.255.255.0
no shutdown
router ospf 1
router-id 4.4.4.4
network 10.0.14.4 0.0.0.0 area 0
network 10.0.0.4 0.0.0.0 area 0
Router RA
en
conf t
interface GigabitEthernet0/0
ip ospf hello-interval 5
ip ospf dead-interval 20
ip ospf priority 150
ip ospf authentication message-digest
ip ospf message-digest-key 1 md5 Area0pa55
router ospf 1
network 192.168.1.0 0.0.0.255 area 0
area 0 authentication message-digest
End
Router RB
en
conf t
interface GigabitEthernet0/0
ip ospf hello-interval 5
ip ospf dead-interval 20
ip ospf priority 100
ip ospf authentication message-digest
ip ospf message-digest-key 1 md5 Area0pa55
router ospf 1
network 192.168.1.0 0.0.0.255 area 0
area 0 authentication message-digest
end
Router RC ASBR
en
conf t
interface GigabitEthernet0/0
ip ospf hello-interval 5
ip ospf dead-interval 20
ip ospf priority 50
ip ospf authentication message-digest
ip ospf message-digest-key 1 md5 Area0pa55
router ospf 1
passive-interface default
no passive-interface GigabitEthernet0/0
network 192.168.1.0 0.0.0.255 area 0
default-information originate
area 0 authentication message-digest
ip route 0.0.0.0 0.0.0.0 Serial0/0/0 end
Router R1
hostname R1
no ip domain lookup
banner motd # This is R1, Implement Multi-Area OSPFv2 Lab#
interface gi0/0
ip add 172.16.0.2 255.255.255.252
no shut
Ip ospf 1 area 0
exit
interface GigabitEthernet0/1
ip address 192.10.0.1 255.255.255.252
no shut
Ip ospf 1 area 1
exit
Router R3
hostname R3
no ip domain lookup
banner motd # This is R3, Implement Multi-Area OSPFv2 Lab #
interface gi0/0
ip add 172.16.1.2 255.255.255.252
no shut
Ip ospf 1 area 0
exit
interface Gi0/1
ip address 192.10.4.1 255.255.255.252
no shut
Ip ospf 1 area 2
exit
hostname R2
no ip domain lookup
banner motd # This is R2, Implement Multi-Area OSPFv2 Lab #
interface gi0/0
ip add 172.16.0.1 255.255.255.252
no shut
exit
interface Gi0/1
ip address 172.16.1.1 255.255.255.252
no shut
exit
interface lo0
ip add 209.165.200.225 255.255.255.224
int gi0/2
ip address dhcp
no shutdown
NAT_Configuration
access-list 1 permit 192.10.1.0 0.0.0.255
access-list 1 permit 192.10.5.0 0.0.0.255
ip nat inside source list 1 interface gi0/2 overload
int gi0/2
ip nat outside
int gi0/0
ip nat inside
int gi0/1
ip nat inside
L3 Switch
hostname D1
conf t
no ip domain lookup
banner motd # This is D1, Implement Multi-Area OSPFv2 Lab #
interface gi0/1
no switchport
ip address 192.10.0.2 255.255.255.252
no shut
Ip ospf 1 area 1
Exit
interface gi0/0
no switchport
ip address 192.10.1.1 255.255.255.0
no shut
exit
L3 Switch
hostname D2
no ip domain looku
banner motd # This is D2, Implement Multi-Area OSPFv2 Lab #
interface gi0/0
no switchport
ip address 192.10.4.2 255.255.255.252
no shut
Ip ospf 1 area 2
exit
interface gi0/1
no switchport
ip address 192.10.5.1 255.255.255.0
no shut
exit
hostname R1
router ospf 1
router-id 1.1.1.1
interface FastEthernet0/0
ip address 10.0.0.1 255.255.255.0
ip ospf 1 area 0
no shut
interface FastEthernet0/1
ip address 10.0.13.1 255.255.255.0
ip ospf 1 area 13
no shutdown
interface Serial1/0
ip address 10.0.12.1 255.255.255.0
ip ospf 1 area 12
no shut
interface Serial1/1
ip address 10.0.16.1 255.255.255.0
ip ospf 1 area 16
no shutdown
hostname R2
router ospf 1
router-id 2.2.2.2
interface FastEthernet0/0
ip address 10.0.0.2 255.255.255.0
ip ospf 1 area 0
no shut
interface FastEthernet0/1
ip address 10.0.2.2 255.255.255.0
ip ospf 1 area 12
no shut
interface Serial1/0
ip address 10.0.12.2 255.255.255.0
ip ospf 1 area 12
no shut
hostname R3
router ospf 1
router-id 3.3.3.3
interface FastEthernet0/0
ip address 10.0.0.3 255.255.255.0
ip ospf 1 area 0
no shut
interface FastEthernet0/1
ip address 10.0.13.3 255.255.255.0
ip ospf 1 area 13
no shut
interface loopback0
ip address 10.0.3.3 255.255.255.0
ip ospf 1 area 3
hostname R4
router rip
version 2
network 10.0.0.0
no auto-summary
redistribute ospf 1 metric 1
router ospf 1
router-id 4.4.4.4
redistribute rip subnets
interface FastEthernet0/0
ip address 10.0.0.4 255.255.255.0
ip ospf 1 area 0
no shut
interface FastEthernet0/1
ip address 10.0.45.4 255.255.255.0
no shutdown
hostname R5
interface FastEthernet0/1
ip address 10.0.45.5 255.255.255.0
no shut
interface loopback0
ip address 10.0.5.5 255.255.255.0
router rip
version 2
network 10.0.0.0
no auto-summary
hostname R6
router ospf 1
router-id 6.6.6.6
interface serial 1/1
ip address 10.0.16.6 255.255.255.0
ip ospf 1 area 16
no shutdown
OSPF Network Type
Change OSPF network type on an interface
........................................
interface g0/0
ip ospf network broadcast
ip ospf network non-broadcast
ip ospf network point-to-point
ip ospf network point-to-multipoint
ip ospf network point-to-multipoint non-broadcast
1. Broadcast
Default on Ethernet/FastEthernet/GigabitEthernet.
DR/BDR election occurs.
Neighbors discovered automatically via multicast (224.0.0.5/6).
2. Non-Broadcast (NBMA)
Used in Frame Relay/ATM.
DR/BDR election occurs.
No multicast → must use manual neighbors.
3. Point-to-Point
Default on serial links.
No DR/BDR election.
Only 2 neighbors.
4. Point-to-Multipoint
Treats all neighbors as separate point-to-point links.
No DR/BDR election.
Neighbors discovered automatically (multicast).
5. Point-to-Multipoint Non-Broadcast
Similar to above, but no multicast → must manually configure neighbors.
No DR/BDR election.
DR/BDR Election
DR/BDR Election Control (Interface Level)
.........................................
interface g0/0
ip ospf priority <0-255>
Default priority = 1
0 → Router will never become DR/BDR
Higher number = higher chance of becoming DR
Special Scenarios
.................
interface g0/0
ip ospf priority 0
interface g0/0
ip ospf priority 100
OSPF Authentication
There are 3 authentication types in OSPF
........................................
Null (No Authentication) – default.
Plaintext Authentication – simple password (not secure).
MD5 Authentication – secure hash-based authentication (preferred).
Enable OSPF Authentication (per-area)
.....................................
router ospf
area authentication # Enable simple (plaintext) auth
area authentication message-digest # Enable MD5 auth
Configure Authentication on Interfaces
......................................
Plaintext Authentication
interface g0/0
ip ospf authentication
ip ospf authentication-key
Example..
ip ospf authentication
ip ospf authentication-key CISCO123
MD5 Authentication
..................
interface g0/0
ip ospf authentication message-digest
ip ospf message-digest-key md5
Example..
ip ospf authentication message-digest
ip ospf message-digest-key 1 md5 MYSECRET
Disable Authentication (on interface)
.....................................
interface g0/0
no ip ospf authentication
Verification Commands
.....................
show ip ospf interface g0/0 # Shows auth type (None, Simple, or MD5)
show ip ospf neighbor # Check if neighbors are FULL (adj formed)
debug ip ospf adj
Enable OSPF and Set Router ID
Enable OSPF and Set Router ID
.............................
router ospf
router-id
Example...
router ospf 1
router-id 1.1.1.1
Advertise Networks
..................
network area
Example...
network 192.168.1.0 0.0.0.255 area 0
network 10.0.0.0 0.0.0.3 area 0
Interface-Based OSPF (Alternative to network command)
.....................................................
interface g0/0
ip ospf area
Example...
interface g0/0
ip ospf 1 area 0
OSPF Timer-Related Commands
OSPF Default Timer Values
| Network Type | Hello Interval | Dead Interval | Retransmit Interval | Transmit Delay |
|---|---|---|---|---|
| Broadcast (Ethernet, FDDI) | 10s | 40s | 5s | 1s |
| Point-to-Point (Serial, PPP) | 10s | 40s | 5s | 1s |
| Non-Broadcast (NBMA – Frame Relay, ATM) | 30s | 120s | 5s | 1s |
| Point-to-Multipoint | 30s | 120s | 5s | 1s |
| Virtual Links | 10s | 40s | 5s | 1s |
There are 4 main OSPF timers (configurable on interfaces):
..........................................................
Hello Interval → how often hello packets are sent (default: 10s on
broadcast/point-to-point,
30s on NBMA).
Dead Interval → how long to wait before declaring neighbor down (default: 40s / 120s).
Retransmit Interval → how long between LSA retransmissions (default: 5s).
Transmit Delay → how long to add to LSA age before sending (default: 1s).
Configure OSPF Timers (Interface Mode)
......................................
interface g0/0
ip ospf hello-interval
ip ospf dead-interval
ip ospf retransmit-interval
ip ospf transmit-delay
Common Examples
...............
Set Hello & Dead Timers
interface g0/0
ip ospf hello-interval 5
ip ospf dead-interval 20
Note - Neighbors must match Hello & Dead timers, otherwise adjacency will fail.
Set Retransmit Interval
.......................
interface g0/0
ip ospf retransmit-interval 10
Set Transmit Delay
..................
interface g0/0
ip ospf transmit-delay 3
Verification Commands
.....................
show ip ospf interface g0/0
Output shows:
Hello interval
Dead interval
Retransmit interval
Transmit delay
DR/BDR info
OSPF Basic Commnds
Check OSPF neighbors & DR/BDR roles
...................................
show ip ospf neighbor
Check OSPF interface details (who is DR/BDR)
............................................
show ip ospf interface fastEthernet 1/0
Force OSPF to re-elect DR/BDR
.............................
clear ip ospf process
Set OSPF Priority (influences DR/BDR election)
..............................................
interface g0/0
ip ospf priority 100
Check OSPF process summary
...........................
show ip ospf
Check OSPF Database (LSAs learned via DR/BDR)
.............................................
show ip ospf database
Check current OSPF network type
...............................
show ip ospf interface g0/0
OSPF Basic Configuration Commands
.................................
router ospf # Start OSPF process (process-id is local only)
router-id # Set manual router ID (default = highest IP)
network area # Advertise networks into OSPF
passive-interface # Stop sending OSPF Hello on interface
no passive-interface # Enable OSPF hello on interface
default-information originate # Advertise default route
area authentication # Enable area authentication
area stub # Make area stub
OSPF Interface-Level Commands
.............................
interface g0/0
ip ospf area 0 # Enable OSPF directly on interface
ip ospf priority <0-255> # Influence DR/BDR election (0 = never DR/BDR)
ip ospf hello-interval # Change hello timer
ip ospf dead-interval # Change dead timer
ip ospf cost # Set interface cost (metric)
OSPF Neighbor & Adjacency Verification
......................................
show ip ospf neighbor # Shows neighbor states (DR/BDR/DROTHER)
show ip ospf interface # Shows OSPF settings, DR/BDR on interface
show ip ospf # General OSPF process info
show ip ospf database # LSDB (Link-State Database)
show ip ospf border-routers # Shows ABRs & ASBRs
show ip protocols # Displays routing protocols running
OSPF Routing Table & LSAs
.........................
show ip route ospf # Only OSPF routes
show ip ospf database router # Router LSAs (Type-1)
show ip ospf database network # Network LSAs (Type-2, created by DR)
show ip ospf database summary # Summary LSAs (Type-3, ABR)
show ip ospf database asbr-summary# ASBR summary (Type-4)
show ip ospf database external # External LSAs (Type-5)
OSPF Troubleshooting Commands
.............................
debug ip ospf adj # Debug adjacency formation
debug ip ospf hello # Debug hello packets
debug ip ospf events # Debug OSPF events
debug ip ospf packet # Debug OSPF packets
clear ip ospf process # Restart OSPF process (re-election)
clear ip ospf neighbor # Reset adjacency with neighbor
ping # Check connectivity
traceroute # Verify path
Check any routing Protocol use Or Not
.................................
show ip protocols
show ip route ospf
interface fastEthernet 1/0
ip ospf cost 50
interface fastEthernet 1/0
no ip ospf cost 50
show ip interface loopback 0
router ospf 1
network 2.2.2.0 0.0.0.255 area 0
debug ip ospf packet
no debug all
interface fastEthernet 1/0
ip ospf authentication message-digest
ip ospf message-digest-key 1 md5 mykey
OSPF Passive-Interface Commands
This feature is used to advertise a network into OSPF without forming
neighbor adjacencies (i.e., OSPF Hellos are stopped on that interface).
Simple Way Stop Router Lan Interface OSPF Hello Packets Block For Router Reduce
CPU And Network Bandwith
.......................................................................
Make a Specific Interface Passive
.................................
router ospf
passive-interface
Example...
router ospf 1
passive-interface g0/1
OSPF stops sending Hello packets on g0/1.
The network is still advertised into OSPF
Make All Interfaces Passive (by default)
........................................
router ospf
passive-interface default <-This makes all interfaces passive (no Hellos sent anywhere).
Allow OSPF on Specific Interfaces (after default)
.................................................
router ospf
passive-interface default
no passive-interface
Example...
router ospf 1
passive-interface default
no passive-interface g0/0
no passive-interface g0/2
Here, only g0/0 and g0/2 form neighbors.
All other interfaces remain passive
Remove Passive-Interface (re-enable adjacency)
..............................................
router ospf
no passive-interface
Verification
............
show ip ospf neighbor # Should not see neighbors on passive interfaces
show ip ospf interface # Confirms Hello packets are suppressed
Summary of OSPF Passive-Interface Commands
..........................................
passive-interface → Suppresses OSPF Hellos on one interface.
passive-interface default → Suppresses OSPF Hellos on all interfaces.
no passive-interface → Re-enable OSPF Hellos on chosen interfaces.
Networks are still advertised even if the interface is passive.
OSPF Advance Commnd
OSPF Database Commands (LSA & Topology)
.......................................
show ip ospf database
Show LSDB by Type
.................
show ip ospf database router # Type-1 LSAs (Routers)
show ip ospf database network # Type-2 LSAs (DR-generated)
show ip ospf database summary # Type-3 LSAs (ABR summary)
show ip ospf database asbr-summary # Type-4 LSAs (ABR-generated external summary)
show ip ospf database external # Type-5 LSAs (External routes)
Show ABRs in OSPF
.................
show ip ospf border-routers
Displays all ABRs known in OSPF area.
Troubleshooting ABR & LSDB
..........................
show ip ospf neighbor # Check adjacency state with neighbors
show ip ospf interface # Check area assignment & DR/BDR
show ip route ospf # Check OSPF routes learned from other areas
debug ip ospf events # Shows LSDB updates, area changes
Show SPF Log / Events
.....................
show ip ospf spf statics
show ip route ospf | include O IA # Show only inter-area routes
show ip route ospf | include O E2 # Show only external type-2 routes
show ip ospf neighbor | include FULL # Show only fully adjacent neighbors
show ip ospf database | include External # Show only type-5 LSAs
show ip ospf interface | include DR # Show interfaces where router is DR
OSPF Route Symbols in Routing Table
OSPF Route Symbols in Routing Table
| Symbol | Meaning | Details |
|---|---|---|
| O | OSPF Intra-area | Learned within the same OSPF area. Example: Router sees a network in Area 0, where it is directly connected via OSPF. |
| O IA | OSPF Inter-area | Learned from another OSPF area via an ABR (Type-3 LSA). Example: Area 1 network advertised to Area 0 by an ABR. |
| O E1 | OSPF External Type-1 | External routes imported into OSPF with cost = internal OSPF cost + external cost. Used when external route’s metric is added to the internal path cost. |
| O E2 | OSPF External Type-2 | External routes imported with cost = external cost only. Default for OSPF external routes. Internal OSPF cost does not affect metric. |
🔹 Explanation
1. O (Intra-Area)
The simplest type.
Network exists inside the same area as the router.
Best path is always the shortest path to that network inside the area.
2. O IA (Inter-Area)
Learned via ABR from another area.
Cost = OSPF cost from router to ABR + cost advertised by ABR.
Helps connect multiple OSPF areas.
3. O E1 (External Type-1)
External route (redistributed into OSPF from another protocol like RIP or BGP).
Metric = internal OSPF cost to ASBR + external metric.
Example: Router adds its path cost to the external route metric.
4. O E2 (External Type-2)
Default external route type.
Metric = external cost only (ignores OSPF internal cost).
If multiple E2 routes exist → the lowest external cost wins; internal cost used only as tiebreaker.
OSPF LSAs (Link-State Advertisements)
Show All LSAs in OSPF Database
..............................
show ip ospf database
Check LSAs for a Specific Prefix
................................
show ip ospf database | include 192.168.1.0
Check LSAs from a Specific Router
................................
show ip ospf database router | include 1.1.1.1
Check Detailed LSA Information
...............................
show ip ospf database router detail
show ip ospf database network detail
show ip ospf database summary detail
show ip ospf database external detail
Useful Pipes
............
show ip ospf database | include OSPF
show ip ospf database | include External
show ip ospf database | begin Network
show ip ospf database | section Summary
OSPF Virtual Link Commands
Purpose of OSPF Virtual Link
............................
Connect a non-backbone area (e.g., Area 1) to backbone Area 0 through another area.
Virtual link runs between two ABRs.
Acts like a logical point-to-point link over a transit area.
Requirements
............
Both ABRs must have interfaces in the transit area
(the area between the remote area and backbone).
Remote ABR must be configured with router ID.
Only non-stub areas can be used as transit areas.
OSPF Virtual Link Configuration (Cisco IOS)
............................................
Step 1: Enter OSPF Process
router ospf 1
Step 2: Create Virtual Link
area virtual-link
Example...
router ospf 1
area 1 virtual-link 2.2.2.2
Verification Commands
.....................
Show virtual links
..................
show ip ospf virtual-links
Check OSPF neighbors (includes virtual link neighbor)
.....................................................
show ip ospf neighbor
Show OSPF interface info (virtual link appears as interface)
............................................................
show ip ospf interface
Show OSPF database
..................
show ip ospf database
R1(config)
..........
router ospf 1
network 1.1.1.0 0.0.0.255 area 0
network 192.168.12.0 0.0.0.255 area 1
R2(config)
..........
router ospf 1
network 192.168.12.0 0.0.0.255 area 1
network 192.168.23.0 0.0.0.255 area 2
R3(config)
.........
router ospf 1
network 192.168.23.0 0.0.0.255 area 2
Start with a default OSPF configuration
.......................................
R1(config)
..........
router ospf 1
area 1 virtual-link 192.168.23.2
Router A
........
interface Loopback0
ip address 1.1.1.1 255.255.255.0
interface Fa0/0
ip address 10.0.0.1 255.255.255.0
exit
Router B
.........
interface Loopback0
ip address 2.2.2.2 255.255.255.0
interface Fa0/1
ip address 10.0.0.2 255.255.255.0
interface Fa0/0
ip address 20.0.0.1 255.255.255.0
exit
Router C
........
interface Loopback0
ip address 3.3.3.3 255.255.255.0
interface Fa0/1
ip address 20.0.0.2 255.255.255.0
interface Fa0/0
ip address 30.0.0.1 255.255.255.0
exit
Router D
.........
interface Loopback0
ip address 4.4.4.4 255.255.255.0
interface Fa0/1
ip address 30.0.0.2 255.255.255.0
exit
After interface ip configuration, we will configure OSPF process and add OSPF Networks
under this interface. Here, we will use OSPF process number 1. Router A is in Area 0,
Router B is Area Border Router (ABR) and it is on both ara 0 and area 1.
Again, Router C is an Area Border Router (ABR) and in two different areas,
in Area 1 and area 2. And lastly, Router D will be in area 2 only.
The interfaces will be added to these ospf process with these
areas with network addresses and required wildcard mask.
Router A
........
router ospf 1
network 10.0.0.0 0.0.0.255 area 0
Router B
........
router ospf 1
network 10.0.0.0 0.0.0.255 area 0
network 20.0.0.0 0.0.0.255 area 1
Router C
........
router ospf 1
network 20.0.0.0 0.0.0.255 area 1
network 30.0.0.0 0.0.0.255 area 2
Router D
........
router ospf 1
network 30.0.0.0 0.0.0.255 area 2
Configuring Virtual-Links
.........................
After configuring ip addresses and OSPF processes with networks, now it is time to do the exact
OSPF Virtual Link Configuration on Packet Tracer. Here,
we will connect Area 2 to Area 0 over Area 1. So, we will create a virtual link between Router B and Router C. On router B,
we will set the destination virtual link address as the loopback ip address of router C (3.3.3.3).
And on router C, we will set the destination virtual link address as the loopback ip address of Router B (2.2.2.2).
Router B
........
router ospf 1
area 1 virtual-link 3.3.3.3
Router C
.........
router ospf 1
area 1 virtual-link 2.2.2.2
Cisco Virtual-Link Confgiuration Verification
.............................................
Router B# show ip ospf virtual-links
Virtual Link OSPF_VL0 to router 3.3.3.3 is up
Run as demand circuit
Transit area 1, via interface FastEthernet0/0, Cost of using 1
Transmit Delay is 1 sec, State POINT_TO_POINT,
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
Hello due in 00:00:06
Adjacency State FULL
Index 1/2, retransmission queue length 0, number of retransmission 0
First 0x0(0)/0x0(0) Next 0x0(0)/0x0(0)
Last retransmission scan length is 0, maximum is 0
Last retransmission scan time is 0 msec, maximum is 0 msec
Router C# show ip ospf virtual-links
....................................
Virtual Link OSPF_VL0 to router 2.2.2.2 is up
Run as demand circuit
Transit area 1, via interface FastEthernet1/0, Cost of using 1
Transmit Delay is 1 sec, State POINT_TO_POINT,
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
Hello due in 00:00:07
Adjacency State FULL
Index 1/2, retransmission queue length 0, number of retransmission 0
First 0x0(0)/0x0(0) Next 0x0(0)/0x0(0)
Last retransmission scan length is 0, maximum is 0
Last retransmission scan time is 0 msec, maximum is 0 msec
Router B# show ip ospf neighbor
...............................
Neighbor ID Pri State Dead Time Address Interface
3.3.3.3 0 FULL/ - 00:00:36 20.0.0.2 OSPF_VL0
10.0.0.1 1 FULL/DR 00:00:38 10.0.0.1 FastEthernet1/0
3.3.3.3 1 FULL/DR 00:00:31 20.0.0.2 FastEthernet0/0
Router C# show ip ospf neighbor
...............................
Neighbor ID Pri State Dead Time Address Interface
2.2.2.2 1 FULL/BDR 00:00:34 20.0.0.1 FastEthernet1/0
30.0.0.2 1 FULL/DR 00:00:39 30.0.0.2 FastEthernet0/0
2.2.2.2 0 FULL/ - 00:00:31 20.0.0.1 OSPF_VL0
Virtual Link Authentication Types
.................................
Plaintext Authentication (simple password)
MD5 Authentication (secure, recommended)
Configure Plaintext Authentication on Virtual Link
..................................................
router ospf
area virtual-link
area authentication
area authentication-key
Example...
router ospf 1
area 1 virtual-link 2.2.2.2
area 1 authentication
area 1 authentication-key CISCO123
Configure MD5 Authentication on Virtual Link
............................................
router ospf 1
area 1 virtual-link 2.2.2.2
area 1 authentication message-digest
area 1 message-digest-key 1 md5 CISCO123
show ip ospf interface
show ip ospf interface brief
show ip ospf neighbor
Originate Default Route into OSPF
What is “Originate Default Route into OSPF”?
In OSPF, the default route is 0.0.0.0/0, which is used to forward packets for unknown destinations.
Originate default route means telling an OSPF router to advertise a default route into the OSPF network, so other OSPF routers can use it as a gateway for networks they don’t know.
Typically, this is done by an ABR (Area Border Router) or an ASBR (Autonomous System Boundary Router).
🔹 Why It’s Used
To provide a gateway of last resort for OSPF routers in other areas.
To allow internal OSPF routers to reach external networks or the internet.
Useful when not all routers need full routing information — they can use the default route instead of learning all external networks.
Originate Default Route into OSPF
................................
router ospf
default-information originate
This tells the OSPF router to advertise a default route (0.0.0.0/0)
to all other OSPF routers.
Example...
router ospf 1
default-information originate
Force Originate Default Route
..............................
router ospf 1
default-information originate always
Verify Default Route in OSPF
............................
show ip route
O*E2 0.0.0.0/0 [110/1] via
Symbol explanation:
O → OSPF
E2 → External Type-2 route (default route is always external)
OSPF stub and totally stubby area commands
1. OSPF Stub Area Overview
Stub Area → An area that does not accept external (Type-5) LSAs.
Instead, it uses a default route (0.0.0.0) to reach external networks.
Useful to reduce LSDB size in areas with many external routes.
2. Totally Stubby Area Overview
Totally Stubby Area (TSA) → Cisco-specific enhancement.
Blocks both Type-5 (external) LSAs and Type-3 summary LSAs from other areas.
Router only knows:
Intra-area routes (Type-1, Type-2)
A single default route to reach other areas
Configure Stub Area (Router on ABR)
..................................
router ospf
area stub
Example...
router ospf 1
area 1 stub
Configure Totally Stubby Area
.............................
On ABR connecting to the totally stubby area:
router ospf
area stub no-summary
Example...
router ospf 1
area 1 stub no-summary
no-summary → Blocks Type-3 summary LSAs.
Routers inside area see only intra-area routes + default route.
Tips
....
Only ABR can configure stub/totally stubby area.
All routers in the area must agree on stub type, otherwise adjacency fails.
Stub area reduces routing table size and SPF calculations.
OSPF NSSA (Not-So-Stubby Area) and Totally NSSA
1. OSPF NSSA Overview
NSSA (Not-So-Stubby Area) is a special type of stub area.
Characteristics:
Blocks external Type-5 LSAs from other areas (like stub).
Allows redistribution of external routes into OSPF as Type-7 LSAs.
Type-7 LSAs are converted to Type-5 by ABR when leaving the NSSA.
Useful when you have external routes in a stub-like area (e.g., connecting RIP/BGP to OSPF stub).
2. Totally NSSA Overview
Totally NSSA → Cisco enhancement.
Blocks Type-5 external LSAs and Type-3 summary LSAs, except for a default route.
Routers inside see:
Intra-area routes (Type-1/Type-2)
Type-7 LSAs (for redistributed external routes inside NSSA)
Default route for everything else
NSSA Configuration Commands
..................................
router ospf
area nssa
Example...
router ospf 1
area 2 nssa
By default, NSSA injects Type-3 summary LSAs from backbone.
External routes from NSSA are advertised as Type-7 LSAs
Configure Totally NSSA
.........................
On ABR connecting to the totally stubby area:
router ospf 1
area nssa no-summary
Example...
router ospf 1
area 2 nssa no-summary
no-summary → Blocks Type-3 summary LSAs, only default + Type-7 external routes.
Optional – Default Route in NSSA
................................
ABR can inject default route into NSSA:
area 2 nssa default-information-originate
Verification Commands
.....................
show ip ospf
show ip ospf database
Shows Type-7 LSAs for external routes
Type-7 LSAs are converted to Type-5 outside the NSSA
show ip route
Inside NSSA, redistributed external routes appear as O E2 (external)
Tip:
....
Use NSSA when you want a stub-like area but still need external route redistribution.
Totally NSSA is useful when you
want the area to have minimal routes, only defaults and necessary redistributed networks.
OSPF Cost Commands
OSPF Metric Calculation
As we know, OSPF is a link state protocol, so the router learns all the paths and their costs to the destination and selects the routes with the lowest costs to the destination. This is known as OSPF Metric calculation.
Metric – It is a parameter that OSPF uses to choose its best path. OSPF metrics are calculated using a cost-based algorithm.
For any given interface, the cost is always inversely proportional to the bandwidth.
- A higher bandwidth leads to a lower cost.
- A lower bandwidth leads to a higher cost.
So, the path with the lowest cost will be the best path for OSPF.
Now, as we know, OSPF utilizes link-state advertisements for network destinations, and it is known as a link-state routing protocol. For this reason, the (shortest path first) SPF algorithm is used for routing calculations based on link-state information. With OSPF, all routers share metrics and link-state information about their connected interfaces with each other.
Let’s move on to know more about the shortest-path-first algorithm.
SPF Algorithm
Specifically, OSPF employs a (shortest-path-first) SPF algorithm to determine and construct the shortest route to all known destinations.
- In OSPF, routers generate a link state advertisement (LSA). This advertisement depicts the all-link states of the router.
- All routers in OSPF exchange link states by flooding LSAs. Every router that receives an LSA will store a copy of its link-state database and then forward the OSPF LSA to other routers.
- Once the database of every router is synced, it will calculate the shortest path to all possible destinations, which we call the shortest path tree (SPT).
- The algorithm puts every router in a tree and determines the shortest path to each destination by taking into account the total cost of getting there.
- Lastly, when the router builds the SPT, it starts creating the routing table.
We hope you have a good overview of the SPF Algorithm. Let’s understand the OSPF cost formula now.
OSPF Cost Formula
The formula used by OSPF to determine cost is as follows:
Cost = Reference bandwidth/Interface bandwidth
In OSPF’s documentation (RFC 2338), reference bandwidth was given a completely random number. Each manufacturer must determine its reference bandwidth. When referring to bandwidth, Cisco uses 100 Mbps (108) as reference bandwidth. With this, the equation would be:
Cost = 108/interface bandwidth in bps
Some of the key points to follow while calculating cost is discussed below.
Key points –
- Cost is a positive integer value.
- All decimal values will be rounded to the nearest positive integer.
- Any value in decimal or less than 1 will be considered 1.
Now that we have the formula let’s perform the arithmetic and get the base cost of the necessary interfaces.
Default cost of essential interfaces.
| Interface type | Bandwidth | Metric Calculation | Cost |
| Serial Link | 1544Kbps | 100000000/1544000 = 64.76 | 64 |
| Ethernet Link | 10Mbps | 100000000/10000000 = 10 | 10 |
| FastEthernet Link | 100Mbps | 100000000/100000000 = 1 | 1 |
How to check the cost of a link?
#show ip ospf interface fa0/0 | include cost
How to change the reference bandwidth?
Router(config)#Router ospf 1
Router(config)#auto-cost reference-bandwidth 10000 (in Mbps)
How to check reference bandwidth?
#Show ip ospf | include reference
How to check the bandwidth of a link?
#Show ip ospf interface fa0/0 | include BW
Check OSPF Cost on Interfaces
.............................
show ip ospf interface
FastEthernet0/0 is up, line protocol is up
Internet Address 192.168.1.1/24, Area 0
Cost: 10, State: DR, Priority: 1
Manually Set OSPF Cost
......................
interface GigabitEthernet0/1
ip ospf cost 5
Here, cost is explicitly set to 5.
Lower cost → more preferred route in OSPF.
Reference Bandwidth
...................
By default, OSPF calculates cost as:
Cost = Reference Bandwidth / Interface Bandwidth
Default reference bandwidth is 100 Mbps.
Example: FastEthernet (100 Mbps) → Cost = 100/100 = 1
GigabitEthernet (1000 Mbps) → Cost = 100/1000 = 0.1 → Rounded to 1
You can change the reference bandwidth globally
................................................
router ospf 1
auto-cost reference-bandwidth 1000
This is useful if you have faster interfaces like 10 Gbps,
so OSPF assigns proper lower cost to faster links
Check OSPF Route Cost
.....................
show ip route ospf
192.168.2.0/24 [110/20] via 10.1.1.2, 00:00:12, FastEthernet0/0
[110/20] → OSPF administrative distance 110, metric (cost) 20