Returning wlan to initial state

Hello,

I have been periodically searching for a solution to this but I am not sure it is even possible.

if I do a bunch of random things to my wireless interface like...

Code:
# ifconfig wlan0 ssid "somelan" up
# ifconfig wlan0 wepmode on wepkey "somekey"
# ifconfig wlan0 inet 192.168.1.1 netmask 255.255.255.0 up

Is there any way I can undo all this jibberish?

Currently I need to do something like

Code:
# ifconfig wlan0 ssid "" wepmode off wepkey "" down

I still havnt reset the inet or netmask yet either and it is a bit of a pain to have to do this, i.e when swapping from a wep or open network to a wpa one.

something like...

Code:
# ifconfig wlan0 returntonormal

Any ideas?
 
kpedersen said:
Is there any way I can undo all this jibberish?
[snip]
something like...
Code:
# ifconfig wlan0 returntonormal
As far as I know there's no returntonormal command, but you could of course figure out what the defaults are and then conjure up a script or alias to reset those. And although I haven't tested it, if the NIC driver is a module you could try to unload and reload it again. As I said I didn't test it but it may or may not reset the defaults.

Hope this helps (and perhaps someone else has a better idea),

Fonz

Edit: See bbzz's answer. I should have thought of that, he did.
 
Hi, thanks bbzz this solution seems to work great :)

I guess I am lucky that since FreeBSD 8.0, the wireless device needs to be aliased before use.

Would it be possible to do the same type of thing with a non aliased interface?

For example em0, ath0 etc...?
 
There's interface restart with
# /etc/rc.d/netif restart

But that affects everything. Other than that, not sure.
 
bzzz, if I am not mistaken the command you've given can be followed by the interface's name (ie wlan0 in our case), but the truth is that I don't use it cause I am not very sure that it only touches the interface I am interested in.
 
Remove assigned IP address from network interface:
[CMD=]# ifconfig <interface name> down delete[/CMD]
 
mamalos said:
bzzz, if I am not mistaken the command you've given can be followed by the interface's name (ie wlan0 in our case), but the truth is that I don't use it cause I am not very sure that it only touches the interface I am interested in.

Correct, and, it does. Use 'wlanX' to 'delete' cloned interface. It only affects that interface, and it removes ALL configuration.

This also helps in a case when cloned interface start flapping up/down (check dmesg). Happens quite often, in fact.
 
Back
Top