'How to form DHCPDISCOVER via scapy on Python?

I created a request using scapy. It works fine with my eth0 interface. I send a message to the discoverer and i get an offer. But it doesn't work through the wlan0 interface, when I connect to it via wifi and try to send a packet. Why is this happening ? How to fix it ?

from scapy.all import *

conf.checkIPaddr = False


dhcp_discover = Ether(dst='ff:ff:ff:ff:ff:ff',src=RandMAC())  \
                 /IP(src='0.0.0.0',dst='255.255.255.255') \
                 /UDP(sport=68,dport=67) \
                 /BOOTP(op=1, chaddr=RandMAC()) \
                 /DHCP(options=[('message-type','discover'),('end')])

#sendp(dhcp_discover,iface='eth0') # Ok 
sendp(dhcp_discover,iface='wlan0') # not working

enter image description here



Solution 1:[1]

Discover packets can be broadcasted only in the same network . It is dropped by the router that is it cannot be routed. If the server is in other network you'll need dhcp-relay / dhcp-helper.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 gerrit_noob