FreeBSD Wireless – Configuring a wireless interface on FreeBSD 8.1

FreeBSD Wireless

FreeBSD has strong support for wireless devices. Here is a quick overview of how to manage wireless interfaces on FreeBSD.

Prerequisites

For Wireless access requires the following:

  1. A wireless interface card
  2. wpa_supplicant
  3. An Access Point

Note: In later of versions of FreeBSD, since 2008, wpa_supplicant was included in base. If you are running an older version of FreeBSD, then wpa_supplicant was a port.  So if you are on FreeBSD 8, you have wpa_supplicant.

To complete this guide, we will also use:

  1. A FreeBSD desktop environment.
  2. wpa_gui

Note: wpa_gui is not included in the base system but is found in ports.

Step 1 – Determine what wireless interface card you have

Some wireless cards are built into the kernel, and may already be loaded.  If you know what card you have, skip this step.

  1. First, we need to find out what wireless card you have. Run ifconfig and look at the network cards you have.  Then to see which one is your wireless card, compare them to the wireless kernel module list here:
    http://www.freebsd.org/releases/8.1R/hardware.html#WLAN

    $ ifconfig
    em0: flags=8843 metric 0 mtu 1500
            options=219b
            ether 00:1e:37:d0:91:cb
            media: Ethernet autoselect
            status: no carrier
    lo0: flags=8049 metric 0 mtu 16384
            options=3
            inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
            inet6 ::1 prefixlen 128
            inet 127.0.0.1 netmask 0xff000000
            nd6 options=3

    Notice in the above configuration, no wireless card was discovered. Here is an example of one with a wireless card.

    em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
            options=219b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,WOL_MAGIC>
            ether 00:1e:37:d0:91:cb
            media: Ethernet autoselect
            status: no carrier
    iwn0: flags=8843 metric 0 mtu 2290
            ether 00:1e:37:d0:91:cb
            media: IEEE 802.11 Wireless Ethernet autoselect mode 11g
            status: associated
    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>
  2. Most wireless cards are PCI devices.  Run pciconf to look for your wireless network card type. This outputs a lot of information, I have snipped my output to isolate only the information about the wireless PCI card.
    $pciconf -lv
    ...
    none1@pci0:3:0:0:       class=0x028000 card=0x10108086 chip=0x42308086 rev=0x61 hdr=0x00
        vendor     = 'Intel Corporation'
        device     = 'Intel Wireless WiFi Link 4965AGN (Intel 4965AGN)'
        class      = network
    ...
  3. Now go to the current release notes for FreeBSD and look through the wireless kernel modules to see which one supports your hardware.
    http://www.freebsd.org/releases/8.1R/hardware.html#WLAN

    Note: I searched for 4965AGN and found my kernel module immediately.
  4. Keep the link open as you move to Step 2.

Step 2 – Make sure the kernel module is loading

If your wireless card is already detected and loading, skip this step.  If not, configure /boot/loader.conf to load your wireless card.

  1. Read the man page for your wireless kernel module, there is a link to it in the hardware notes, to see any special information about loading the kernel module for your kernel module.
  2. Configure the /boot/loader.conf to load the kernel module and make any other required settings to use the kernel module.Example 1 – The Intel iwn kernel module requires a line to load the kernel module and a second line to load the firmware.
    # Wireless
    if_iwn_load="YES"
    iwn4965fw_load="YES"

    Example 2 – The Intel iwi kernel module requires that you accept a license agreement:

    # Wireless
    if_iwi_load="YES"
    legal.intel_iwi.license_ack=1
  3. Save and close the /boot/loader.conf
  4. Now you can either reboot, or you can use kldload to load the kernel modules without rebooting.

Step 3 – Configure the wireless settings in /etc/rc.conf

The rc.conf is where the wireless network card is configured.

  1. In FreeBSD 8 and later, all wireless interfaces should be configured to use the generic wlan device. Then to enable wpa_supplicant, the wlan should be configured to use WPA.
    To make these configurations, add these lines to the /etc/rc.conf.

    wlans_iwn0="wlan0"
    ifconfig_wlan0="WPA DHCP"
  2. Save and close /etc/rc.conf.

Step 4 – Add your Access Point’s (AP) SSID to your /etc/wpa_supplicant.conf

There is a lot of information on how to add an SSID to your /etc/wpa_supplicant.conf file in the man page for wpa_supplicant.conf. But the process is simple.

  1. If you don’t know the SSID, discover or scan for the SSID by running ifconfig wlan0 scan.  Below is an example.
    $ ifconfig wlan0 scan
    SSID/MESH ID    BSSID              CHAN RATE   S:N     INT CAPS
    MyWifi          00:20:e1:96:54:32    6   11M -75:-95  100 E
    OpenNet         da:ce:41:d3:af:3a    6   54M -85:-95  100 IS
    MyWPA           00:24:7b:6b:71:27    1   54M -89:-95  100 EP   RSN WPA WPS
                    00:00:00:00:00:00    1   54M -89:-95  100 E
  2. Now add a network entry for the desired wireless device.  Examples are below:

    Open or no authentication

    network={
            ssid="MyWifi"
            key_mgmt=NONE
    }

    WPA or WPA2

    network={
            ssid="MyWPA"
            psk="SomeP@sswd!"
    }

    More examples

    For more examples, read the man page for wpa_supplicant.conf.

    $ man wpa_supplicant.conf

    Once the SSID is configured properly in the /etc/wpa_supplicant.conf, then an automatic connection to this AP will occur whenever the device is within range.

Step 5 – Install wpa_gui from ports

Often you don’t always know what wireless you are going to connect to and also often you don’t care to store the SSID configuration permanently in the /etc/wpa_supplicant.conf. This is common if you are getting online at an airport, coffee shop, or any hotspot that you don’t frequent. It would be nice to have a graphical interface that shows you the SSIDs available, allows you to connect, but doesn’t store the information. wpa_gui is this tool.

  1. Install wpa_gui from ports
    # cd /usr/ports/net/wpa_giu
    # make install
  2. Add the following two lines to the top of the /etc/wpa_supplicant.conf.
    ctrl_interface=/var/run/wpa_supplicant
    ctrl_interface_group=wheel
  3. Restart the wpa_supplicant.# /etc/rc.d/wpa_supplicant restart wlan0
  4. Run wpa_gui.
    $ wpa_gui
    Selected interface 'wlan0'
    Trying to connect to '/var/run/wpa_supplicant/wlan0'

    wpa_gui opens.

  5. Click Scan and a window listing the available SSIDs appears.
  6. Double-click on an SSID to get the configuration windows.  It will try to select the correct settings as best it can, so often you only need to add the psk or passkey, which is essentially a password.
  7. This will connect you to that SSID.

Note: If you do want to save the networks to the wpa_supplicant.conf by default, then add this line. Otherwise, they are not saved. You may or may not want them to be saved.

update_config=1

Additonal Notes

Note 1: PC-BSD has a network configuration tool, so if you are running PC-BSD, wpa_gui is not necessary.

Note 2: There is a command line tool called wpa_cli that is included in the base system.  wpa_cli is useful if you don’t have a graphical environment.

Note 3: I also configured link aggregation, or lagg, so my wired and wireless interfaces share the same MAC.

ifconfig_em0="up"
ifconfig_iwn0="`ifconfig em0 ether`"
ifconfig_iwn0="ether ${ifconfig_iwn0##*ether }"
wlans_iwn0="wlan0"
ifconfig_wlan0="WPA"
cloned_interfaces="lagg0"
ifconfig_lagg0="laggproto failover laggport em0 laggport wlan0 DHCP"

Resources

http://www.freebsd.org/doc/handbook/network-wireless.html
http://www.freebsd.org/releases/8.1R/hardware.html#WLAN
man wpa_supplicant
man wpa_supplicant.conf
man iwn
man iwi


Copyright ® Rhyous.com – Linking to this page is allowed without permission and as many as ten lines of this page can be used along with this link. Any other use of this page is allowed only by permission of Rhyous.com.

17 Comments

  1. boat repair says:

    I am continually invstigating online for ideas that can facilitate me.

    Thanks!

    my blog post: boat repair

  2. yacht sales says:

    It?s hard to come by well-informed people about this subject,
    but you sound like you know what you?re talking about!
    Thanks

    Check out my web blog ... yacht sales

  3. My brother recommended I may like this web site.

    He used to be entirely right. This submit actually made my day.
    You can not consider simply how so much time I had spent
    for this info! Thanks!

  4. Anyone looking for free dating app? soo many hot girls over here able to meet near the location of you.
    I met many pretty girls here!

  5. slime.work says:

    Here’s a appear at the nine ways to win andd
    how a lot they could be worth...

    Also visit my webb blog: Great post to read (slime.work)

  6. Hi it's me, I am also visiting this website daily, this web page is actually good and the visitors are truly
    sharing pleasant thoughts.

  7. Gilda says:

    Thhe estimated jacopot wass raised Tesday by $35 milion due
    to powerful ticket sales.

    Feel free to surf to my homepage :: Take a loo at the site her (Gilda)

  8. btc all exchanges reserve

    Rhyous » Blog Archive » FreeBSD Wireless – Configuring a wireless interface on FreeBSD 8.1

  9. choangvip apk

    Rhyous » Blog Archive » FreeBSD Wireless – Configuring a wireless interface on FreeBSD 8.1

  10. Tree Company Leesburg VA

    Rhyous » Blog Archive » FreeBSD Wireless – Configuring a wireless interface on FreeBSD 8.1

  11. psycarus says:

    You Sir, are Awesome!
    I had this weird issue with the firmware of Intel 5100 Series WiFi.
    Your procedural guide simply made it work!

    Cheers!

  12. crunchbase.com says:

    crunchbase.com

    FreeBSD Wireless - Configuring a wireless interface on FreeBSD 8.1 | Rhyous

  13. silverlokk says:

    More nice work. I did have trouble with my failover. First off, my WiFi wasn't coming up automatically so I had to drop into a command prompt and ifconfig it up (using wlan0). Next, the wireless wasn't taking over when I unplugged the cable from my Ethernet port. The latter turned out to be a problem with my el-cheapo wireless router, and all I had to do was cycle the power, and things are cool in that regard.

    As to my wireless needing a manual ifconfig to bring it up, I added the 'up' parameter to the ifconfig line for wlan0: ifconfig_wlan0="WPA up".

    I blush to admit that my access point isn't password protected, for one because I can no longer get into the management page -- but that's kinda off-topic :). Would that explain why wlan0 wasn't automatically going up? Was it looking for a WPA-enabled router?

    • Rhyous says:

      I am not sure. In your wpa_supplicant.conf, is your must common wifi connection NOT set to disabled. I was experiencing something similar and I noticed somehow mine was set to disabled so I had to use the Wifi tool to connect at every logon.

      • silverlokk says:

        There you have it, I don't have a wpa_supplicant.conf.

        • Rhyous says:

          Here is my final wpa_supplicant.conf

          ctrl_interface=/var/run/wpa_supplicant
          ctrl_interface_group=wheel
          update_config=1
          
          network={
                  ssid=&quot;PrimarySSID&quot;
                  psk=&quot;Password1&quot;
                  proto=RSN
                  key_mgmt=WPA-PSK
                  pairwise=CCMP
          }
          
          network={
                  ssid=&quot;OtherSSID1&quot;
                  psk=&quot;passwd1&quot;
                  disabled=1
          }
          
          network={
                  ssid=&quot;OtherSSID2&quot;
                  key_mgmt=NONE
                  disabled=1
          }
          

Leave a Reply

How to post code in comments?