# creating Ad-Hoc wireless network like Ubuntu does [solved]

## fikiz

Hi all.

I realized that Ubuntu 9.04 has a very nice feature to create an ad-hoc network, and this network could be discovered and associated by other machines exactly like an access point managed network. That's great!

I would like to do the same thing with my Gentoo system. How can I do that? I tried a lot of iwconfig commands with no luck.

There's one thing I don't understand on my Ubuntu machine:

```
# iwconfig

wlan0     IEEE 802.11bgn  ESSID:"testing"

          Mode:Ad-Hoc  Frequency:2.412 GHz  Cell: C2:60:A9:35:97:3F

          Tx-Power=20 dBm

          Retry min limit:7   RTS thr:off   Fragment thr=2352 B

          Encryption key:off

          Power Management:off

          Link Quality:0  Signal level:0  Noise level:0

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

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

As you can see, there's a "Cell:" value. On managed networks it is the AP mac address (correct me if I'm wrong), but in this ad-hoc network I don't understand what kind of value it is and where Ubuntu takes it. And I don't know how to set it on my Gentoo using iwconfig command.

thanks for your help!Last edited by fikiz on Sun Jun 28, 2009 6:39 pm; edited 1 time in total

----------

## Bones McCracker

see the man page for iwconfig

 *Quote:*   

> Access Point/Cell
> 
>     An address equal to 00:00:00:00:00:00 means that the card failed to associate with an Access Point (most likely a configuration issue). The Access Point parameter will be shown as Cell in ad-hoc mode (for obvious reasons), but otherwise works the same.

 

It's the MAC address of the access point (or device) to which an association has been created.  You don't set it, it shows up when you are connected.

http://en.wikipedia.org/wiki/MAC_address

----------

## fikiz

Yes, you're right. Thanks for your answer.

I found this page that explain what to do:

http://www.crhc.illinois.edu/wireless/assignments/handson/lab1.html

but for me the Cell: field remains Not-associated even after the command to activate the wlan0 interface (ifconfig wlan0 192.168.12.1 up).

any ideas? There's still something missing!

thanks.

----------

## Bones McCracker

Handbook:

http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=4&chap=4

Read thoroughly:

/etc/conf.d/net.example

/etc/conf.d/wireless.example

Wiki's/HowTos:

This stuff is guaranteed to be at least somewhat out of date, but may be helpful:

http://en.gentoo-wiki.com/wiki/Wireless_Networking

http://www.gentoo-wiki.info/Wireless/Configuration

http://www.gentoo-wiki.info/Wireless/Managers

Setting up an access point is a different matter (I haven't done this -- no guarantee on any of this, but it looks relevant).

http://en.gentoo-wiki.com/wiki/Wireless/Access_point

http://en.gentoo-wiki.com/wiki/Madwifi_Wireless_Access_Point

http://kunxi.org/archives/2007/05/poor-mans-wireless-network/

https://forums.gentoo.org/viewtopic-t-274790-highlight-adhoc+wireless.html

----------

## szczerb

If I remember correctly, then in Ubuntu you set it up with NetworkManager. So, if you wanna have an AdHoc network like Ubuntu does it (that's what you claim), then you shall use NetworkManager to set it up.

BTW You can also us hostapd to set up a real access point.

----------

## fikiz

Yes, Ubuntu uses NetworkManager. But I'm looking for a manual non-automated command line configuration of my wireless card; I think it should be possible to obtain.

I'm not going to set up a real access point because AP-mode is still not supported by the driver (zd1211rw). This Ad-Hoc AP-like behaviour is enough for my needs.

I hope somebody knows what I'm doing wrong.

thanks!

----------

## fikiz

I was able to setup di adhoc AP-like network, adding these lines to /etc/conf.d/net:

modules_wlan0=("iwconfig")

mode_wlan0="Ad-hoc"

essid_wlan0="testing"

channel_wlan0="3"

config_wlan0=( "192.168.5.1/24" )

I still don't know the manual procedure, but works and it is better than installing NetworkManager only for this.

thank you for you patience.

----------

## Bones McCracker

I'm not sure what you mean by "manual procedure" or what you would use that for, but if you study the gentoo networking scripts and see what they are doing with these parameters you provide, then you should be able to determine the commands the scripts are executing to achieve what they are achieving.

----------

## fikiz

Yes, that's what I mean. Thank you for your suggestion.

----------

## Bones McCracker

 *fikiz wrote:*   

> Yes, that's what I mean. Thank you for your suggestion.

 

Start with the /etc/init.d/net.lo script, and see where it goes from there.

It's a bit complicated, but the scripts are designed to handle a wide variety of possibilities.

----------

## albright

I'll add this as example of hyper manual approach.

I just set up an ad-hoc network at the cottage. My script

is beyond simple:

```
#!/bin/bash

iwconfig eth1 mode ad-hoc

sleep 2

iwconfig eth1 essid bathaven

sleep 2

ifconfig eth1 192.168.0.10 netmask 255.255.255.0

sleep 1
```

(eth1 is my wireless interface of course). This works great - the

little gateway masqs ip addresses, does dns and dhcp (all set

up separately naturally). A genuine little network. 

I don't need encryption - the nearest dwelling is at least a km

away  :Smile: 

I wonder, how many machines before an ad-hoc network really

bogs down?

----------

