Router Advertisements with scapy (NETLAB)

Purpose

To practice using Router Advertisements to distribute IPv6 addresses.

Background

In IPv4, addresses are usually distributed via DHCP, which is a "pull" process--when a client boots up, it requests an address from the local DHCP server, as shown below.

(After this process, a couple of additional DHCP packets are sent to make sure that no other device is using the same address.)

However, in IPv6 the most common method is through Router Advertisements. This is a "push" process: the router announces its presence with a special packet that is multicast to all nodes, and they then join the network, as shown below.

(After this process, a couple of additional Neighbor Discovery packets are sent to make sure that no other device is using the same address.)

A Routing Advertisement packet is shown below. Notice these elements, outlined in red:

Starting your Sender Machine

Open the Kali32 virtual machine. This is your Sender machine. Log in as root with the password toor

Starting your Receiver Machine

Open the Kali64 virtual machine. This is your Receiver machine. Log in as root with the password toor

Finding your Sender Machine's MAC Address

On the Sender Machine, in a Terminal window, execute this command:
ifconfig eth0
Find the HWaddr value, which is highlighted in the figure below on this page. Record this value--you will need it later.

Creating an IPv6 Object

On the Sender Machine, execute these commands to create an IPv6 packet and examine it:
scapy

a = IPv6()

a.dst = "ff02::1"

a.display()

Your IPv6 object should now have both the src and dst fields filled in, as shown below on this page.

If the colors are difficult to see, adjust them by clicking Edit, "Profile Preferences", Colors. I used "Black on light yellow".

Creating an ICMPv6 Router Advertisement Object

In the Sender Machine, execute these commands:
b = ICMPv6ND_RA()

b.display()

Your ICMPv6 Router Advertisement object should have a type of Router Advertisement, as shown below on this page:

Specifying the Source Link-Layer Address

In the Sender Machine, execute these commands. In the second command below, replace the value shown with the HWaddr value you found with the ifconfig command at the start of this project:
c = ICMPv6NDOptSrcLLAddr()

c.lladdr = "00:50:56:24:3b:c0"

c.display()

The lladdr value should match your HWaddr, as shown below on this page:

Specifying the Maximum Transfer Unit

In the Sender Machine, execute these commands:
d = ICMPv6NDOptMTU()

d.display()

The mtu value should be 1280, as shown below on this page:

Specifying the Advertised Prefix

In the Sender Machine, execute these commands:
e = ICMPv6NDOptPrefixInfo()

e.prefixlen = 64

e.prefix = "d00d::"

e.display()

The prefixlen and prefix values should be correct, as shown below on this page:

Starting Wireshark

In the Sender Machine, in the Terminal window menu bar, click File, "Open Terminal".

In the new Terminal window, execute this command:

wireshark
Wireshark shows a couple of warning messages, saying that it's not recommended to run it as root.

Press Enter to close them. In the Wireshark window, click eth0 to highlight it, as shown below.

Then click Start.

Sending a Router Advertisement Packet

In the Sender Machine, in the Terminal window, at the >>> prompt, execute this command:
send(a/b/c/d/e)

You should see a message saying "Sent 1 packets".

The Wireshark window should show the Router Advertisement packet. Click it in the upper pane to select it, and expand the middle pane so the Prefix: d00d:: information is visible, as shown below on this page:

Viewing the Autoconfigured Address on the Client Machine

On the Client Machine, in a Terminal window, execute this command:
ifconfig eth0
You should see an automatically configured IPv6 address starting with the d00d:: prefix, as shown below on this page:


Source

http://www.packetlevel.ch/html/scapy/scapyipv6.html


Last modified: 3-27-11, 1 pm
Revised 6-12-16 for NETLAB