Distance Command on CISCO Router/Switch

Other Cisco Other Cisco Material Original source

Command

Distance

Use

Allows you to filter routes from the routing table. For CCNA purposes, this is usually done through access lists.

Syntax

Router(config-router)#distance

Options

Sets the administrative distance for the selected routes
Source IP the route is received from
Specifies a wildcard mask, allows you to specify multiple source IP addresses
Specifies an access-list that selects what routes will have their AD changed

Example

In this example, we will apply a change to the administrative distance for OSPF to 123 for any route that starts with 1.0.0.0. First, we’ll look at the routing table.

Copy

R2(config)#do show ip route ospf

1.0.0.0/32 is subnetted, 3 subnets

O 1.1.1.1 [110/66] via 10.2.2.3, 00:00:22, FastEthernet1/0

O 1.3.3.3 [110/66] via 10.2.2.3, 00:00:22, FastEthernet1/0

O 1.2.2.2 [110/66] via 10.2.2.3, 00:00:22, FastEthernet1/0

192.168.13.0/30 is subnetted, 1 subnets

O 192.168.13.0 [110/65] via 10.2.2.3, 00:00:22, FastEthernet1/0

33.0.0.0/32 is subnetted, 1 subnets

O 33.33.33.33 [110/2] via 10.2.2.3, 00:00:22, FastEthernet1/0

3.0.0.0/32 is subnetted, 1 subnets

O 3.3.3.3 [110/2] via 10.2.2.3, 00:00:22, FastEthernet1/0

111.0.0.0/32 is subnetted, 1 subnets

O 111.111.111.111 [110/66] via 10.2.2.3, 00:00:22, FastEthernet1/0

10.0.0.0/24 is subnetted, 3 subnets

O 10.4.4.0 [110/65] via 10.2.2.3, 00:00:22, FastEthernet1/0

11.0.0.0/32 is subnetted, 1 subnets

O 11.11.11.11 [110/66] via 10.2.2.3, 00:00:22, FastEthernet1/0

133.133.0.0/32 is subnetted, 1 subnets

O 133.133.133.133 [110/2] via 10.2.2.3, 00:00:22, FastEthernet1/0

Now, we will configure the distance command on R2’s OSPF process.

Copy

R2(config)#access-list 25 permit 1.0.0.0 0.255.255.255

R2(config)#router ospf 1

R2(config-router)#distance 123 10.1.1.1 255.255.255.255 25

Finally, we see routes starting with 1.0.0.0 now have an administrative distance of 123.

Copy

R2(config-router)#do show ip route ospf

1.0.0.0/32 is subnetted, 3 subnets

O 1.1.1.1 [123/2] via 10.1.1.1, 00:00:03, FastEthernet0/0

O 1.3.3.3 [123/2] via 10.1.1.1, 00:00:03, FastEthernet0/0

O 1.2.2.2 [123/2] via 10.1.1.1, 00:00:03, FastEthernet0/0

192.168.13.0/30 is subnetted, 1 subnets

O 192.168.13.0 [110/65] via 10.2.2.3, 00:00:03, FastEthernet1/0

[110/65] via 10.1.1.1, 00:00:03, FastEthernet0/0
← All Other Cisco articles Home