# Failing at setting up static wireless networking with no DHCP



## BoggledByBSD (Jul 23, 2016)

I can't help but feel like I'm missing something here. Following all the steps in https://www.freebsd.org/doc/handbook/network-wireless.html, with an Atheros AR9485 card, I've worked my way backwards towards the simplest possible configuration, trying to rule everything out.

I started with a WPA2-PSK setup with wpa_supplicant, and a static IP address. I reconfigured my networking hardware for DHCP, took out the encryption, and adjusted the corresponding settings in FreeBSD accordingly for troubleshooting purposes, as per the FreeBSD manual reading 





> Simplify the configuration as much as possible. If using a security protocol such as WPA or WEP, configure the access point for open authentication and no security to see if traffic will pass.



I've gone back to an open, non-secure configuration for troubleshooting purposes. One thing that keeps popping up when using ping to troubleshoot "No route to host", except when pinging the address under the inet section under wlan0. defaultrouter="*.*.*.*" is set in rc.conf, but I'll just get a "No route to host" error if I ping that, unless my wired connection is plugged in.

I'm getting the impression that the my wlan is looking for a different route than my wired connection, but i cannot find anywhere that says that should be the case.

Some information:
My wireless portion of my ifconfig reads:

```
aht0:  flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 2290
         ether my mac id
         nd6 options=21<PERFORMUND,AUTO_LINKLOCAL>
         media: IEEE 802.11 Wireless Ethernet autoselect mode 11ng
         status: associated
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
         ether my mac id
         inet my DHCP lease netmask 0xffffff00 broadcast my dhcp lease.255
        media: IEEE 802.11 Wireless Ethernet MCS mode 11ng
        status: associated
        ssid my ssid channel 1 (2412 MHZ 11g ht/20) bssid my routers mac(except the last 2 are b2 instead of ae
        regdomain 96 indoor ecm authmode OPEN privacy OFF txpower 20 bmiss 7
        scanvalid 60 protmode CTS ampdulimit 64k ampdudensity 8 shortgi wme
        burst
```

Settings in /etc/rc.conf that have changed since I started trying to set up wireless:

```
wlans_ath0="wlan0"
ifconfig_wlan0="DHCP"
```

Settings in /boot/loader.conf that have changed:

```
if_ath_load="YES"
if_ath_pci_load="YES"
wlan_wep_load="YES"
wlan_ccmp_load_"YES"
wlan_tkip_load="YES"
```

My router gives me a table for monitoring network traffic. Here's what passes through on boot or initialization of the device.
no RX packets, 1 TX packet with a byte size of 356 RX and 361 TX, no dropped, no errors, 2 Multicast, 0 Collisions.


----------



## wblock@ (Jul 23, 2016)

BoggledByBSD said:


> Settings in /boot/loader.conf that have changed:
> 
> ```
> if_ath_load="YES"
> ...


None of these are needed.

Did you see the Quick Start section in that section?  It shows what is really needed: https://www.freebsd.org/doc/en_US.I...rk-wireless.html#network-wireless-quick-start

Use /etc/wpa_supplicant.conf to enter your SSID and PSK.

Do not set defaultrouter in /etc/rc.conf unless you are running a gateway (which you are not).

Do not try to run it with a static IP address.  Get a DHCP-assigned address from the access point.  The default setup does all that.


----------



## BoggledByBSD (Jul 23, 2016)

The first thing I did was try the Quick Start. I'm re-tracing my steps trying to figure out where I went wrong, and i'm not sure if it's the stuff you said I didn't need from my loader and removed, but It's working now with the 
	
	



```
ifconfig_wlan0="WPA SYNCDHCP"
```
setting just fine.

Although, I try to keep everything on my networks static, and don't see why a static IP config for a wireless connection wouldn't work, I can't seem to make it. Would be nice if I could, but just having wireless on my BSD machine is nice!


----------



## kpa (Jul 23, 2016)

wblock@ said:


> None of these are needed.
> 
> Did you see the Quick Start section in that section?  It shows what is really needed: https://www.freebsd.org/doc/en_US.I...rk-wireless.html#network-wireless-quick-start
> 
> ...



You have an error there, defaultrouter is for setting the default gateway which is what you want with a static IP setup. What you probably meant was the gateway_enable setting.


----------



## wblock@ (Jul 23, 2016)

kpa said:


> You have an error there, defaultrouter is for setting the default gateway which is what you want with a static IP setup. What you probably meant was the gateway_enable setting.


Doh!

As far as a static IP address, it can be done.  The easiest way is to just have the DHCP server assign a fixed address.

I'm sure it can be done the hard way, replacing the DHCP part in the rc.conf setting with inet 1.2.3.4/24.  But get it working first with the simplest setup, then try refinements like a static IP address.


----------



## BoggledByBSD (Jul 23, 2016)

Well, this is interesting. Now that I have my wireless working fine with DHCP, I was trying to get it to work with a static config. I found something peculiar to me that suggests I'm missing something pretty basic about networking in FreeBSD.

I was doing things like replacing ifconfig_wlan0="WPA SYNCDHCP" with something like ifconfig_wlan0="inet _192.168.1.100_ netmask _255.255.255.0_ ssid _your_ssid_here_" or ifconfig_wlan0="inet _192.168.1.100/24 _ssid _your_ssid_here_", and have defaultrouter= point at the local router that was serving my DHCP before, and the one that allows me to static my wired config. I did not have any success with setting up the wireless as static, but now I realized I have a more basic problem.

What seems to be the case is I cannot have 2 active network adapters running at the same time. I have to use service netif start/stop _adapter name_ to bring up my wired connection if I turn off DHCP or wireless on my router, and vice versa, have to turn off my wired connection if I want to turn on my wireless connection. If i try to bring 2 up at the same time, or have 2 connections reading ifconfig__anything_ in my rc.conf, only 1 will start, the other will give me a "No route to host" error when pinging anything other than the local adapter on the FreeBSD machine until I stop the other one.

Now that I know this, I'm wondering if it's normal, and if i can, have 2 network adapters running at the same time. If not, running the service command to start and stop adapters when I'm switching isn't a big deal, but I still haven't found the proper configuration for a static IP on my wireless connection.

No matter what order I start or stop my adapters, if I put anything static in my wlan0 section of my ifconfig_wlan0 in my rc.conf, it will say "no carrier" when checking ifconfig.


----------



## wblock@ (Jul 23, 2016)

What are you trying to do with multiple adapters?  If you use them to access different networks, you'll have to set up static routes.  I'm sure that can be done with rc.conf, but don't know the syntax.

If you just want it to auto-switch from wireless to wired when available, see the Handbook section on lagg(4): https://www.freebsd.org/doc/en_US.I...ation.html#networking-lagg-wired-and-wireless


----------



## BoggledByBSD (Jul 24, 2016)

Nothing complicated like accessing different networks, just using the cable when I'm close to the router and easily switching to wireless when I move away and want to run on battery. I'm sure the failover config would work fine.

But like I said, bringing up the adapters manually isn't really a big deal, I would just like to see any successful config for static wireless. Everything I look at indicates, especially with wireless, using DHCP is standard and I would like to run a static wireless network and haven't configured myself or seen a successful configuration for it.

EDIT: Well, even the failover config guide seems to rely on DHCP, which is what i'm trying to avoid. I'm trying to find a config for static-ing both the wired and wireless networks, even with no failover, or if i have to bring up the devices manually.


----------



## BoggledByBSD (Jul 24, 2016)

Well, what lagg does is great, cloning the interface and using the same local address, seamlessly allowing you to switch between wired and wireless. I do have to sacrifice any static IP addressing though, but hey, if this is what it takes to get a seamless wired/wireless for now, until, if and when I can find a way to do it staticly - it will help greatly.


----------



## wblock@ (Jul 24, 2016)

The Handbook example shows assigning a MAC address to the wireless interface.  Then you can configure the DHCP server to assign a static IP address to that MAC address.

Although I suppose you can set it up through rc.conf, but I prefer to set that up in the DHCP server so it's all in one place.


----------



## BoggledByBSD (Jul 24, 2016)

wblock@ said:


> The Handbook example shows assigning a MAC address to the wireless interface.  Then you can configure the DHCP server to assign a static IP address to that MAC address.
> 
> Although I suppose you can set it up through rc.conf, but I prefer to set that up in the DHCP server so it's all in one place.



Not a bad idea. I was intent on disabling DHCP in my router once I had everything set in BSD, but the way lagg works by spoofing a mac address to 2 interfaces, I didn't realize right away that my networking hardware had the ability to set a static DHCP, binding that MAC to a specific local area address.

I prefer to set it up in the OS so the networking hardware is more set-and-forget, but your method accomplishes the same ends by a different means. I'll just use your method and consider the configuration of a static IP for wireless in rc.conf to be a moot point for now. Thanks


----------

