Pete’s Packet

I don’t think I can. I know I can!

Archive for the ‘IPV6’ Category

ipv4 to ipv6

Posted by Peter Kurdziel on July 16, 2009

Decimal   150              1             3           3
Binary   1001 0110    0000 0001     0000 0011    0000 0011

in hex, they are 16 digit groupings for hex representations,

1001=9  0110=6 so forth,

The results is

9601:0303

http://blog.ru.co.za/2009/03/19/converting-ipv4-to-ipv6/

Converting from IPv4 to IPv6

is so easy, yet everyone seem to convert a IPv4 address to binary, then to IPv6. Why? Why waste time and do things the long way? Not cool. When would you need to do this? One specific use is IPv6 6-to-4 tunnels, which always concatenates 2002::/16 with the IPv4 address embedded. With Automatic 6-to-4-tunnels, your address format is as follow: 2002:<32 bit IPv4 site address in Hex>:<16 bit network number in Hex>::/64 The question is how to do the conversion. Firstly before starting I will assume everyone knows the following:
  • Binary is a Base-2 numbering system, as it has only 0,1
  • Decimal is a Base-10 numbering system, as it has 0,1,2,3,4,5,6,7,8,9
  • Hexadecimal is a Base-16 numbering system, as it has 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
I also assume you know the hex values in decimal:
A = 10
B = 11
C = 12
D = 13
E = 14
F = 15
Two more things I would like to mention before explaining the conversion. An IPv4 address : example 192.168.99.1
  • Each Octet (8 bits) “between the dot-thingys” denote 1 byte
An IPv6 address : example 2001:0db8:85a3:0000:0000:8a2e:0370:7334
  • Two Tuples (1 Tuple = 4 bits = 1 Hex character) denotes 1 byte
Then converting is easy. Lets take the following IPv4 address : 192.168.99.1 and convert it to Hex. Step1 > Divide the first octet (192) by 16 (since Hex is a Base-16) IE : 192/16 = 12 times exactly with 0 left over - 12 in Hex is represented as C - 0 (zero) in Hex is, you guessed it, 0 Thus 192 in HEX is C0 Step2 > Repeat step 1 with the second octet (168), IE : 168/16 = 10 times with 8 left over because 10*6 = 160, - 10 in HEX is A - 8 in HEX is 8 Thus 168 in HEX is A8 Step3 > Repetition rules!!! Third octet (99) IE : 99/16 = 6 times with 3 left over - 6 in HEX is 6 - 3 in HEX is 3 Thus 99 in HEX is 63 Step4 > Last octet IE : 1/16 = 0 times with 1 left over - 0 in HEX is, yeah it is 0 - 1 in HEX is 1 Thus 1 in HEX is 01 So the IPv4 address of 192.168.99.1, represented in the IPv6 address portion would be C0A8:6301. So when using IPv6 6-to-4 Tunnels, on the one endpoint of the tunnel, with the IPv4 address of 192.168.99.1, the complete IPv6 address would be 2002:C0A8:6301::1/64 See, not all that difficult, if you know your 16 multiplication table, you can do this in your head, no problems. - – - - .

Converting back from IPv6 to IPv4

Now to convert the same portion of the IPv6address 2002:C0A8:6301::1/64 back to IPv4, the reverse method would apply. Let me point one more thing about Base-16 out to understand why I’m doing what I am below: 160 = 1 161 = 16 Taking the  portion C0A8:6301, first divide the address into 2 Tuple-groupings (2 Hex Characters) = C0 A8 63 01 Step1 > Take C0 and multiply the first character ‘C’ by 16 and the second character ‘0′ by 1. Add the two decimal values together to get the IPv4 decimal value IE: ((C=12)*16) + (0*1) = 192 Step2 > Repeat the same process with A8, IE: ((A=10)*16) + (8*1) = 168 Step3 > Repeat the same process with 63, IE: (6*16) + (3*1) = 99 Step4 > Repeat the same process with 01, IE: (0*16) + (1*1) = 1

Posted in IPV6, Routing & Switching Lab | Leave a Comment »

ipv6 cef – For Unicast RPF to work, Cisco Express Forwarding must be configured globally in the router

Posted by Peter Kurdziel on July 8, 2009

The following prerequisites apply to Cisco Express Forwarding and distributed Cisco Express Forwarding for IPv6: – To forward IPv6 traffic using Cisco Express Forwarding or distributed Cisco Express Forwarding, you must configure forwarding of IPv6 unicast datagrams globally on the router by using the ipv6 unicast-routing command, and you must configure an IPv6 address on an interface by using the ipv6 address command.

– You must enable Cisco Express Forwarding for IPv4 globally on the router by using the ip cef command before enabling Cisco Express Forwarding for IPv6 globally on the router by using the ipv6 cef command.

– To use Unicast Reverse Path Forwarding (RPF), enable Cisco Express Forwarding switching or distributed Cisco Express Forwarding switching in the router. There is no need to configure the input interface for Cisco Express Forwarding switching. As long as Cisco Express Forwarding is running on the router, individual interfaces can be configured with other switching modes.

Note For Unicast RPF to work, Cisco Express Forwarding must be configured globally in the router. Unicast RPF will not work without Cisco Express Forwarding.

Posted in IPV6, Routing & Switching Lab | Leave a Comment »

IPV6 address’

Posted by Peter Kurdziel on June 26, 2009

http://www.potaroo.net/ispcol/2008-08/ipv6addr.html

::1/128 local host
::FFFF:w.x.y.z IPv4 mapped address – lookup IPv4 address w.x.y.z
FD00::/8 Unique Local Addresses.

    No registry is used for these addresses
FE80::/10 Link Local Addresses

    No registry is used for these addresses
2001:0::/32 Teredo address

    • a Cone NAT flag (C),
    • the Universal (U) flag (set to 0),
    • the Individual/Group (G) flag (set to 0),
    • a reserved flag (R),
    • a 12 bit random value (A) used to deflect intrusion attacks.
      2001:0:cf2e:308c:0:323d:3fa1:c0b0
      Teredo server IPv4 address is cf.2e.30.8c = 207.46.48.140
      External Obscured Port of client is 323d = port 52674
      External Obscured IP address of client is 3f.a1.c0.cb = 192.94.63.70
  • Bits 33 – 64 of the address contain the Teredo server address

    Bits 65 – 80 contain flags: The field format is: CRAA AAUG AAAA AAAA

    Bits 81 – 96 contain the external IPv4 port address, XORed with 1’s

    Bits 97 – 128 contain the external IPv4 address XORed with 1’s

    For example, the Teredo IPv6 address : can be mapped as follows:

2002::/16 6to4 address

    • 2002:cb0a:3cdd:1::1
      cb.0a.3c.dd = 203.10.60.221
  • Bits 17 – 48 contain the IPv4 address of the 6to4 gateway

    For example, the 6to4 address has the IPv4 gateway address of

Posted in IPV6, Routing & Switching Lab | Leave a Comment »

IPV6 stateless autoconfiguration

Posted by Peter Kurdziel on April 13, 2009

The following is a summary of the steps a device takes when using stateless autoconfiguration:

1. Link-Local Address Generation: The device generates a link-local address. Recall that this is one of the two types of local-use IPv6 addresses. Link-local addresses have “1111 1110 10” for the first ten bits. The generated address uses those ten bits followed by 54 zeroes and then the 64 bit interface identifier. Typically this will be derived from the data link layer (MAC) address as explained in the topic on interface identifiers, or it may be a “token” generated in some other manner.
2. Link-Local Address Uniqueness Test: The node tests to ensure that the address it generated isn’t for some reason already in use on the local network. (This is very unlikely to be an issue if the link-local address came from a MAC address but more likely if it was based on a generated token.) It sends a Neighbor Solicitation message using the Neighbor Discovery (ND) protocol. It then listens for a Neighbor Advertisement in response that indicates that another device is already using its link-local address; if so, either a new address must be generated, or autoconfiguration fails and another method must be employed.
3. Link-Local Address Assignment: Assuming the uniqueness test passes, the device assigns the link-local address to its IP interface. This address can be used for communication on the local network, but not on the wider Internet (since link-local addresses are not routed).
4. Router Contact: The node next attempts to contact a local router for more information on continuing the configuration. This is done either by listening for Router Advertisement messages sent periodically by routers, or by sending a specific Router Solicitation to ask a router for information on what to do next. This process is described in the section on the IPv6 Neighbor Discovery protocol.
5. Router Direction: The router provides direction to the node on how to proceed with the autoconfiguration. It may tell the node that on this network “stateful” autoconfiguration is in use, and tell it the address of a DHCP server to use. Alternately, it will tell the host how to determine its global Internet address.
6. Global Address Configuration: Assuming that stateless autoconfiguration is in use on the network, the host will configure itself with its globally-unique Internet address. This address is generally formed from a network prefix provided to the host by the router, combined with the device’s identifier as generated in the first step.

Posted in IPV6, Real World | Leave a Comment »