# [solved] Ad-hoc impossible after connecting to router

## haarp

I'm trying to tether with my phone, which requires ad-hoc. My setup is NetworkManager (quite buggy under Gentoo btw) with an Intel wireless card (IWL1000) and gentoo-sources-3.3.3

Now, when the system has just booted, or I rmmod and modprobe the necessary modules (cfg80211, mac80211, iwlwifi), I can tether just fine. This works with no problems:

```
# iwconfig wlan0 mode ad-hoc
```

However, when I connect to my regular router (standard access point with WPA2) just once, and then try to tether again, it will fail. This is why:

```
# iwconfig wlan0 mode ad-hoc 

Error for wireless request "Set Mode" (8B06) :

    SET failed on device wlan0 ; Operation not supported.
```

So something has changed during the connection to my router. Something that broke ad-hoc.

I've played around with CRDA and regulatory stuff, because according to this, "Operation not supported" is a problem related to that. However, the regulatory domain doesn't even change when I connect to my router! So I don't see how it can be an issue.

It must be something else, or something I am missing. Any ideas?Last edited by haarp on Mon Jun 11, 2012 4:15 pm; edited 1 time in total

----------

## haarp

bump

----------

## khayyam

haarp ...

As I understand it, the "Operation not supported" error is simply the result of not being able to carry out the requested task.

NetworkManager (which I don't use) is known to cause issues if putting the card into monitor mode, and the advice is to kill it prior. As far as I remember (a search for aircrack-ng + NetworkManager should provide you with more details) NetworkManager doesn't like to relinqish its hold on the device, and so anything set via some other method is registered and reverted. I say this not because I think its the root of your problem, but so you know that it can interfere with things, and so that you can kill it while debugging the problem.

My guess is that the card is still "up" when you do the iwconfig, I have a similar issue if, say, I connect to my AP, disconnect, and then attempt to change the MAC, the solution may be fairly simple:

```
ifconfig wlan0 down && iwconfig wlan0 mode ad-hoc
```

If this works then its simply a matter of adding this to 'postdown()' in /etc/conf.d/net

```
postdown() {                                                                                                                                                   

    if [[ ${IFACE} = "wlan0" ]] ; then

        ifconfig wlan0 down

    fi                                                                                                                                                         

}
```

I can't say for certain that this is what's at issue here, but if, as you say, a reboot or rmmod will cause the problem to disapear then its not likely to be CDRA, note the bug author would have this issue "whether its been brought up or down with ifconfig", so it sounds as if s/he is simply unable to get into ad-hoc mode.

Anyhow, hope this is of some help ... best

khay

----------

## Logicien

To connect to your router, I suppose your wireless card fallback to Managed mode. It is the default mode to connect to most routers. So check the mode of the card when connected to your router

```
iwconfig wlan0
```

If it is in Managed mode and you want to put your wireless card in Ad-Hoc mode again, you can try

```
ifconfig wlan0 down

iwconfig wlan0 mode Ad-Hoc

ifconfig wlan0 up
```

Most of the wireless cards configurations can be done when the card is down. I did it before.

----------

## haarp

Thanks for your replies.

Sadly, stopping the NetworkManager service and forcing the interface down doesn't make a difference. It still returns "Operation not supported" when trying to enter ad-hoc mode.

It appears I really have to unload and reinsert the modules  :Sad: 

----------

## khayyam

haarp ...

I see ... and does ifconfig show the card as being configured post 'ifconfig down', and are there any other processes running that might be holding the card?

Potencial 'suspects': wpa_action, wpa_supplicant, wpa_cli, dhclient, ifplugd, dhcdbd, dhcpcd, knetworkmanager, avahi-autoipd, avahi-daemon, wlassistant, wifibox (and quite possibly .. more)

I ask only to rule out some of the more obvious things that could cause the card not be behave.

If I were you I would remove any network daemons (NetworkManager, avahi, etc) from your run-level, reboot and configure the network interface by hand (either using wpa_supplicant, or by configuring /etc/conf.d/net). I would then connect and disconnect from the AP, bring the interface down, and see if the problem persists. Again, its a question of ruling out anything but the driver. I have encountered a number of situations where these 'helpers' (gah) decide they know better than the user how things should work (fortuantely not on my own machine.)

If the problem persists then it can probably can be traced to the card/driver ... and you would be best to take it up with the authors of the driver.

HTH & best ...

khay

----------

## haarp

I'm pretty sure by now that the problem is not some service holding the card active. Stopping NetworkManager also shuts down any net-related subsystems. 

Even manually downing the interface doesn't make a difference (yup, the interface is really down). I can even switch between managed and ad-hoc when the interface is up, given that I haven't triggered the problem yet by connecting to an AP.

Looks like I'll have to get in touch with the driver devs.

EDIT:

Some random bug on the Intel Wireless bugzilla gave me the right idea: Switch to channel 1, then try setting mode to ad-hoc!

```

# iwconfig wlan0 channel 1

# iwconfig wlan0 mode ad-hoc

```

It works! Now I just have to teach NetworkManager how to do that...

----------

## khayyam

haarp ...

ahh, good.

Well, when debugging these things I always start with the most obvious, and as I've seen too many situations where the card can't be modified because some daemon or other I wanted to exclude that (btw, the list above is from the airmon-ng script). Similarly with the interface being brought down, as I mentioned previously, some actions effecting the card will error if the card is 'up' (though unconnected), and again, ruling out the obvious.

Which reminds me ... ifconfig is depreciated, and so I should have provided 'ip' (its replacement) above.

```
ip link set dev wlan0 down
```

As far as NetworkManager is concered, as I said I don't use it, but it uses /etc/init.d/NetworkManagerDispatcher to do this kind of thing. Scripts are placed in /etc/Networkmanager/dispatcher.d (which has sysvinit style setup). More information here.

HTH & best ...

khay

----------

