# setting up an adhoc-hub drives me crazy

## rer

I try to set up an adhoc-hub/ap. I use a rtl8187-usb-stick, but due to the inability of the rtl8187-driver to run in adhoc-mode, I use ndiswrapper (or has someone rtl8187 working in adhoc out there?)

Anyway, If I set it up the manual way it works like a charm, like this

rmmod rtl8187

modprobe ndiswrapper

sleep 3

iwconfig wlan1 mode ad-hoc

iwconfig wlan1 essid -- ANY

iwconfig wlan1 key dc:c4:36:8e:ed open

iwconfig wlan1 rate 11M chan 4

ifconfig wlan1 192.168.0.5/25

other nodes can connect now and communicate, iwconfig wlan1 shows:

     IEEE 802.11g  ESSID:"ANY"

          Mode:Ad-Hoc  Frequency:2.427 GHz  Cell: 02:E0:7F:A3:B0:F7

          Bit Rate=11 Mb/s   Tx-Power:20 dBm   Sensitivity=0/3

          RTS thr:off   Fragment thr:off

          Encryption key:DCC4-368E-ED   Security mode:open

          Power Management:off

          Link Quality:62/100  Signal level:-56 dBm  Noise level:-96 dBm

          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0

          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

I setup /etc/conf.d/net the following way:

modules_wlan1=( "iwconfig" )

config_wlan1=("192.168.0.5/25")

mode_wlan1="ad-hoc"

essid_wlan1="ANY"

adhoc_essid_wlan1="ANY"

#scan_mode_wlan1="ad-hoc"

channel_wlan1="4"

#wpa_supplicant_wlan1="-Dndiswrapper -d -iwlan1"

If I start the box, and I have net.wlan1 in default start level, strange things happen. iwconfig shows the right key and mode, but the wrong ssid (Its the one of an other nearby AP), not the configured "ANY", but it comes even more strange.

If I restart net.wlan1, log and iwconfig shows nearly everything like expected, with the exception of the channel#. The channel-parameter seems to be ignored, everything else is okay even the SSID. Clients can connect/associate now, but not communicate, i cannot ping, dhcp for them is also not working, the hubs IPs and routes are set up as expected, the iwconfig-output is exactly the same as if I do it the manual way.

If I then do this:

iwconfig wlan1 key dc:c4:36:8e:ed open

everything works fine, but I swear, the same key was set before, if not, the clients couldn't associate, this command seems to trigger something, I cannot see. 

btw. wpa_supplicant is even worse.

Any idea!

----------

## DawgG

iwconfig configures the wireless layer, ifconfig configures tcp/ip. first the wireless stuff has to be set up, then, on top of that, you assign ip-adresses etc. iwconfig can NOT assign any tcp/ip-parameters.

ANY is a special keyword for iwconfig - meaning just "take ANY" ap out there, and in ad-hoc mode it does just this, hooks up with any ad-hoc-node out there. if this other node is on channel 11 your card can not be on the same channel with a different ssid (i think). also, not all iwconfig-commands work on all cards.

personally i find setting up wireless connections with conf.d/net a little tiresome and do it in extra-scripts, but it certainly works easily. you probably have to adapt your config a little more.

GOOD LUCK!

----------

## rer

I thought lowercase "any" is the special word, or is this caseinsensitive? And why does it work, when I execute the script?

I also put the script in the udev-rule for the device, as a RUN-rule, but this also doesnt work reliable espacially when I resume from hibernate, although the rule seems to be executed, because the device-renaming from wlan0 to wlan1 included in that rule is also done. Is it possible, that the device needs some time to settle and the udev-rule or net.wlan1-initscript is executed to early?

----------

## DawgG

 *Quote:*   

> I thought lowercase "any" is the special word, or is this caseinsensitive? 

  i don't know, but generally it is a good idea to avoid using keywords like that at all (like naming your box l0calhost).

 *Quote:*   

> why does it work, when I execute the script? 

  because all thje commands are executed in the right order, using other scripts and (sub)systems like udev can mess this up.

 *Quote:*   

> also put the script in the udev-rule for the device, as a RUN-rule, but this also doesnt work reliable

  while it is possible to do all this with udev it will require very thorough testing, especially if you have the same stuff in your /etc/conf.d/net-file. it is probably the best to write your own rule which must then be executed in its correct  place in the sequence (i guess the correct place is NOT the device-renaming-rule).

and yes, some devices are special - i once had a wlan-nic which could not be configured at all before issuing a 

```
ifconfig <devname> up
```

 and waiting a couple of secs till the light went on.

if you want to give your wlan-nic an ip you probably also need the module "ifconfig" or "ifcfg" in /etc/conf.d/net

GOOD LUCK!

----------

