Welcome to the new location of Alien's Wiki, sharing a single dokuwiki install with the SlackDocs Wiki.

Welcome to Eric Hameleers (Alien BOB)'s Wiki pages.

If you want to support my work, please consider a small donation:

no way to compare when less than two revisions

Differences

This shows you the differences between two versions of the page.


Next revision
slackware:network [2008/09/09 13:53] – Created. alien
Line 1: Line 1:
 +====== Configuring your network in Slackware ======
 +
 +This article will is intended to be an in-depth look into the way network cards are configured in Slackware. The network scripts themselves are well-documented but there is not much other written documentation apart from the [[http://slackbook.org/html/network-configuration-tcpip.html|Network Configuration]] chapter in the //[[http://slackbook.org/html/|Slackware Linux Essentials]]// book.
 +
 +==== Wireless Network ====
 +
 +If you have a Wireless Access Point that is broadcasting its station ID (the //ESSID//), and is not configured for encrypted traffic, then you're ready to go with the default configuration as it comes with Slackware. This kind of open wireless network is typical when
 +
 +  - you just took your Wireless Access Point out of the box you bought it in, and didn't have time yet to configure it;
 +  - you are at an airport/hotel/pub where they offer free wireless access.
 +
 +If you need to configure specific parameters to make the wireless card talk to your Access Point - for instance, the ''ESSID'' (in case the Access Point is hiding its station ID), or the channel, or a ''WEP'' key, etc) then you will need to edit either the file <code>/etc/rc.d/rc.wireless.conf</code> or the file <code>/etc/rc.d/rc.inet1.conf</code> (one of the two will do) and add a specific configuration that matches your wireless card and Access Point.
 +
 +=== History ===
 +
 +The first release of Slackware to have support for wireless networks was 10.0.0.\\ Wireless support was added after it became possible to use other interface names than just "''eth0''" - the name ''eth0'' was hard-coded in the ''rc.inet1'' script previously. The script ''/etc/rc.d/rc.wireless'' takes care of configuring the wireless parameters for a network interface. This script is being called by the generic network configuration script ''/etc/rc.d/rc.inet1'' for every network interface which is being initialized. The ''rc.wireless'' script will return control to ''rc.inet1'' immediately if it determines that the interface has no wireless capabilities.\\ The ''rc.wireless'' script is not meant to be run on it's own by the user.
 +
 +The first versions of the ''rc.wireless'' script relied on the ''/etc/rc.d-rc.wireless.conf'' file to hold all of your wireless card's configuration. Starting with Slackware 10.2, it was also possible to use ''/etc/rc.d/rc.inet1.conf'' to store wireless parameters. Support for WPA encryption (using wpa_supplicant) was also added, although it would take until Slackware 11.0 before a //wpa_supplicant// package was actually added to the ///testing// directory. In Slackware 12.0, wpa_supplicant finally became part of the 'N' package series.
 +
 +=== Using rc.wireless.conf or rc.inet1.conf ===
 +
 +Originally, ''rc.wireless.conf'' was the file to store your wireless parameters. When support for wireless parameters was also added to ''rc.inet1.conf'' this was done with a reason.\\ The ''rc.wireless'' and ''rc.wireless.conf'' files were initially based on the //pcmcia// scripts for wireless cards. That means your card's parameters were tied to it's //MAC address// (with the option to use a wildcard in that MAC address to support different brands of cards). This is different from the standard way of configuring a network card in Slackware, where network configuration parameters are tied to the name of the interface. Adding the option to define your wireless configuration parameters in ''rc.inet1.conf'' allows you to keep all your network settings (apart from WPA) in one file: ''rc.inet1.conf''.\\ Let us have a better look at these two files now.
 +
 +  * __rc.wireless.conf__\\ You will notice that the content of ''/etc/rc.d/rc.wireless.conf'' is basically a number of sections that apply to certain (ranges of) wireless network cards. The distinguishing factor is the hardware address (the //MAC address//) of a card. A section for a specific card or range of cards looks like this: <code>
 +  MAC_Address)
 +      INFO="a string that decribes your card type"
 +      PARAMETER1="value1"
 +      PARAMETER2="value2"
 +      [more parameters] .......
 +      ;;
 +</code> The MAC_Address in this example can be a full MAC address (six //HEX// bytes separated by colons, like ''00:12:8E:A0:32:DC'') that matches a single network card, or a wildcard address that matches a whole range of cards, typically all cards from a specific vendor (like ''00:12:8E:A0:*'').\\ If you intend to use ''rc.wireless.conf'' you will probably have to add such a section for your specific card, and this is how to do it:
 +    * If your wireless interface called //wlan0//, run ''ifconfig wlan0'' to get the ''MAC'' address of the card.
 +    * Edit ''/etc/rc.d/rc.wireless.conf'' and comment out this section right in the beginning of the file: <code>
 +  *)
 +      INFO="Any ESSID"
 +      ESSID="any"
 +      ;;
 +</code> so that it will look like this: <code>
 +# *)
 +#     INFO="Any ESSID"
 +#     ESSID="any"
 +#     ;;
 +</code>
 +    * Somewhere further below the lines you just commented out, add a few lines (easiest is to add it to the very bottom of the file for instance, **right above** the ''esac'' line) that will apply to your card, like these: <code>
 +  00:06:25:13:2B:D4)
 +      INFO="D-LINK DWL-G510 revB1"
 +      ESSID="your_ap_essid"
 +      KEY="0100030203"
 +      ;;
 +</code> The first line is your card's MAC address followed by a ')', and the last line must only consist of two semicolons - all by themselves (copy and paste one of the available examples if you're unsure).\\ Your ''MAC'' address, ''ESSID'', ''KEY'' and info comment are obviously going to be different from the values in the above example.
 +
 +For the remainder of this article, we will be using ''/etc/rc.d/rc.inet1.conf'' as the single configuration file for all your network parameters (wired as well as wireless).
 +
 +
 +
 +=== rc.inet1.conf ===
 +
 +Slackware since release 10.2 understands network interfaces whose names do not start with ''eth''. A network card that shows up as **''ath0''** can not be setup with an IP address using the configuration files that are part of pre-Slackware 10.2 releases. We are going to assume here that you are running Slackware 10.2 or newer. For older releases, read [[#network_configuration_the_manual_way_slackware_10.1_and_older|Updating the network scripts and Configuration the manual way]].
 +
 +  * You will need to add or modify a few lines in /etc/rc.d/rc.inet1.conf in order to get a configuration like this: <code>
 +# Config information for ath0 (using dhcp):
 +IFNAME[1]="ath0"
 +IPADDR[1]=""
 +NETMASK[1]=""
 +USE_DHCP[1]="yes"
 +DHCP_HOSTNAME[1]="mywirelessbox"
 +</code> Or like this: <code>
 +# Config information for ath0 (using static IP address):
 +IFNAME[1]="ath0"
 +IPADDR[1]="192.168.3.11"
 +NETMASK[1]="255.255.255.0"
 +USE_DHCP[1]=""
 +DHCP_HOSTNAME[1]=""
 +GATEWAY="192.168.3.1"
 +</code> These are example values of course and you will have to substitute your own.
 +
 +  * NOTE\\ In the above example, where I used the index 1, like in: VARIABLENAME[**1**], you may use whatever index is not used. If you do not have an eth0 interface for instance, you might as well want to use the unused 0 array index. The last configuration example would then look like this: <code>
 +# Config information for ath0 (using static IP address):
 +IFNAME[0]="ath0"
 +IPADDR[0]="192.168.3.11"
 +NETMASK[0]="255.255.255.0"
 +USE_DHCP[0]=""
 +DHCP_HOSTNAME[0]=""
 +GATEWAY="192.168.3.1"
 +</code> Obviously, any array index value ([0],[1],[2], ) in /etc/rc.d/rc.inet1.conf should be used for exactly one card's configuration. If you copy a set of lines, be sure to change the array index to an unused value. If you forget this, and create a double entry, then Slackware will happily forget about the first, and will use only the last value for any parameter found in the file.
 +
 +  * NOTE\\ Any configuration setting that is available in //rc.wireless.conf// can also be configured in //rc.inet1.conf// by prefixing the parameter with "//WLAN_//". For instance, suppose you want to configure [[#support_for_wpa_encryption|WPA]]. You could add the following to your card's section in //rc.wireless.conf//
 +<code>
 +WPA="wpa_supplicant"
 +WPADRIVER="wext"
 +</code> but this is how you could do it in //rc.inet1.conf// as well: <code>
 +IFNAME[1]="ath0"
 +   ...
 +WLAN_WPA[1]="wpa_supplicant"
 +WLAN_WPADRIVER[1]="wext"
 +</code> You can configure your card in either one, or both of the configuration files, but the settings in //rc.inet1.conf// will always have priority. It depends on your own taste which of the two configuration files you want to put your configuration in, but if I may make a suggestion: don't use ''rc.wireless.conf'' and group all of the network configuration (wireless as well as non-wireless) for an interface nicely together in ''rc.inet1.conf''.
 + 
 +
 +=== (Re) starting the network interface ===
 +
 +If you're using Slackware 10.2 or newer, or in case you run an older release but updated your network scripts, you can start your ath0 interface like this:
 +<code>
 +/etc/rc.d/rc.inet1 ath0_start
 +</code>
 +or restart it like this (after making changes to the above configuration files for instance):
 +<code>
 +/etc/rc.d/rc.inet1 ath0_restart
 +</code>
 +Earlier versions of Slackware will (re-)start all configured interfaces at once, because all you can run is
 +<code>
 +/etc/rc.d/rc.inet1
 +</code>
 +
 +
 +=== Updating the network scripts (Slackware 10.1 and older) ===
 +
 +The network scripts of Slackware 10.2 or later can be used in older releases of Slackware as well. You will need /etc/rc.d/rc.wireless* and /etc/rc.d/rc.inet1* \\ If you have difficulties extracting these files from a Slackware CD or Internet server, you can find them [[http://www.slackware.com/~alien/rc_scripts/|here too]].
 +
 +
 +=== Network configuration the manual way (Slackware 10.1 and older) ===
 +
 +These are the relatively easy ways to get slackware to bring up your interface:
 +
 +  - Run ''/etc/rc.d/rc.wireless'' to configure the wireless parameters for your card.
 +  - Run ''dhcpcd ath0'' which should be enough to get you up and running;
 +  - It depends on your local network and your settings if you want ''ifconfig'' (instead of ''dhcpcd'') and possibly additional ''iwconfig'' commands.
 +  - Put a ''dhcpcd ath0'' or ''ifconfig ath0'' statement at the bottom of ''/etc/rc.d/rc.local''
 +  - If you're using hotplug, you can have it automatically bring up the interface by editing ''/etc/hotplug/net.agent'' and inserting the following lines in the case add|register) branch: <code>
 +     ath*)
 +       dhcpcd -n $INTERFACE % If you use dhcp for the interface
 +       % or if you prefer to just hardcode your interface, put your ifconfig statement here.
 +       % ifconfig $INTERFACE 192.168.1.1 netmask 255.255.255.0 ...
 +       ;;
 +</code> In the //remove|unregister// branch it will automatically bring down dhcpcd if running.
 +
 +
 +==== Support for WPA encryption ====
 +
 +I am assuming that you already have your madwifi-powered card up and running. Do not try to add WPA support if you do not yet have a functional wireless network connection! Also, if you run Slackware older than 10.2 you will need the updated network scripts that are mentioned in the previous section [[#updating_the_network_scripts_slackware_10.1_and_older|Updating the network scripts (Slackware 10.1 and older)]].
 +
 +The madwifi package obtained [[http://www.slackware.com/~alien/slackbuilds/madwifi/pkg/|here]] works well with the wpa_supplicant package found in Slackware 12.0. Starting with the linux kernel 2.6.14, madwifi and wpa_supplicant can communicate using wpa_supplicant's "''wext''" driver using the kernel's "wireless extensions". For older kernel versions, you will need wpa_supplicant's "''madwifi''" driver for which you need the wpa_supplicant package found [[http://www.slackware.com/~alien/slackbuilds/wpa_supplicant/pkg/|here]].
 +
 +If you want to compile your own wpa_supplicant package, you might find some useful information in the [[http://madwifi.org/wiki/UserDocs/802.11i|Setting up a Client Using WPA-PSK]] Wiki page.
 +
 +>> Note:
 +>> Recent wpa_supplicant should have support for roaming open networks as well
 +>> as for wpa-protected networks. This makes the [[http://0pointer.de/lennart/projects/waproamd/|waproamd]] 
 +>> program obsolete for instance.
 +
 +>> Note:
 +>> When you want to re-build wpa_supplicant and run a Linux kernel older than 2.6.14,
 +>> make sure you have installed the madwifi package on your system as well.
 +>> The wpa_supplicant build needs the include files which the madwifi package installs.
 +>> If you want to use the SlackBuild scripts for madwifi and wpa_supplicant
 +>> which you can find [[http://www.slackware.com/~alien/slackbuilds/|here]] to rebuild the packages for your system,
 +>> build them in that specific order (first build and install madwifi,
 +>> then build and install wpa_supplicant).
 +>> The madwifi include files will be detected by the wpa_supplicant build script and madwifi support enabled.
 +
 +  * To enable WPA support for your madwifi driver, install the wpa_supplicant package (it is not depending on any kernel version) and then open the file ''/etc/wpa_supplicant.conf'' in an editor. It should look something like this: <code>
 +  ctrl_interface=/var/run/wpa_supplicant
 +  ctrl_interface_group=0
 +  eapol_version=1
 +  ap_scan=1
 +  fast_reauth=1
 +  
 +  network={
 +        scan_ssid=0
 +        ssid="your_essid"
 +        proto=WPA
 +        key_mgmt=WPA-PSK
 +        pairwise=CCMP TKIP
 +        group=CCMP TKIP WEP104 WEP40
 +        psk=your_64_hex_characters_long_key
 +  }
 +</code> but you'll need to supply your own values for the //ssid// and the //psk//.
 +
 +  * There is a way to generate the hexadecimal value for the PSK if you have an access point which uses a passphrase. As root, run: <code>
 +wpa_passphrase YOURSSID passphrase
 +</code> with the SSID of your AP and the passphrase youve entered in its WPA-PSK configuration. You'll receive an output, which looks like this: <code>
 +network={
 +    ssid="YOURSSID"
 +    #psk="passphrase"
 +    psk=04dffae0172e3a255e5bab6f28ab78cc23d845f3dd8d4a63ba64a37555e2a33b
 +}
 +</code> Next, you should copy the three lines that you find inside the ''network={}'' section of the command's output and paste them inside the ''network={}'' section of the file ''/etc/wpa_supplicant.conf''. Do not forget to check the permissions of the configuration file! The key that it contains should be protected from prying eyes. <code>
 +chmod 600 /etc/wpa_supplicant.conf
 +</code>
 +
 +  * You will also need to apply the following patch to ''/etc/hotplug/net.agent'' if you're not yet running Slackware 10.2 or newer. The patch makes the network initialization cleaner if you have more than one network interface, and wpa_supplicant needs that. <code>
 +--- net.agent.org       2005-04-17 00:48:48.000000000 +0200
 ++++ net.agent   2005-04-17 00:41:56.000000000 +0200
 +@@ -67,7 +67,7 @@
 +                 # Interface already up?  If so, skip.
 +                 if ! /sbin/ifconfig | grep "^${INTERFACE} " 1> /dev/null ; then
 +                     debug_mesg run rc.inet1
 +-                    exec /etc/rc.d/rc.inet1
 ++                    exec /etc/rc.d/rc.inet1 ${INTERFACE}_start
 +                 fi
 +            # RedHat and similar
 +</code>
 +  * Finally, you'll need to upgrade your wireless-tools to at least wireless-tools-27 (if you run anything older than Slackware 10.2). There is a package for wireless-tools [[http://www.slackware.com/~alien/slackbuilds/wireless-tools/pkg/ |here]] in case you need a more advanced version.
 +
 +  * Now, if your network configuration in ''rc.inet1.conf'' looked like this at first: <code>
 +  # Config information for ath0 (using dhcp):
 +  IFNAME[1]="ath0"
 +  IPADDR[1]=""
 +  NETMASK[1]=""
 +  USE_DHCP[1]="yes"
 +  DHCP_HOSTNAME[1]="mywirelessbox"
 +</code> then you'd have to add two lines so that it will read: <code>
 +  # Config information for ath0 (using dhcp):
 +  IFNAME[1]="ath0"
 +  IPADDR[1]=""
 +  NETMASK[1]=""
 +  USE_DHCP[1]="yes"
 +  DHCP_HOSTNAME[1]="mywirelessbox"
 +  WLAN_WPA[1]="wpa_supplicant"
 +  WLAN_WPADRIVER[1]="wext"
 +</code> Adapt this to your own configuration of course. With kernels older than 2.6.14, the last line should become <code>
 +  WLAN_WPADRIVER[1]="madwifi"
 +</code> and you'll need the version of wpa_supplicant that has support for the madwifi driver (see above).
 +
 +  * You can restart your wireless network card (''ath0'') now, by running <code>
 +/etc/rc.d/rc.inet1 ath0_restart
 +</code> If your WPA connection does not activate, try some debugging:
 +
 +
 +=== WPA debugging ===
 +
 +  * [//If you run a kernel older than 2.6.14 ://] Was wpa_supplicant compiled with support for madwifi?\\ Run the command ''wpa_supplicant'' on the commandline, and verify that the output mentions ''madwifi = MADWIFI 802.11 support (Atheros, etc.)'' under ''drivers:''. If not, you will have to find another package which has the support for madwifi compiled in, or build a wpa_supplicant package yourself, and make sure that the build script finds the madwifi source code on your box.
 +
 +  * Debug the WPA authentication process.\\ Make sure the network interface is down (run <code>
 +/etc/rc.d/rc.inet1 ath0_stop
 +</code> to make sure). Start the wpa_supplicant daemon as a foreground process with additional debugging enabled: <code>
 +wpa_supplicant -dw -c/etc/wpa_supplicant.conf -Dwext -iath0
 +</code> Then activate the network interface in another terminal (run <code>
 +/etc/rc.d/rc.inet1 ath0_start)
 +</code> Look at the output of wpa_supplicant in the first terminal, it might give you pointers to look for a solution.
 +
 +  * Get a run-time status overview of the supplicant:\\ As root, run <code>
 +wpa_cli status
 +</code> to see the current status of wpa_supplicant's authentication process.
 +
 +  * Debug Slackwares network intitialization.\\ Change <code>DEBUG_ETH_UP="no"</code> to <code>
 +DEBUG_ETH_UP="yes"
 +</code> in ''/etc/rc.d/rc.inet1.conf'' and look for //logger// messages that are written to ''/var/log/messages''. Maybe those messages will help you trace your problem.\\ NOTE: with debugging enabled, Slackware will write your WEP/WPA keys to the message log as well, in clear text!
 +
 +  * The WPA association might take a long time.\\ Start the interface again after a little time, this may help if it takes wpa_supplicant a long time to associate (no //restart//, just a //start//): <code>
 +/etc/rc.d/rc.inet1 ath0_start
 +</code> If this makes your wirelesss work, but the problem occurs often, you can change the 'wait' time for the WPA authentication process by editing the file ''/etc/rc.d/rc.inet1.conf'' and adding the line <code>
 +WLAN_WPAWAIT[?]=30
 +</code> or any other larger value that helps your particular setup.\\ __NOTE__: in the last line make sure that you replace the questionmark in **[?]** with the array value that matches your wireless card configuration In the [[#rc.inet1.conf|above example]] this array index would be [**1**].
 +
 +  * The Access Point is not broadcasting the SSID.\\ I have tried and failed in getting WPA to work when the Access Point has a //hidden SSID//. Check if your AP is broadcasting the SSID and if not, enable it. There is little point in hiding the SSID anyway, with WPA as a protection layer you should not fear break-ins (as long as you do not use easy-to-guess passphrases!!! WPA can be cracked with dictionary attacks and no I will not supply a link here).
 +
 +
  
 Configuring your network in Slackware ()
SlackDocs