# per-ssid network configuration

## heartburn

I'm trying to set up a new netbook to have a static ip address on my home network and default to dhcp everywhere else. I can't get it to work. I'm using baselayout-2. Can anyone see what I'm doing wrong?

```

modules="wpa_supplicant"

wpa_supplicant_wlan0="-Dwext"

wpa_timeout_wlan0=60

preferred_aps="myssid"

config_myssid="192.168.1.55 netmask 255.255.255.0 brd 192.168.1.255"

routes_myssid="default via 192.168.1.1"

#config_wlan0="dhcp"

config_eth0="dhcp"

```

----------

## NeddySeagoon

heartburn,

/etc/wpa_supplicant/wpa_supplicant.conf, allows priority to be assigned to sections.

e.g. I have 

```
# Let wpa_supplicant take care of scanning and AP selection

ap_scan=1

# Simple case: WPA-PSK, PSK as an ASCII passphrase, allow all valid ciphers

network={

  ssid="RadioNet"

  psk="Secret"

  # The higher the priority the sooner we are matched

  priority=50

}

# IBSS/ad-hoc network with WPA-None/TKIP

network={

  ssid="RadioNet"

  mode=1

  proto=WPA

  key_mgmt=WPA-NONE

  pairwise=NONE

  group=TKIP

  psk="Secret"

  priority=0

}

```

So the first entry is used if it can. if not the second entry is used.

You have to get associated (and authenticated) with an AP before you can run dhcp to get an IP.

You will need to use the special 

```
ssid="Any"
```

in your fallback, as you won't know the ssid of the random network you are connecting to.

Now the bit I'm not sure of.

You can have a fallback section in your /etc/conf.d/net file, so if you have a random ssid, your static IP section does not match and the fallback is run.  Its documented in /usr/share/doc/...  somewhere, look for an openrc folder.

You could also cheat on your home network if you run dhcp there at all. Have dhcp assign a fixed IP to your MAC address. That way it would appear to be static.

----------

## heartburn

I added a fallback to my /etc/conf.d/net and an "Any" section to my wpa_suppplicant.conf, but I still get the same result: "No configuration specified, defaulting to DHCP." I'm sure it's reading those two configuration files though because it authenticates, and if I change "config_myssid=" to "config_wlan0=", I get my static ip.

----------

## NeddySeagoon

heartburn,

Does /etc/init.d/net.myssid exist ?

It should be a symlink to /etc/init.d/net.lo

The system will not create it for you, if you want to use non kernel device names you need to make the symlink.

How does your interface called myssid get created ?

----------

## heartburn

No! I never created it. I didn't realize I needed one for an ssid. But, after I created the link, I still got the same result.

I'm not sure how the ssid interface gets created. I was just following the sample in /usr/share/doc/openrc-0.6.1-r1/. I figured it was some kind of magic in the wireless drivers or the init scripts that would take care of it.

----------

## NeddySeagoon

heartburn,

Reading that helpfile, the symlink is not needed.

Does it work without the fallback ?

What symbols do you have in your SSID ?

Not all symbols are legal and some that are legal need to be 'escaped', that is preceded by a \

----------

## heartburn

 *NeddySeagoon wrote:*   

> heartburn,
> 
> Reading that helpfile, the symlink is not needed.
> 
> Does it work without the fallback ?
> ...

 

My ssid is ffsoft. Nothing fancy.

The only way I was able to get it to work was to use "config_wlan0=" instead of "config_myssid=", It doesn't really do what I want, but at least it was working. This is what I have now:

```
modules="wpa_supplicant"

wpa_supplicant_wlan0="-Dwext"

wpa_timeout_wlan0=60

preferred_aps="ffsoft"

config_wlan0="dhcp"

config_eth0="dhcp"
```

```
# The below line not be changed otherwise we refuse to work

ctrl_interface=/var/run/wpa_supplicant

# Ensure that only root can read the WPA configuration

ctrl_interface_group=0

# Let wpa_supplicant take care of scanning and AP selection

ap_scan=1

network={

        ssid="ffsoft"

        proto=WPA

        key_mgmt=WPA-PSK

        pairwise=TKIP

        group=TKIP

        psk=biglongstringgeneratedbywpa_passphrase

        priority=50

}
```

I decided to just go with the simplest thing I could think of and upgrade my ap's firmware so that I can assign static ips.

Meanwhile, I was trying out quickswitch and ifplugd to see if I could get the machine to boot in a reasonable amount of time when it was disconnected from the network. I have no idea what I did, but now, even the configuration above isn't working. I see this in dmesg after I get the "WEP key not set for ffsoft" error.

```
[   16.414093] ------------[ cut here ]------------

[   16.414111] WARNING: at kernel/softirq.c:143 local_bh_enable_ip+0x60/0x90()

[   16.414116] Hardware name: TOSHIBA NB205

[   16.414119] Modules linked in: snd_hda_codec_realtek ath9k ath9k_common snd_hda_intel mac80211 snd_hda_codec ath9k_hw snd_pcm ath snd_timer snd battery r8169 ac cfg80211 mii snd_page_alloc led_class thermal processor

[   16.414154] Pid: 2084, comm: iwconfig Not tainted 2.6.33-gentoo-r1 #9

[   16.414159] Call Trace:

[   16.414168]  [<c103269e>] ? warn_slowpath_common+0x6e/0xb0

[   16.414175]  [<c1037ba0>] ? local_bh_enable_ip+0x60/0x90

[   16.414182]  [<c10326f3>] ? warn_slowpath_null+0x13/0x20

[   16.414189]  [<c1037ba0>] ? local_bh_enable_ip+0x60/0x90

[   16.414200]  [<f88baca5>] ? ath_tx_node_cleanup+0x155/0x170 [ath9k]

[   16.414214]  [<f88648a0>] ? add_todo+0x60/0x90 [mac80211]

[   16.414222]  [<f88b62d0>] ? ath9k_sta_notify+0x0/0xa0 [ath9k]

[   16.414232]  [<f8851832>] ? __sta_info_unlink+0x132/0x1a0 [mac80211]

[   16.414243]  [<f88518cb>] ? sta_info_unlink+0x2b/0x50 [mac80211]

[   16.414254]  [<f8857594>] ? ieee80211_set_disassoc+0x184/0x200 [mac80211]

[   16.414266]  [<f8857dbd>] ? ieee80211_mgd_deauth+0x12d/0x140 [mac80211]

[   16.414281]  [<f83f0cad>] ? __cfg80211_mlme_deauth+0xed/0x120 [cfg80211]

[   16.414289]  [<c10b08ba>] ? __d_lookup+0x10a/0x120

[   16.414301]  [<f83f445b>] ? __cfg80211_disconnect+0x14b/0x1b0 [cfg80211]

[   16.414308]  [<c10af334>] ? dput+0x84/0x120

[   16.414321]  [<f83f6eef>] ? cfg80211_mgd_wext_siwap+0x11f/0x240 [cfg80211]

[   16.414333]  [<c136c0ac>] ? ioctl_standard_call+0x5c/0x360

[   16.414342]  [<c12f6315>] ? dev_get_by_name_rcu+0x75/0x90

[   16.414342]  [<c12f63e5>] ? __dev_get_by_name+0x75/0x90

[   16.414342]  [<c136c5be>] ? wext_handle_ioctl+0x20e/0x230

[   16.414342]  [<f83f55a0>] ? cfg80211_wext_siwap+0x0/0x100 [cfg80211]

[   16.414342]  [<c12fa961>] ? dev_ioctl+0x561/0x6d0

[   16.414342]  [<c106fa06>] ? filemap_fault+0x86/0x3d0

[   16.414342]  [<c12e8920>] ? sock_ioctl+0x0/0x260

[   16.414342]  [<c10abf1b>] ? vfs_ioctl+0x2b/0xa0

[   16.414342]  [<c10ac0f9>] ? do_vfs_ioctl+0x79/0x5c0

[   16.414342]  [<c1084614>] ? handle_mm_fault+0x134/0x860

[   16.414342]  [<c12eacf0>] ? sys_socket+0x60/0x80

[   16.414342]  [<c101ec89>] ? do_page_fault+0xf9/0x300

[   16.414342]  [<c10ac67d>] ? sys_ioctl+0x3d/0x70

[   16.414342]  [<c1002c90>] ? sysenter_do_call+0x12/0x26

[   16.414342] ---[ end trace 03b55580343ba795 ]---
```

I'm starting to get desperate.

----------

## heartburn

I unmerged wireless-tools and remerged wpa_supplicant. Now, the page fault has stopped and it connects with a dynamic ip. But each time I boot, it still takes about a half-minute. This is with the wired network plugged in.

```
[    3.554613] ath9k 0000:03:00.0: PCI INT A -> GSI 17 (level, low) -> IRQ 17

[    3.554640] ath9k 0000:03:00.0: setting latency timer to 64

[    3.606113] ath: EEPROM regdomain: 0x65

[    3.606118] ath: EEPROM indicates we should expect a direct regpair map

[    3.606125] ath: Country alpha2 being used: 00

[    3.606129] ath: Regpair used: 0x65

[    3.610688] phy0: Selected rate control algorithm 'ath9k_rate_control'

[    3.611021] Registered led device: ath9k-phy0::radio

[    3.611078] Registered led device: ath9k-phy0::assoc

[    3.611138] Registered led device: ath9k-phy0::tx

[    3.611194] Registered led device: ath9k-phy0::rx

[    3.611233] phy0: Atheros AR9285 Rev:2 mem=0xf8980000, irq=17

[    4.464890] EXT4-fs (sda3): mounted filesystem with ordered data mode

[    5.420056] r8169: eth0: link up

[    5.420073] r8169: eth0: link up

[   49.546319] Adding 4044792k swap on /dev/sda4.  Priority:-1 extents:1 across:4044792k SSD

[   51.871621] wlan0: direct probe to AP 00:21:29:87:20:11 (try 1)

[   51.875252] wlan0: direct probe responded

[   51.875266] wlan0: authenticate with AP 00:21:29:87:20:11 (try 1)

[   51.877437] wlan0: authenticated

[   51.877497] wlan0: associate with AP 00:21:29:87:20:11 (try 1)

[   51.880049] wlan0: RX AssocResp from 00:21:29:87:20:11 (capab=0x411 status=0 aid=1)

[   51.880057] wlan0: associated

[   58.631000] NET: Registered protocol family 10

[   69.299654] wlan0: no IPv6 routers present

[   69.409658] eth0: no IPv6 routers present
```

Last edited by heartburn on Sat Apr 24, 2010 7:04 pm; edited 1 time in total

----------

## NeddySeagoon

heartburn,

Your last code snippet is either a kernel panic, in which case everything stopped because the kernel cannot recover, or its a kernel oops, which is recoverable. It looks like iwconfig was the source of the problem

You should not be setting the ssid in net and in wpa_supplicant.conf ( don't know that you are).

My own preference is to put as much as possible in wpa_supplicant.conf but thats just a personal preference.

----------

## heartburn

The machine continued to work -- just without networking. 

I was thinking the same way, that's why I decided to remove wireless-tools. My net and wpa_supplicant are what I posted before. Do you think I should even remove the ssid from preferred_aps?

----------

## NeddySeagoon

heartburn,

```
# scripts in /etc/init.d.  To create a more complete configuration,

# please review /usr/share/doc/openrc/net.example and save your configuration

# in /etc/conf.d/net (this file :]!).

# Prefer ifconfig over iproute2

modules=( "wpa_supplicant ifconfig" )

mode_wlan0="managed"
```

is all I have in my net file. everything else is in wpa_supplicant, as I posted earlier.

I have a ath5k chipset.

----------

## heartburn

I'll try that.

BTW, how do you keep the wired network from trying to connect when it's unplugged?

----------

## heartburn

I fixed my net to look exactly like yours, but it takes even longer now. The wireless is about the same, but the ethernet takes a while to default to dhcp without a configuration. So, it had pretty much no effect.

----------

## NeddySeagoon

heartburn,

You can stop the system attempting to bring up both interfaces with an edit to /etc/rc.conf

Its well commented.

You can also decrease the dhcp timeout with a setting in the net file.

There is an example of that in /usr/share/doc/openrc-0.6.1-r1/...   grep for -t 5

This cuts the timeout to 5 seconds.

----------

## heartburn

yes. That helped.

Anyway, I'm pretty sure that it was wireless-tools-29 that was causing the page fault. I've uninstalled & reinstalled it several times, and that problem only happens when it's installed, and always when it's installed. I guess that's what probably also does the parsing for ssid specific configurations because, as far as I can tell, wpa_supplicant seems to ignore those ssids.  I suppose I'll set up quickswitch instead.

Thanks for all your help!

----------

