# Configuring multiple wifi access



## Dinchamion (Nov 23, 2009)

Hello,

I just installed FreeBSD on my laptop, and I have a problem I can't seem to solve with my wifi card.

I use the laptop at home as well as in my office, and obviously I'd like it to connect automatically to the appropriate network. However, my office uses DHCP with WPA-PSK, while at home I'm using static IP with WEP. So far I could configure both, but they're exclusive - I have to manually comment out one of them in rc.conf to use the other one.

Is there any way to configure the network so it can switch automatically?

Thanks in advance!


----------



## fronclynne (Nov 23, 2009)

If you have gnome installed, I believe you can use its (user level) network manager.  You would have to comment out your "ifconfig_*" lines from /etc/rc.conf so it doesn't get angry.

I believe it's /usr/local/bin/nm-applet (I'm doing this from memory: I don't have gnome on my freebsd machine and my Lady's unbunutu netbook is with her at the moment).

I would suppose that KDE has a similar functionality, & there may even be some stand-alone applications that do user-level [wireless] networking.


----------



## aragon (Nov 24, 2009)

Actually, I think the gnome network manager is one of those utilities that has never been ported to FreeBSD (any takers?).

You might try net/pcbsd-netmanager.

Otherwise just enable WPA at home too (which you should be using anyway), and wpa_supplicant will auto connect to it when you start your wlan.  Then just the static ip issue you need to sort out.


----------



## fronclynne (Nov 24, 2009)

aragon said:
			
		

> Actually, I think the gnome network manager is one of those utilities that has never been ported to FreeBSD (any takers?).
> 
> You might try net/pcbsd-netmanager.
> 
> Otherwise just enable WPA at home too (which you should be using anyway), and wpa_supplicant will auto connect to it when you start your wlan.  Then just the static ip issue you need to sort out.



I think that wpa_supplicant will work fine with empty passphrases*.  But, yeah, unless you're +500M from the nearest untrusted human & you have good security camers, you should most certainly be using something to secure your home network.


* from  my /etc/wpa_supplicant.conf
(in part)

```
network={
   ssid="linksys"
   key_mgmt=NONE
}
```


----------



## mickey (Nov 24, 2009)

Dinchamion said:
			
		

> However, my office uses DHCP with WPA-PSK, while at home I'm using static IP with WEP. So far I could configure both, but they're exclusive - I have to manually comment out one of them in rc.conf to use the other one.
> 
> Is there any way to configure the network so it can switch automatically?



Automatic switching between multiple WiFi networks depending upon availability can easily be achieved, by defining a separate network block for each of the networks in your _/etc/wpa_supplicant.conf_ file. Optionally you may assign a priority value to each network block, in order to define precedence, if multiple networks are available simultaneously.

You should consult _wpa_supplicant.conf(5)_ for a detailed explanation of the syntax of this file, and some examples.

To use wpa_supplicant, your interface definition in _/etc/rc.conf_ would look like:

```
ifconfig_XX="WPA DHCP"
```

The only problem I see here is that you are using a static IP at home, meaning there is no DHCP server to assign an address. Perhaps it would be possible, to tweak this using the dhclient.conf file. Or you setup a DHCP server in your home network.


----------



## bschmidt (Nov 24, 2009)

Might it be possible to use an alias for such a scenario?
e.g.

```
defaultrouter="192.168.0.1"
ifconfig_wlan0="WPA DHCP"
ifconfig_wlan0_alias0="inet 192.168.0.2 netmask 255.255.255.0
```

I'm not sure whether DHCP handles default route correctly, worth a try anyway.


----------



## Dinchamion (Nov 25, 2009)

Thanks for the suggestions!

I don't want to set up DHCP at home, it's just another security hole in my opinion, and I don't have control over what goes on in the office.

On linux I use 'fallback': if the primary (home) network is not available, it falls back to the office one. Is this a viable option in BSD?


----------

