Archive for the ‘BSD’ Category.

Asp.Net web services on FreeBSD and Apache using Mono

Asp.Net is cross platform using mono. Novell SUSE and Microsoft and others companies are dedicated to making .NET Framework a cross platform solution. Asp.Net web services are limited to running on windows, but can also run on other platforms, such as FreeBSD.

FreeBSD has ports for mono and mod_mono and can easily run web services build with Asp.Net. Here is a tutorial to make this happen.

Preparing a FreeBSD system for Asp.Net on Apache using Mono

Information

A good place to start reading is the getting started page on the mono project’s web site.:
http://mono-project.com/Start

This has the resources you need for most things, however, the documentation is designed mostly for SUSE Linux, so be prepared for slight differences on FreeBSD.

Step 1 – Install Apache

Install Apache on FreeBSD as follows.

  1. Change to the ports directory for Apache and run make install.
    #
    #
    cd /usr/ports/www/apache22
    make install
  2. Configure Apache to load on start up.
    # echo ‘apache22_enable=”YES”‘ >> /etc/rc.conf
  3. Leave Apache stopped. We will start it later.

Step 2 – Install mod_mono

Installing mod_mono will also install mono and xsp. Install mod_mono as follows.

  1. Change to the ports directory for Apache and run make install.
    #
    #
    cd /usr/ports/mod_mono
    make install
  2. Because on FreeBSD these packages work a little differently, you don’t need to do some of the steps listed on the mono website because they are done for you. Here are some key paths and differences in the packages on FreeBSD that you should know about.
    • The mod_mono port installs a mod_mono.conf file to /usr/local/etc/apache22/Includes which is automatically includes in the httpd.conf, so you don’t have to add an include manually.
    • The xsp port adds sample ASP.NET web services to /usr/local/lib/xsp.
    • The apache root directory is /usr/local/www/apache22/data
  3. Here are the contents of the mod_mono.conf file. Notice that this Apache include file loads a couple modules, adds a bunch of types, and adds a few files as DirectoryIndex options.
    # mod_mono.conf
    
    # Achtung! This file may be overwritten
    # Use 'include mod_mono.conf' from other configuration file
    # to load mod_mono module.
    
    <IfModule !mod_mono.c>
        LoadModule mono_module /usr/local/libexec/apache22/mod_mono.so
    </IfModule>
    
    <IfModule mod_headers.c>
        Header set X-Powered-By "Mono"
    </IfModule>
    
    AddType application/x-asp-net .aspx
    AddType application/x-asp-net .asmx
    AddType application/x-asp-net .ashx
    AddType application/x-asp-net .asax
    AddType application/x-asp-net .ascx
    AddType application/x-asp-net .soap
    AddType application/x-asp-net .rem
    AddType application/x-asp-net .axd
    AddType application/x-asp-net .cs
    AddType application/x-asp-net .vb
    AddType application/x-asp-net .master
    AddType application/x-asp-net .sitemap
    AddType application/x-asp-net .resources
    AddType application/x-asp-net .skin
    AddType application/x-asp-net .browser
    AddType application/x-asp-net .webinfo
    AddType application/x-asp-net .resx
    AddType application/x-asp-net .licx
    AddType application/x-asp-net .csproj
    AddType application/x-asp-net .vbproj
    AddType application/x-asp-net .config
    AddType application/x-asp-net .Config
    AddType application/x-asp-net .dll
    DirectoryIndex index.aspx
    DirectoryIndex Default.aspx
    DirectoryIndex default.aspx
    

Step 3 – Add the “test” web service to the Apache root directory

In /usr/local/lib/xsp, added by the mod_mono port, is a “test” folder that contains sample web services. Ther

  1. Copy /usr/local/lib/xsp/test to /usr/local/www/apache22/data.
    # cp -fR /usr/local/lib/xsp/test /usr/local/www/apache22/data/

Step 4 – Start Apache

  1. Start Apache with this command:
    # service apache22 start

You should now have Apache configured to run Asp.net.

Step 5 – Open the “test” folder in a browser

  1. Open your favorite browser on a workstation that has access to the server you just finished installing.
  2. Go to the URL of your server. For example, the url for my test server is this:
    http://192.168.0.43/test
  3. Browse around and test the web services.

Step 6 – Install Libraries as needed

    1. Determine if you need additional libraries.

With the bare minimum installed, you can almost guarantee that a web service is going to require a library you do not have installed. In fact, clicking on the second link in the “test” site, code-render.aspx, shows us this error.

Server Error in '/test' Application

gdiplus.dll

Description: HTTP 500. Error processing request.

Stack Trace:

System.DllNotFoundException: gdiplus.dll
  at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
  at System.Drawing.GDIPlus..cctor () [0x00000] in <filename unknown>:0

Version information: Mono Runtime Version: 2.6.7 (tarball Tue Mar 1 06:10:28 MST 2011); ASP.NET Version: 2.0.50727.1433

This library can be found and installed.

  1. Go to the directory for the port and run make install.
    #
    #
    cd /usr/ports/x11-toolkits/libgdiplus
    make BATCH=yes install

    This has some Xorg dependencies so compiling it could take a while. Notice the BATCH=yes parameter passed to make above. This will prevent any prompts and accept the defaults for every port this command compiles.

Released: FreeBSD 8.2-RELEASE and 7.4-RELEASE

BSD Licenses good, GPL bad: Microsoft Bans Some Open Source Licenses from WP7 Marketplace

Microsoft is not going to allow GPL onto their phones.
Microsoft Bans Some Open Source Licenses from WP7 Marketplace

Microsoft has stated that its Windows Phone 7 marketplace will reject any apps that use the GPL (GNU General Public License) and similar licenses.

“The Windows Phone Marketplace supports several open source licenses, including BSD, MIT, Apache Software License 2.0, MS-PL and other similar permissive licenses.  We revise our Application Provider Agreement from time to time based on customer and developer feedback, and we are exploring the possibility of modifying it to accommodate additional open source-based applications in upcoming revisions.”

Microsoft is doing the right thing and cannot be blamed in the slightest. The GPL is often termed a viral license and for good reason. Once you use it in your code everything is infected by it. Others say it is a spiderweb license, that once you are in the spider’s web, you can’t get out. The BSD license instead of the GPL is probably the single biggest reason to use FreeBSD over Linux, especially for enterprise business such as Microsoft, Apple, and others.

I don’t like the entrapment of the GPL. Students often first encounter the GPL in college, where they hear that the GPL is free and start using it. Only later do they realize they are trapped. Some don’t mind, wish they would have understood the license better.

Here is a simple rhyme to remember which license to use:

If you want your software to really be free,
    license it with BSD.
If you want your software to be in license hell,
    use the GPL.

This post shows that Microsoft feels the same as many of us who are anti-GPL.

Obviously they don’t want to have those who write their apps ever accidental depend on another app, only to find out the app they depended on is GPL, so their entire work must be GPL as well. They are doing what humanity tries to do with any virus, eradicating it and prevent infection by eliminating the virus, just as we have done with small pox, from the world.

For more information on the differences between the BSD License and the GPL, read this post.
Differences between the BSD/FreeBSD Copyrights and the GNU Public License (GPL)

Backing up PostgreSQL databases nightly on FreeBSD

I didn’t write this post, a blogger named Keith did, but I am definitely going to link to his work on his blog.

Backing up PostgreSQL databases nightly on FreeBSD

He did a good job editing this script to backup postgresql on FreeBSD. While he does say he got some of it from another site he found on using Google…

…Using Google I found a generic script, after some custom tweaks for FreeBSD I had the script I wanted.

…so some of the work should be attributed elsewhere. I want to thank him for the work he did. This was something that was on my to do list and now it is pretty much done for me.

Here is the script he posted.

#!/bin/sh
# Location of binaries
bin="/usr/local/bin"
# Location of the backup logfile.
logfile="/data/backup/postgres/postgres.log"
# Location to place backups.
backup_dir="/data/backup/postgres"
username="pgsql"
database="template1"
touch $logfile
timeslot=`date +%H-%M`
databases=`$bin/psql -h localhost -d $database -U $username -q -c "\l" | sed -n 4,/\eof/p | grep -v rows\) | awk {'print $1'}`

for i in $databases; do
        echo "Backup and Vacuum complete at $timeinfo for time slot $timeslot on database: $i " >> $logfile
        $bin/vacuumdb -z -h localhost -U $username $i >/dev/null 2>&1
        j="60"
        while [ $j -ge 0 ]
        do
                temp0=`expr $j - 1`
                temp1=$j
                j=`expr $j - 1`
                if [ $temp0 -lt 0 ]
                then
                        suffix0=""
                        suffix1=".0"
                else
                        suffix0=".$temp0"
                        suffix1=".$temp1"
                fi
                if [ -f $backup_dir/postgresql-$i-database.gz$suffix0 ]
                then
                        echo "Renaming postgresql-$i-database.gz$suffix0 to postgresql-$i-database.gz$suffix1"
                        mv $backup_dir/postgresql-$i-database.gz$suffix0 $backup_dir/postgresql-$i-database.gz$suffix1
                fi
        done
        if [ $i != 'template0' ]
        then
                $bin/pg_dump -U $username $i -h 127.0.0.1 | gzip > "$backup_dir/postgresql-$i-database.gz"
        fi
done

Here is what I like about his script:

  1. Variables are used at the top of the script that are easily modifiable.
  2. It backs up all databases without having to list the databases, so you don’t have to update the list with every new database.
  3. It does compress using gzip the databases, so uses as little space as possible.

Here are some ideas for future enhancements to the script

  1. The gzip compression level as a variable up top. The default gzip compression level is 6 and 9 could make the file significantly smaller with large databases, while 1 would be faster for machines with weaker processors.
  2. Database to exclude from the backup.  I like the idea to get them all by default, but sometimes you have a test database you just don’t care about and you don’t want a nightly backup of it.
  3. I don’t see the password in the script, and I am not sure how it is authenticating without it, maybe a password feature needs to be added.

BSD Magazine February Issue is out: ZFS and FreeBSD

BSD Magazine February Issue released.

Download it here:

http://bsdmag.org/magazine/1638-zfs-and-freebsd

Review: GhostBSD 2.0 Beta 2 – A FreeBSD LiveCD

GhostBSD 2.0 – Beta 2 Review

Today I downloaded GhostBSD 2.0.  GhostBSD 2.0 is a live CD that you boot off and your operating system loads to a desktop environment from the CD itself.

It is a CD not a DVD. It was 645.3 MB.  That fits one a single CD.  So it is still small and downloaded rather quickly compared to multi-gigabyte DVD images.

The Good

It didn’t take long to find some good features.

  1. VMWare resolution wasn’t too bad 1280×720.
  2. Decent backgrounds
  3. Thunderbird setup to take your account immediately and the autodetect is cool.
  4. Firefox worked first time.
  5. Has AbiWord and Gnumeric Spreadshet installed.
  6. Has burning software
  7. As a CD ISO, it is still small and downloaded rather quickly compared to multi-gigabyte DVD images.

What Needs works

The first thing that needs work is this review.  I didn’t test much.  I booted, and looked at features, but as I only use a Live CD when something goes terribly wrong and nothing has, I didn’t really do anything too geeky.  So let me just say there is much more to review.  But here are some things I noticed in just my short time clicking away at this.

There wasn’t much bad to speak of that was bad. I had to get nit picky.

  1. There was a problem that delays boot related to the hostname.
  2. No Flash 10 in Firefox, though the linux kernel was there.
  3. Thunderbird is not configured to open links with Firefox by default.
  4. pkg_info shows the pages but says that the package info is corrupt for every package installed.

Other FreeBSD Live CDs

  • Frenzy – A much smaller CD. Here is a quote from the home page: Frenzy is a “portable system administrator toolkit,” LiveCD based on FreeBSD. It generally contains software for hardware tests, file system check, security check and network setup and analysis. Size of ISO-image is 200 MBytes (3″ CD)
  • FreeSBIE – No longer maintained

I didn’t install Frenzy and I have never used it, so I cannot compare it.  However, it is supposedly only 200 MB, which leaves me wondering what it has.

FreeSBIE has been useful in the past, but is no longer maintained.

The Conclusion

GhostBSD 2.0 is the FreeBSD live CD that I currently recommend. I first came across it when it was 1.5, and 2.0 shows it moving forward quite nicely.

Hopes for the future

I do believe there is a place for them to hook into pc-sysinstall and create an installer.  There is not a GNOME-based FreeBSD distribution that I know about, though PC-BSD might add GNOME as an option, but many of the GNOME users would probably jump on this if an installer was built. They may even convert me from KDE to GNOME.

FreeBSD News: What version of FreeBSD are you using (Poll)?

Over at FreeBSD News, they have a survey asking what version of FreeBSD you are using.

Take a moment and hit this link and enter your FreeBSD version.

What version of FreeBSD are you using (Poll)?

Debian one step closer to making the kernel optional

You have heard of options during install, but have you ever thought of swapping out the Kernel? Maybe, for a similar kernel with a different configuration, but what about a completely different kernel, say a Linux or FreeBSD kernel? Well, Debian has thought about this for quite some time, and with their new release of Debian 6, they now have a

Quote on Slashdot: “After two years of work, the Debian Project has announced the release of Debian 6.0. ‘There are many goodies in Debian 6.0 GNU/Linux, not the least of which is the new completely free-as-in-freedom Linux kernel, which no longer contains firmware modules that Debian developers found troublesome,’ says blogger Brian Proffitt. And in addition to Debian GNU/Linux, Debian GNU/kFreeBSD is introduced as a technology preview. ‘Debian GNU/kFreeBSD will port both a 32- and 64-bit PC version of the FreeBSD kernel into the Debian userspace, making them the first Debian release without a Linux kernel,’ says Proffitt. ‘The Debian Project is serious about the technology preview label, though: these FreeBSD-based versions will have limited advanced desktop features.’ The release notes and installation manual have been posted, and installation images may be downloaded right now via bittorrent, jigdo, or HTTP.”

Since FreeBSD is my platform of choice, this idea sounds pretty good to me.

This isn’t hte first time I have commented on this Debian GNU/kFreeBSD release. However, it is in the new again and it is interesting to say the least.

Getting the Microphone to work in FreeBSD on a Lenovo T61p

Hey all,

I am trying to get my Microphone to work on my Lenovo T61p.

Problem

If I talk into my microphone while capturing sound, when I play back, I cannot hear my voice.

Troubleshooting

Let me answer some questions for you:

Does the sound work?
Yes. The sound card works great.

Does the hardware work?
The Microphone works well if I boot to windows 7. I have a hard drive with Windows 7 that used to be in this laptop.

What tools am I using to capture sound?
audacity
xvidcap

Can I get any sound to record?
Yes. If I tap hard with my finger on the microphone, the taps are caught, though faint, by both audacity and xvidcap.

What have I done?

Read the Handbook.
Read the man pages for mixer and snd_hda

  1. Loaded and unloaded snd_hda.ko and sound.ko
  2. Changed every mixer setting there is.
  3. Tested tapping and yelling into the mic, tapping barely registers.
  4. Test hardware on Windows 7, works.
  5. Checked systctl -a |grep snd and sysctl -a |grep hda
  6. Changed the mixer to use monitor instead of mic.

Resolution

Well, it was the last step. Once I changed the mixer to use monitor instead of mic, it worked like a charm.

mixer -rec monitor

mixer monitor 35:35

Installing and testing PC-BSD 8.2 RC2

I am installing PC-BSD 8.2 RC2.

I really love that I can just choose ZFS as the file system and I don’t have to really make a huge effort to get it to work.

I found polish issues, but nothing serious yet.

Take a moment to install and share your experience here:

http://forums.pcbsd.org/showthread.php?p=85374&posted=1#post85374

VirtualBox on FreeBSD – Don’t use lagg0 and don’t use NAT

So my networking on my host has been extremely slow and choppy on my VM guests. I read somewhere to not use NAT but when I tried to turn off NAT, I could never get and IP address. Turns out that was the fault of lagg.

I have disabled lagg and configured my VMs to use bridging mode and suddenly my host is extremely fast.

Also, when I accidently configured my VM to use iwn0 instead of wlan0, the system hung, followed by a reboot.

So lets sum up the three tips for using VirtualBox on FreeBSD:

  1. Don’t use lagg on the host.
  2. Don’t use NAT.
  3. Don’t configure the guest to use your wireless device using iwn0, but make sure to use wlan0.

Russian Government going Open Source…and the future

Well, I have seen governments claim they are going to open source before, but not from Russia, and not with such a realistic plan to migrate over a few years.

Here is a link to the article via Google translate:

Putin ordered the transfer of power on Linux

The now

Business drives software development.  Open Source communities help, but even today much of the ongoing development for Linux is driven by businesses such as Red Hat and Novell and others.  If you think your Linux code is being written by unpaid developers in their spare time, you are somewhat correct but only partially.  Most changes are made by developers who are paid.

While communities are nice, they can’t match the hours or output of experienced developers working forty to sixty hours a week.

Looking Ahead…the Apps…and C# (Mono)

The more open source is used in business, the more development power it will have.  But it is not the open source Operatings Systems that prevent people from moving to Linux or BSD.  Ubuntu, SUSE, Fedora, CentOS, PC-BSD, and numerous others are all very usable desktops that are user friendly.  It is the software that runs on them that everyone is waiting for.

The market is already there to make millions extra if you application runs cross platform, one Windows, MAC, Linux, and BSD.

But most the applications written for Windows, the business desktop of today, are using .NET Framework. So naturally those companies are going to want to make their code cross platform.  And they are going to find it is easier than they thought to move their applications between platforms using C#.  I have recently decided that C# is the future of applications on all platforms.

Some MAC and Linux users don’t like Microsoft and will fight off the idea of a Microsoft provided development platform such as C# (Mono) on their systems.  But when a corporation decides that you must run software X, and software X requires .NET, and you have to either give up your MAC or Linux box for a Windows box, or use C# (Mono), then users will come around.

If you are a company writing software for Windows only today and using C#, you need to take a look at Mono. Even if the return on investment of developing a C# (Mono) based version of your product is a slight loss to break even, it is an investment in the future.  Once written, maintenance costs will be less than the original development costs and that slight loss to break even margin will turn to a small profit.  And with the experience, you next app will migrate to C# (Mono) that much easier and soon, all you apps will run anywhere that C# (Mono) can run.

This is going to take off in a way Java hasn’t because developers for windows prefer and will continue to prefer .NET over Java.  And when it comes to business apps, Java just isn’t the language of choice.  Business applications are written in C#.

How to tranfer a TiVo recording and watch it on FreeBSD?

I broke my TiVo remote to my TiVo series II.

I wanted to watch a TiVo recording on my laptop…running FreeBSD. I had never done this, so I wasn’t sure if it was going to happen.

Gratefully, I succeeded. Here is what I had to do.

Step 1 – Find my media access key.

You can find this on your TiVo, but since I didn’t have a remote, I couldn’t look on my TiVo.  So I went to http://www.Tivo.com, logged in, and sure enough under My Account, there was a link to see my Media Access Key.

Step 2 – Download a video recording from your Tivo

  1. Connect to you Tivo using your favorite web browser using https.
    Note: I wasn’t sure of my Tivo’s IP Address so I had to connect to my Wireless router and look at its DHCP leases.
  2. Login using these credentials:
    User: tivo
    Password: [your media access key]Once in, you will see a list of recordings in a table and you can download them as you desire.
  3. Download your recording.  Your recordings are .tivo files.

Step 3 – Install tivodecode

When I tried to play the .TiVo file with mplayer, it failed. So I looked at how to convert it.

Turns out there is a port called tivodecode.  Install it as follows.

# cd /usr/ports/multimedia/tivodecode
# make install

Step 4 – Decode the .TiVo file

Run the following command to decode your .TiVo file.

tivodecode “Some Video.TiVo” -o “Some Video.mpg”

And now you can play decoded video in mplayer.

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.

FreeBSD or Linux

Ok, so if you have been on my site, you know that I started with Red Hat and never really got into it, and then, settles on FreeBSD.  Why would I choose FreeBSD over Linux? It fit me better.

I actually think that everybody needs to use what suits them.

This is NOT a FreeBSD versus Linux post.  It is a site to help others who are trying to decide whether to use FreeBSD or Linux see some pros and cons and get my recommendation.

FreeBSD

FreeBSD is not Linux or Unix exactly.  It is BSD. It has its own bsd kernel and an is surrounded by a base system.

Here are a list of positives about FreeBSD

  • It is open to proprietary code that just can’t be used in Linux, such as Sun’s ZFS.
  • It is easy to get a small install of just the base system with minimal to no features installed. (Security! Attach surface area is minimized when less software is included.)
  • Jails
  • The ports tree for compiling from source is unmatched by any Linux operating system, but if you prefer binaries, yes, it has them too.
  • Installing software has less problems as you compile it on the system, with the settings you need (rather than get binaries that may have been compiled for a different system or without the settings you need).
  • The documentation is far better than most other open source projects and better than most projects commercial or open source for that matter!
  • OS X chose to use much of FreeBSD in its underlying operating system and so when combining the OS X and FreeBSD market share, FreeBSD code is actually used on more systems than any operating system other than Windows.
  • There are not that many BSD distributions, and the ones that exist have clear focusses different than the others, that later they share.  FreeBSD is a solid server. PC-BSD is a desktop focussed on avoiding dependency problems with its software. OpenBSD is extremely securee. NetBSD is extremely compatible with lots of hardware.  They contribute back to each other often.
  • The License is free and gives everyone who uses it true freedom.
  • The License is free for commercial use.
  • Easy Editor. Newbies can actually use this editor included in the FreeBSD base system.  Don’t forget to learn vi though.
  • Patching is as simple as running freebsd-update.

Here are a list of negatives about FreeBSD

  • Hardware companies tend to make drivers for Windows and Linux first and often don’t include FreeBSD, though most hardware is soon supported.
  • There is not a native Flash Player in FreeBSD, instead the Linux version of Flash must be used.
  • There Desktop options for FreeBSD are not as rich as those for Linux (Example: KDE network settings doesn’t work on FreeBSD, but PC-BSD has their own settings now.)
  • IT/Developers forFreeBSD are harder to come by.

Linux

Linux was originally just a kernel.  The userland was separate.  Now there are plenty of projects that make a nice complete operating system using the Linux kernel and a nice base system surrounding it.

Here are a list of positives about Linux

  • It has a large user base.
  • Free to use.
  • There are plenty of distros to choose from.
  • It is no longer just a kernel but many different groups put out an actual system: Red Hat/Fedora, Debian/Ubuntu, CentOS, SUSE, Arch, Gentoo, etc…
  • A lot of work is going into the desktop environment
  • Development for any Linux platform could benefit all Linux platforms.
  • More and more hardware companies are including Linux drivers
  • Some Software companies make Linux software as well, and the number is increasing
  • Strong commercial backing (which doesn’t make sense for software licensed under the GPL)

Here are some negatives

  • There is often a lot of binary packages that just don’t work.
  • Lack of consolidation.  There are a lot of distributions of Linux and they are not the same. Which one do you choose.
  • Many Linuxes (not all) are now installing desktop software by default, and no longer are minimalistic. (Security! Attach surface area is increased when more software is included.)
  • The inability to write and distribute software that touches GPL software, without having to release your software as GPL too.
  • If you hope to do anything other than use the software or help the community, you need a lawyer to figure out how to interact with the various versions of GPL.
  • The security settings are usually not easy to use and are result in users just turning them off (i.e. SELinux)
  • Are Red Hat and SUSE open source or commercial, they sell support but the software is free, except you can’t get updates without buying support…confusing!
  • IT guys who claim to know Linux usually have done little more than run Ubuntu for a few days.

This is not a flame post and any responses that appear to be trolls will be deleted.

My recommendations

Ok, so what would I recommend if I were paid by a company for consulting?

Server (LAMP)

For a Server running Apache, PHP, SQL, often mis-termed LAMP (Linux Apache MySQL PHP) but really means any OS, Web Server, SQL, Script language.

Recommended OS: FreeBSD

Commerical Appliance

If you work for a company and you need a commercial appliance. Stay away from the dangers of the GPL, just don’t go there.

Recommended OS: FreeBSD

Open Source Desktop

For a quick desktop for a home user that has PC hardware but doesn’t have a license for Windows and doesn’t want to buy one.

Recommended OS: Ubuntu

Note: Sorry PC-BSD friends. Keep working on it.

Commerical Desktop for Employees

If you want a good commercial desktop, you should go with one of the following depending on certain factors, the primary being that some software you may need to use only runs on these two platforms.

Recommended OS: Windows 7 or OS X

However, Ubuntu, Red Hat, SUSE, Fedora, PC-BSD, are all very usable replacements depending on the situation.

Point of Sale (POS) Device

If you need to have to have a POS device for handling sales.

Recommended OS: Depends on needs

Share your thoughts

Hey, please comment.  No flame wars though.  I repeat, this is not a FreeBSD versus Linux post, but a FreeBSD or Linux post, with just some information from my experience. I appreciate all technology and any rude comments will be deleted.  However, feel free to challenge and provide facts, demand facts, etc…