[PYTHON] scapy IPv6

Memorandum.

Router solicit

#Keep throwing as usual
>>> sendp(Ether()/IPv6()/ICMPv6ND_RS())
#I want a response
>>> sr1(IPv6()/ICMPv6ND_RS())

DHCPv6 solicit requires client-id (RFC 3351)

>>> client_id=DUID_LLT(lladdr=get_if_hwaddr(conf.iface6))
>>> a=sr1(IPv6(dst="ff02::1:2")/UDP()/DHCP6_Solicit()/DHCP6OptClientId(duid=client_id))
>>> client_id=a[DHCP6OptClientId].duid
>>> server_id=a[DHCP6OptServerId].duid

When connected with DHCPv6 solicit, advertise, request, reply, it looks like this. dnsmasq responds for the time being.

a=sr1(IPv6(dst="ff02::1:2")/UDP()/DHCP6_Solicit()
 /DHCP6OptClientId(duid=DUID_LLT(lladdr=get_if_hwaddr(conf.iface6))))
b=sr1(IPv6(src=a[IPv6].dst, dst=a[IPv6].src)/UDP()/DHCP6_Request()
 /DHCP6OptServerId(duid=a[DHCP6OptServerId].duid)
 /DHCP6OptClientId(duid=a[DHCP6OptClientId].duid))

Cisco will not respond without DHCP6OptIA_NA in DHCPv6_Solicit. If you execute the description of RFC 3351 as it is, it will be attached (it is not required by Ichiou validation).

a=sr1(IPv6(dst="ff02::1:2")/UDP()/DHCP6_Solicit()
 /DHCP6OptClientId(duid=DUID_LLT(lladdr=get_if_hwaddr(conf.iface6)))
 /DHCP6OptIA_NA(iaid=1)
)
b=sr1(IPv6(dst="ff02::1:2")/UDP()/DHCP6_Request()
 /DHCP6OptServerId(duid=a[DHCP6OptServerId].duid)
 /DHCP6OptClientId(duid=a[DHCP6OptClientId].duid)
 /DHCP6OptIA_NA(iaid=1)
)

In addition, DHCPv6-RelayForward and RelayReply are performed. The src address in the example below is extracted from the value when it was assigned to stateful. If you are using slaac, you should be able to calculate it at hand.

c=sr1(IPv6(dst="ff05::1:3", src=b[DHCP6OptIA_NA].ianaopts[0].addr)
 /UDP(sport=547, dport=547)
 /DHCP6_RelayForward(linkaddr="fd00::152", peeraddr="fe80::2000:1")
 /DHCP6OptRelayMsg()/DHCP6_Solicit()
  /DHCP6OptClientId(duid=DUID_LLT(lladdr="00:11:22:33:44:55"))/DHCP6OptIA_NA(iaid=2)
)

Recommended Posts

scapy IPv6
Scapy Tips