Crafting a DHCP OFFER packet in scapy

I'm writing a very simple DHCP server using scapy and I'm stuck on sending an offer packet. Right now I'm doing it like this:

ethernet=Ether(dst=dest_mac, src=hw, type=0x800)
ip=IP(dst=dest_addr, src=srv_ip)
udp=UDP(sport=67, dport=68)
bootp=BOOTP(op=2, yiaddr=dest_addr, siaddr=srv_ip, chaddr=client_mac)
dhcp=DHCP(options=[("message-type", "offer"), ("server_id", dest_addr), ("broadcast_address", broadcast), ("router", gateway), ("subnet_mask", netmask)])


Client is ISC DHCP, installed on ubuntu server 16.04. I can see Discovery packets sent by dhclient in Wireshark, but I can't see offer packets which are sent by my server (scapy says: sent 1 packets, so it looks ok). So I think I've done something wrong while crafting the offer packet.

As it doesn't even can be seen in Wireshark, I think the problem somewhere is on IP protocol layer or lower (I sent malformed packets earlier and I could see them in Wireshark).

UPD: Output of 1 2

Not sure, but maybe problem is in checksums and/or length of IP header? Should I calculate it manually or scapy can do it itself?

1 answer

  • answered 2018-04-25 19:46 kekyc

    I added interface name to sendp: sendp(of_pack, iface="ens33"). Now it at least can be seen through wireshark.