19

I recently used ifconfig en1 1.2.3.4 to set the IP address of a network interface (specifically, the wireless card) on a Mac… How can I remove/unset it?

Using the graphical network configuration tool doesn't seem to change (or even be aware of) this address - when I use it to manually set an address, a second address is added to the device.

For example, right now ifconfig shows:

en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    ether 00:23:xx:xx:xx:xx 
    inet 192.168.141.99 netmask 0xffffff00 broadcast 192.168.141.255
    inet 192.168.1.112 netmask 0xffffff00 broadcast 192.168.1.255
    media: autoselect
    status: active

The first address - 141.99 - is the address I manually set. The second address — 1.112 — is the address assigned by my network's DHCP server.

migrated from serverfault.com Sep 24 '11 at 16:55

This question came from our site for system and network administrators.

22

Use delete:

ifconfig en1 delete 192.168.141.99
  • 4
    This didn't work for me, I had to do ifconfig en1 del 192.168.141.99 on Ubuntu. Hope it helps someone. – Frodik Aug 21 '15 at 13:26
  • @Frodik What's the difference? – voices Sep 20 '16 at 10:53
  • del instead of delete – Kousik Nandy Jun 19 '18 at 20:39
7

To clear all ip address associated with en1:

sudo ifconfig en1 0.0.0.0
  • I confirm that this worked for me. – volatilevar Oct 31 '16 at 14:43
0

I believe a reboot should reset it.

  • 1
    That might. But I'd rather leave it than sit through a reboot :P – David Wolever Sep 25 '11 at 2:07
  • A clear alternative, however this answer does not use of the ifconfig command as the question specified. – Josiah DeWitt May 2 '18 at 20:52
0

Try:

sudo ifconfig en1 down
sudo ifconfig en1 up
  • Sorry, but this doesn't work — the address persists past the down/up. – David Wolever Sep 24 '11 at 18:37
  • Did you ifconfig en1 back to your original address? If you didn't then it's obviously going to be the same one you had changed it to. – l'L'l Sep 24 '11 at 19:49
  • Sorry, my original question wasn't as clear as it could be. There was no “original address” - normally I have addresses assigned via DHCP, which now adds a second address to the interface. – David Wolever Sep 25 '11 at 2:08
0

Sounds like you are looking to change the device en1 from 'static' to 'dhcp'. To do this perform the following:

sudo ipconfig set en1 BOOTP
sudo ipconfig set en1 DHCP

After making the config changes you will need to bring that interface down and back up:

sudo ifconfig en1 down
sudo ifconfig en1 up
  • Which version of ifconfig uses that syntax? The manpage for ifconfig on my machine (10.6.7) mentions nothing of either a set action or dhcp. – David Wolever Sep 25 '11 at 2:07
  • This may work on linux but it does not appear to work in BSD ifconfig that ships with MacOS. – Thom Nichols Feb 26 '18 at 13:39
-2

Try :

ifconfig en* down detach delete 
  • Please could you expand this answer to explain what the various flags and options are doing? – Graham Miln Feb 11 '14 at 7:44
  • and why does this work and other answers do not? – user151019 Feb 11 '14 at 11:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .