# FreeBSD as WiFi access point



## mzv (Dec 8, 2010)

Hi all,

I'm trying to configure access point. Access point is discoverable, authorization works fine, DHCP server receives request for ip-address, sends response, but wifi client doesn't receive anything.

USB-adapter D-Link DWA-140 (RT2820)
FreeBSD 8.1 server, LAN linked via ethernet (192.168.0.10)
DHCP-server  (192.168.0.4)
Gate  (192.168.0.1)



```
# cat /boot/loader.conf
runfw_load="YES"
if_run_load="YES"
```


```
#cat /etc/rc.conf
wlans_run0="wlan0"
create_args_wlan0="wlanmode hostap"
cloned_interfaces="bridge0"
ifconfig_bridge0="inet 192.168.0.10 netmask 255.255.255.0 addm em0 addm wlan0 up"
ifconfig_em0="up"
ifconfig_wlan0="up mode autoselect"

hostapd_enable="YES"
gateway_enable="YES"
```


```
# cat /etc/hostapd.conf
interface=wlan0
ctrl_interface=/var/run/hostapd
ctrl_interface_group=wheel
ssid=My_WiFi
wpa=1
wpa_passphrase=PASSWORD
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP TKIP
```


```
# ifconfig
em0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=2098<VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC>
        ether 00:14:5e:41:14:14
        media: Ethernet autoselect (1000baseT <full-duplex>)
        status: active
em1: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=209b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC>
        ether 00:14:5e:41:14:15
        media: Ethernet autoselect
        status: no carrier
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=3<RXCSUM,TXCSUM>
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
        inet6 ::1 prefixlen 128
        inet 127.0.0.1 netmask 0xff000000
        nd6 options=3<PERFORMNUD,ACCEPT_RTADV>
run0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 2290
        ether 00:22:b0:05:18:04
        media: IEEE 802.11 Wireless Ethernet autoselect mode 11g <hostap>
        status: running
bridge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether c6:2a:59:05:33:9e
        inet 192.168.0.10 netmask 0xffffff00 broadcast 192.168.0.255
        id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15
        maxage 20 holdcnt 6 proto rstp maxaddr 100 timeout 1200
        root id 00:00:00:00:00:00 priority 32768 ifcost 0 port 0
        member: wlan0 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
                ifmaxaddr 0 port 6 priority 128 path cost 370370
        member: em0 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
                ifmaxaddr 0 port 1 priority 128 path cost 20000
wlan0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 00:22:b0:05:18:04
        media: IEEE 802.11 Wireless Ethernet autoselect mode 11g <hostap>
        status: running
        ssid My_WiFi channel 1 (2412 MHz 11g) bssid 00:22:b0:05:18:04
        country US authmode WPA privacy MIXED deftxkey 2 TKIP 2:128-bit
        TKIP 3:128-bit txpower 0 scanvalid 60 protmode CTS wme dtimperiod 1
        -dfs
```


----------



## SirDice (Dec 8, 2010)

Try without the bridging. As I understood it not all wireless network drivers work with bridging. This is because the wireless interface basically has to spoof a source MAC address. Not all drivers accept this.

Without bridging you'll have 2 separate subnets though. You'll need a DHCP relay agent to cross it.


----------



## kpedersen (Dec 8, 2010)

Yeah it seems that the bridge stuff doesn't always work with certain wifi cards.

I attempted it the other direction (wireless to wired network) and found it best to use NAT and separate networks instead.

Does ndis support bridging? Perhaps you could attempt to use the windows wifi drivers with ndisgen rather than the native freebsd ones?


----------



## SirDice (Dec 9, 2010)

kpedersen said:
			
		

> I attempted it the other direction (wireless to wired network) and found it best to use NAT and separate networks instead.


NAT will only complicate things. There's no need for it as long as routing is set up properly.



> Does ndis support bridging? Perhaps you could attempt to use the windows wifi drivers with ndisgen rather than the native freebsd ones?


No idea but I doubt it.


----------



## richardpl (Dec 9, 2010)

if_bridge(4) depends on random MAC address and with ndis(4) you can configure custom MAC address only via sysctl before device is inititalized.
So it is possible but highly impractical.


----------



## aragon (Dec 9, 2010)

richardpl said:
			
		

> if_bridge(4) depends on random MAC address


Not necessarily...



			
				if_bridge(4) said:
			
		

> If sysctl(8) node net.link.bridge.inherit_mac has non-zero value, newly
> created bridge will inherit MAC address from its first member instead of
> choosing random link-level address.


----------

