I try to make a DHCP pachet with parameter request list option and to add three parameters in that request.
This is what i done but the pachet I see on Wireshark look`s to be malformed:
dhcp_pkt = Ether(dst="ff:ff:ff:ff:ff:ff")/IP(src="0.0.0.0",dst="255.255.255.255")/UDP(sport=68,dport=67)/BOOTP(chaddr=MAC_SOURCE)/DHCP(options=[("message-type","request"),("param_req_list", "subnet_mask", "router", "domain"),"end"])
I also try to pass the parametes as a list of codes of the parameters i want to be included in the request list, but still the packet is malformed.
Advertisement
Answer
(this answer deals with a discover packet, not a request packet, because that’s what I’m writing)
You can create the DHCP frame like this:
dhcp_options = [ ("message-type", "discover"), ("param_req_list", [ DHCPRevOptions["subnet_mask"][0], # by name DHCPRevOptions["router"][0], DHCPRevOptions["name_server"][0], 15, # aka "domain name ]), "end" ] dhcp = DHCP(options=dhcp_options)
Once you’ve crafted the ether
, ip
, udp
and bootp
frames:
packet = ether/ip/udp/bootp/dhcp