contact Me

Use the form on the right to contact me.

You are welcome, to contact me regarding the topics of this page, my open source projects, or my work. Please use the contact form and leave a valid email address for me to respond to.

Thank you.

Egidestr. 9
44892 Bochum
Germany

/brain/dump

Random thoughts, bright ideas and interesting experiments. In short the ramblings of a fulltime nerd.

 

Gentoo wireless - My way

Jakob Westhoff

I have just finished a little script, which runs on top of the gentoo net.* initscripts. It gives you the opportunity to configure your wifi device using a folder filled with different small configfiles instead of a complicated big one, which is hard to manage.

You may ask, why should somebody change the gentoo way of initializing the wifi device. The main reason for changing the standard behaviour was my need to execute different programs after establishing connections to different accesspoints. At first I used one postup function combined with a case statement in the monolithic wireless conf to associate a special ap with some commands to be executed after the defined ap has been found.

This solution to the problem seemed quite useful, but as the number of accesspoints started growing it got really hard to keep track of all the different commands and configurations. Because of this I splitted the configfiles. I did not want to reinvent the wheel, therefore I wrote a little wrapper to read the defined values into the gentoo net initscripts instead of doing the whole initializiation on my own.

For using this in your system just do the following:

  1. Create a directory called wireless.d in /etc/conf.d.
  2. Create a configfile for every accesspoint in this directory. The file has to be called exactly like the essid of the accesspoint. You can use every configparameter the gentoo net initscript supports in combination with the essid, eg. config_YOUR_ESSID=( "dhcp" ) could be used. Hence the wrapper gets the essid out of the filename you can omit this part of the variablename.

    Another nice feature is the opportunity to define a postup function in every "configfile". There you could execute any shell command you need. For example you could initialize a vpn client here or establish any connection you always need after the netinit.

    Here is a simple essid configfile:

    key="YOUR WEPKEY HERE"
    config=( "10.0.3.4 netmask 255.255.255.0" )
    routes=( "default via 10.0.3.1" )
    dns_servers=( "10.0.1.1" )
    
    
    postup() {
        ebegin "Running Racoon to initialize the vpn"
        source /etc/conf.d/racoon
        /usr/sbin/setkey -f ${SETKEY_CONF}
        /usr/sbin/racoon -f ${RACOON_CONF} ${RACOON_OPTS}
        eend $?
    }
    

    This is the config I am using for my wifi connection at home. The file is saved as /etc/conf.d/wireless.d/Exiel

    The essid of my accesspoint is, as you have already discovered, "Exiel".

    As you can see it is really easy to use this wifi wrapper.

  3. You have to install the configwrapper script. Just download the script and save it as as /etc/conf.d/net

  4. Change the WIRELESSDEVICE variable to the name of your wifi device and add net.ath0 (or whatever your card is called) to your default bootlevel.

    $ rc-update add net.ath0 default
    

Now you are ready to enjoy your new essid file based wlan configuration.

I am not sure if this script works on every system with every gentoo baselayout. I have tested it on my system, where it works great. If it's not doing what it's supposed to, send me an email or comment on this entry.