# Starting OSPF

You enable OSPFv2 and OSPFv3 differently. When you enable OSPFv2 on your router, you can create either a range of OSPFv2 interfaces or a single OSPFv2 interface. When enabling OSPFv3, you create the OSPFv3 interface and assign the interface to an area.

## Enabling OSPFv2

You can create OSPFv2 interfaces in the following ways:

- You can issue the network area command, which creates OSPF interfaces for all IP interfaces with IP addresses within the specified range.
- You can issue the address area command, which creates an OSPF interface in the specified area that sits on top of the IP interface at the given IP address (or on the unnumbered interface, if that is specified).

  | Note: Do not enable OSPF on any unidirectional interfaces (such as an MPLS tunnel), because it can never form an adjacency.

You can delete OSPFv2 interfaces in the following ways:

- You can issue the no network area command, which deletes all OSPF interfaces within the specified range.
- If the OSPF interface was created with the address area command, you can issue the no address area command to delete the specified interface.
- You can issue the no ip address command to delete the IP interface associated with the OSPF interface and also the OSPF interface itself.

  | Note: If an OSPF interface is configured on top of an IP interface and you delete the IP interface, the corresponding OSPF interface is also deleted. The previously configured network range, however, is not deleted. You must issue the no network area command to delete the range.

## Enabling OSPFv3

| Note: Before you can enable OSPFv3, you must specify an IPv6 license key. For additional information about configuring an IPv6 license key, see Configuring an IPv6 License .

OSPFv3 provides IPv6 support in the OSPF protocol. To enable OSPFv3:

1. Issue the ipv6 router ospf command, and specify a process ID.
2. Use the router id command to specify a router ID for OSPFv3.

   See Specifying an OSPF Router ID.

3. Issue the ipv6 ospf area command (in interface configuration mode) to create an OSPFv3 interface under an area ID.

You can delete OSPFv3 interfaces in the following ways:

- You can issue the no ipv6 router ospf command, which deletes OSPFv3.
- You can issue the no ipv6 ospf area command to remove the OSPF interface from a specific area.

## Creating a Range of OSPF Interfaces

To create a range of OSPFv2 interfaces:

1. Create an OSPF routing process.
2. Create the range of IP addresses associated with the routing process and the corresponding OSPF interfaces.
3. Assign an area ID associated with each range of IP addresses.

Each router running OSPFv2 has a database describing a map of the routing domain. This map needs to be identical in all participating routers.

network area

- Use to configure a range of OSPFv2 interfaces and their related area.
- If the specified range matches one or more of the IP addresses configured for IP interfaces, one or more corresponding OSPF interfaces are created and placed in the specified area.
- Create address ranges that do not overlap; you can attach only the same range of interfaces to a single area.
- You cannot use this command for unnumbered interfaces.
- If the range specified by this command includes an address on an interface that is being referred to by unnumbered interfaces, all of the unnumbered interfaces begin trying to form adjacencies. If this behavior is not intended, you must reevaluate the interface assignment or the range specified by the command.
- Example 1—shows the creation of one OSPF interface in the backbone area
  host1(config-if)#ip address 2.2.2.1 255.255.0.0 host1(config-if)#ip address 2.2.1.1 255.255.0.0 secondary host1(config)#router ospf 2 host1(config-router)#network 2.2.2.0 0.0.0.255 area 0
- Example 2—shows the creation of two OSPF interfaces, one in the backbone area and one in a non-backbone area
  host1(config-if)#ip address 2.2.2.1 255.255.255.0 host1(config-if)#ip address 2.2.1.1 255.255.255.0 secondary host1(config)#router ospf 2 host1(config-router)#network 2.2.2.0 0.0.0.255 area 0 host1(config-router)#network 2.2.1.0 0.0.0.255 area 1

  This sequence of commands creates two OSPF ranges (2.2.2.0/24 and 2.2.1.0/24), with each range belonging to a different area. Area 0 is configured for 2.2.2.0/24, and area 1 is configured for 2.2.1.0/24. This sequence also creates two OSPF interfaces: one in the backbone area (area 0) using IP address 2.2.2.1, the second in a nonbackbone area (area 1) using IP address 2.2.1.1. This command also creates the two areas if they do not already exist.

- Use the no version to delete OSPF interfaces, ranges, and areas.

  | Note: Until you activate the configured network range for summaries by issuing the area range command, the range is not active for summarization; the network range is summarized through area summaries—for ABRs only. (See Aggregating OSPF Networks .) The only range that is active by default if you do not issue the area range command is the network that matches the IP interface’s network exactly. (In other words, by default the exact network of the IP interface is going to be summarized into other areas.)

- See network area

ospf enable

- Use to enable OSPF on the router.
- OSPF is enabled by default.
- Example
  host1(config-router)#ospf enable
- The no version of this command is deprecated and may be removed in a future release. Use the ospf shutdown command to disable OSPF on the router.
- See ospf enable

router ospf

ipv6 router ospf

- Use to set an OSPF process ID.
- The process ID can be any positive integer in the range 1–65535.
- You must assign a unique ID for the OSPF routing process.
- From a virtual router context you can specify a VRF name (OSPFv2 only). Doing so changes the context to that of the specified VRF and remains so until you exit from the OSPFv2 router context.
- Example 1
  host1(config)#router ospf 5
- Example 2
  host1(config)#ipv6 router ospf 5
- Use the no version to end the designated OSPF routing process.
- See router ospf
- See ipv6 router ospf

## Creating a Single OSPFv2 Interface

To create a single OSPFv2 interface:

1. Create an OSPF routing process.
2. Create the OSPF interface associated with the IP interface at the specified address.

Each router running OSPF has a database describing a map of the routing domain. This map needs to be identical in all participating routers.

address area

- Use to create an interface in an area on which OSPFv2 runs, on top of the IP interface at the specified IP address.
- You can specify either an IP address or an unnumbered interface.
- Configures OSPFv2 with the default values. You can configure the interface with a nondefault value by using the other address commands. You must first issue the address area command before issuing any other address commands. See Configuring OSPF Interfaces for more information.
- Example
  host1(config-router)#address 10.10.32.100 area 0.0.0.0
- Use the no version to delete the OSPFv2 interface.
- See address area

ospf enable

- Use to enable OSPF on the router.
- OSPF is enabled by default.
- Example
  host1(config-router)#ospf enable
- The no version of this command is deprecated and might be removed in a future release. Use the ospf shutdown command to disable OSPF on the router.
- See ospf enable

router ospf

- Use to set an OSPF process ID.
- The process ID can be any positive integer in the range 1–65535.
- You must assign a unique ID for each OSPF routing process.
- Example
  host1(config)#router ospf 5
- Use the no version to end the designated OSPF routing process.
- See router ospf

## Specifying an OSPF Router ID

The router ID is typically derived by each router from its interface IP addresses. However, you can use the router-id command to specify a different router ID for OSPF.

| Note: You must specify a router ID to enable OSPFv3. Although you can specify the router IP address using the ip router-id command in Global Configuration mode for OSPFv2 interfaces, use the router-id command in Router Configuration mode to enable the router to use a different IP address as the OSPF router ID rather than the address used for other IP routing protocols.

router-id

- Use to specify a different IP address for the router to use as the OSPF router ID.
- Example
  host1(config-router)#router-id 192.168.50.5
- Use the no version to force OSPF to use the previous OSPF router ID behavior.
- See router-id