how to set up ad-hoc network

Hey guys,

I am new to linux - first day.

I used to have a shell script on my freebsd box to configure an adhoc network
I am using the intel pro wireless 2200bg wireless nic
The driver is ipw2200

Could someone help me translate this script to run on linux?

ifconfig iwi0 ssid wiretap
ifconfig iwi0 mediaopt adhoc
ifconfig iwi0 up
ifconfig iwi0

I am running in “OPEN” mode. If you need more info please let me know.




man iwconfig

should help.

thanks that did it

iwconfig eth0 essid wiretap
iwconfig eth0 mode Ad-Hoc
iwconfig eth0 up
iwconfig eth0

I don’t think so, these commands

iwconfig eth0 up
iwconfig eth0

certainly don’t work with iwconfig.

so would I use ip like this?

ip link set dev eth0 up
ip addr add eth0

If you want, why not, but using iwconfig for the purely wireless related commands (setting ssid/mode/etc.) and ifconfig for the others would also work.

help this has gotten bad. I created a new script

iwconfig eth0 mode Ad-Hoc
iwconfig eth0 essid wiretap
iwconfig eth0 chan 11
ifconfig eth0 up
ifconfig eth0
ip route add  default via

but it doesnt work :confused:

I need some more help. What is the command to scan for wireless networks? in bsd its ifconfig eth0 scan but I need the linux equiv

here is the output from some commands

# iwconfig eth0
eth0      IEEE 802.11b  ESSID:"wiretap"  
          Mode:Ad-Hoc  Frequency:2.462 GHz  Cell: 02:18:41:89:98:FD   
          Bit Rate:11 Mb/s   Tx-Power=20 dBm   Sensitivity=8/0  
          Retry limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:off
          Link Quality=65/100  Signal level=-62 dBm  Noise level=-85 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:5   Missed beacon:0

# ifconfig eth0 
eth0      Link encap:Ethernet  HWaddr 00:13:CE:7F:4D:68  
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::213:ceff:fe7f:4d68/64 Scope:Link
          RX packets:276 errors:0 dropped:5 overruns:0 frame:0
          TX packets:12 errors:0 dropped:121 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:11239 (10.9 Kb)  TX bytes:22624 (22.0 Kb)
          Interrupt:23 Base address:0xa000 Memory:b0107000-b0107fff 

note that in iwconfig is should be saying 11g not 11b but I cant manually change.

# netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface   U         0 0          0 eth0       U         0 0          0 lo         UG        0 0          0 eth0

# netstat -i eth0
Kernel Interface table
eth0   1500   0     519      0      0      5      15      0      0    121 BMRU

# ping
PING ( 56(84) bytes of data.
64 bytes from icmp_seq=1 ttl=64 time=16.4 ms
64 bytes from icmp_seq=2 ttl=64 time=6.19 ms
64 bytes from icmp_seq=3 ttl=64 time=5.45 ms
--- ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2005ms
rtt min/avg/max/mdev = 5.455/9.382/16.496/5.040 ms

linux-p0a1:/home/chrisd # ping
PING ( 56(84) bytes of data.
--- ping statistics ---
7 packets transmitted, 0 received, 100% packet loss, time 5999ms

linux-p0a1:/home/chrisd # nslookup
;; connection timed out; no servers could be reached

I can ping both to and from the router <–> laptop

However I cannot telnet or ssh, so somewhere in there lies the problem. Anyone can please help?


If you have a router then why an Ad-Hoc network setup?

And why don’t you use the configuration tools provided by your distribution?


Without name servers (/etc/resolv.conf) there is also no way for that last command to work (which needs DNS).

maybe router is not the right term. what is the right term access point?

I also manually added to my /etc/resolv.conf that didnt work.

I have to configure it manually because the tools that come with this distribution 11.1 / KDE dont have an option for ad-hoc.

Also I should be able to telnet/ssh from the phone to the laptop, but I cannot because it times out.

Thanks in advance

Well, iwconfig shows that you are connected to “wiretap” and pings to the “router” also work.

Using the “traditional method with ifup” (instead of NetworkManager) in YaST will give you the possibility to set up an Ad-hoc network.


Does your laptop actually run sshd and are the ports open (firewall)?


Yes sshd is running, but not telnet. Anyway
I have to run but I will try with ifup. I can read and post to the forum via my cell phone and I will try again later and this weekend to find the solution, so if you have any more solutions…

thanks for all your help

Did you allow ssh in SuSEfirewall2?

(Or just turn the firewall off for testing)

Can you reach (ping?) the Laptop from your phone (if ping is available on your phone)?