dhcppython icon indicating copy to clipboard operation
dhcppython copied to clipboard

sample code in readme.md could not run in my computer

Open younthOL opened this issue 5 years ago • 1 comments

I copy sample code in readme.md which function at DHCP client, my env is centos7 and python3.8.2, my code is: import dhcppython client = dhcppython.client.DHCPClient(interface="wlp3s0") lease = client.get_lease(mac_addr="fa:b3:9e:89:86:32", broadcast=True, relay=None, server="255.255.255.255", options_list=None)

why it comes : Traceback (most recent call last): File "dhcp_clients.py", line 8, in client = dhcppython.client.DHCPClient(interface="wlp3s0") # wlp3s0 File "/usr/local/Python3.8/lib/python3.8/site-packages/dhcppython/client.py", line 96, in init self.writing_sockets = self.get_writing_sockets() File "/usr/local/Python3.8/lib/python3.8/site-packages/dhcppython/client.py", line 329, in get_writing_sockets client_sock = self.get_socket(host, port) File "/usr/local/Python3.8/lib/python3.8/site-packages/dhcppython/client.py", line 320, in get_socket sock.bind((host, port)) OSError: [Errno 98] Address already in use

younthOL avatar Jun 12 '20 10:06 younthOL

Hello, you almost certainly have a DHCP client service already bound to port 68. You can check this by running something like sudo netstat -tulpn.

I suspect its probably systemd-networkd, in which case you can disable and stop it using sudo systemctl disable systemd-networkd && sudo systemctl stop systemd-networkd. I would advise re-enabling the service once you are done.

lvfrazao avatar Jun 12 '20 14:06 lvfrazao