How to force a new DHCP discover

5,043

You might be able to do it by toggling DHCP on/off with sudo ipconfig set en0 none; sudo ipconfig set en0 dhcp, or with doing something similar via the GUI.

Or try downing/upping the interface with ifconfig en0 down; ifconfig en0 up

I believe configd is the process where the DHCP client code lives. You could try sending a SIGHUP to configd with sudo killall -HUP configd, or just kill configd outright and let launchd auto-relaunch it: sudo killall configd. This suggestion is a bit extreme. Don't be surprised if you end up with networking in a weird state after this. If that happens, rebooting might be the easiest way to get it back in order.

Check out the man pages for ipconfig, ifconfig and networksetup for other ideas of how to perturb the interfaces from the command line.

Note: Check what the correct BSD unix-level interface identifier is for your interface, and replace en0 in the examples above with the correct identifier for your situation.

Share:
5,043

Related videos on Youtube

soupdiver
Author by

soupdiver

Updated on September 18, 2022

Comments

  • soupdiver
    soupdiver over 1 year

    I'm analysing my network traffic at home, and I want to force my Mac to completely renew its DHCP stuff. Renewing my DHCP lease only reveals two DHCP packets sent over my interface, but I want to see the whole process in Wireshark. Is there a command-line way to do this?

    • Bill Nace
      Bill Nace over 10 years
      DHCP discovery can be accomplished with only 2 packets sent. What makes you think there are more?
    • soupdiver
      soupdiver over 10 years
      the complete handshake should have more that 2 packets involved or? discover, offer, request, ack at least I think
    • Bill Nace
      Bill Nace over 10 years
      Ah. I misunderstood your use of "sent over my interface." Your Mac sends the discover and request packets. It receives the offer and ack packets. Which two are you seeing?
    • soupdiver
      soupdiver about 10 years
      Already solved. Now I can see all 4 packets in wireshark
  • soupdiver
    soupdiver over 10 years
    thanks sudo ipconfig set en0 none; sudo ipconfig set en0 dhcpdid the trick