Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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.

share|improve this question
add comment

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

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

5 Answers

up vote 2 down vote accepted

Use delete:

ifconfig en1 delete 192.168.141.99
share|improve this answer
add comment

I believe a reboot should reset it.

share|improve this answer
    
That might. But I'd rather leave it than sit through a reboot :P –  David Wolever Sep 25 '11 at 2:07
add comment

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

sudo ifconfig set en1 BOOTP
sudo ifconfig 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
share|improve this answer
    
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
add comment

Try:

sudo ifconfig en1 down
sudo ifconfig en1 up
share|improve this answer
    
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
add comment

Try :

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.