IPv6 general prefixes

By stretch | Saturday, December 13, 2008 at 5:21 p.m. UTC

Recently I read a post over at CCIE Pursuit about paying attention to typos on the IOS command line. His example illustrates a common mistake made when configuring an IPv6 address on an interface, but it also drew attention to an option I hadn't noticed before: IPv6 general prefixes.

As it turns out, general prefixes can be defined in IOS to act as shortcuts when assigning IPv6 addresses to interfaces. For example, if your organization was assigned the 2001:db8:42::/48 prefix, chances are all your routers would have the majority of their interfaces configured with addresses within this prefix. To make address assignment a bit less tedious, you can define a named general prefix pointing to 2001:db8:42::/48 and reference it at interface configuration.

First, we define the general prefix:

Router(config)# ipv6 general-prefix ?
  WORD  General prefix name

Router(config)# ipv6 general-prefix MyGlobal ?
  6to4                Create 6to4 prefix from IPv4 address
  X:X:X:X::X/  IPv6 prefix

Router(config)# ipv6 general-prefix MyGlobal 2001:db8:42::/48

Now when assigning an IPv6 address to an interface, we can reference the prefix by its much more memorable name instead of having to type out the entire address by hand. For example, if we wanted to assign the address 2001:db8:42:10::1/64:

Router(config-if)# ipv6 address ?
  WORD                General prefix name
  X:X:X:X::X          IPv6 link-local address
  X:X:X:X::X/  IPv6 prefix
  autoconfig          Obtain address using autoconfiguration

Router(config-if)# ipv6 address MyGlobal ?
  X:X:X:X::X/  IPv6 prefix

Router(config-if)# ipv6 address MyGlobal 0:0:0:10::1/64
Router(config-if)# do show ipv6 interface brief
FastEthernet0/0            [up/up]
FE80::C000:6AFF:FEC1:0
2001:DB8:42:10::1
FastEthernet0/1            [administratively down/down]

Notice that the first portion of the prefix (2001:db8:42::/48) was taken from our predefined MyGlobal prefix, and the rest was filled in with what we typed at interface configuration. In the above example, zeros were used to fill in the first 48 bits of the interface address; in practice, any values can be used, and will simply be overwritten by the referenced prefix.

General prefixes can also be used in conjunction with EUI-64 addresses as you might expect:

Router(config-if)# no ipv6 address MyGlobal 0:0:0:10::1/64
Router(config-if)# ipv6 address MyGlobal 0:0:0:10::/64 eui-64
Router(config-if)# do show ipv6 interface brief
FastEthernet0/0            [up/up]
FE80::C000:6AFF:FEC1:0
2001:DB8:42:10:C000:6AFF:FEC1:0
FastEthernet0/1            [administratively down/down]

However, it's important to pay close attention when defining general prefixes; IOS allows you to configure multiple prefixes with the same name. If multiple are prefixes are referenced by a common name, the interface will be configured with an address within each prefix. Here we define two unique local /48 prefixes, and the interface is assigned ::1/64 in both:

Router(config)# ipv6 general-prefix MyLocals fd00:1234:5678::/48
Router(config)# ipv6 general-prefix MyLocals fd00:8765:4321::/48
Router(config-if)# do show running-config | include MyLocals
ipv6 general-prefix MyLocals FD00:1234:5678::/48
ipv6 general-prefix MyLocals FD00:8765:4321::/48
Router(config)# interface f0/0
Router(config-if)# ipv6 address MyLocals ::1/64
Router(config-if)# do show ipv6 interface brief
FastEthernet0/0            [up/up]
FE80::C000:6AFF:FEC1:0
2001:DB8:42:10:C000:6AFF:FEC1:0
FD00:1234:5678::1
FD00:8765:4321::1
FastEthernet0/1            [administratively down/down]

About the Author

Jeremy Stretch is a network engineer living in the Raleigh-Durham, North Carolina area. He is known for his blog and cheat sheets here at Packet Life. You can reach him by email or follow him on Twitter.

Posted in IPv6, Tips and Tricks

Comments


Justin (guest)
December 13, 2008 at 11:42 p.m. UTC

That is cool. It's nice to see non-introductory information on IPv6. I look forward to seeing more IPv6 content in the future. Thanks.


Bharat Pawar (guest)
October 4, 2011 at 12:39 p.m. UTC

This information is of great help. Thanks


nickbeee
December 31, 2011 at 11:48 a.m. UTC

I wish I had found this feature sooner - having recently set up some tunnels along with /48s and some ULAs for experimental stuff, this will save me a lot of time typing/checking and flicking back to the spreadsheet.

How about adding it to the IPv6 Cheat Sheet?


Suchaboot1 (guest)
March 21, 2016 at 8:49 a.m. UTC

As usual, a simple, concise explanation. Thank you! Was tryin to figure out the difference between PD and GP, so I think I'm halfway there now.


Gerardo Marciales (guest)
May 13, 2016 at 11:54 p.m. UTC

I like your writing. It is clear and focused on the topic. Congrats.


Tyler Haske (guest)
September 13, 2016 at 7:05 p.m. UTC

Thanks for clarifying that whatever is used for the first 48 bits will be overwritten.

Comments have closed for this article due to its age.