# connessione wireless ad-hoc non funzionante...

## alegioit

ciao a tutti di nuovo  :Wink:  .

Come qualcuno già saprà sto reinstallando gentoo sul mio serverino domestico... ho un problema con le icone ma posso non farci caso. Vorrei però far fungere il serverino anche da router.

Dopo aver provato varie schede wireless (di cui per nessuna vi è il supporto in linux per il modo master o ad-hoc) ho trovato una "RaLink RT2561/RT61 rev B 802.11g" che sembra funzionare bene anche in ad-hoc mode.

Il problema è che sembra tutto funzionare ( i due client si vedono e si agganciano ), ma non si scambiano pacchetti!

Non sto utilizzando il dhcp per comodità, quindi gli sto assegnando un indirizzo fisso... spero di star facendo casini!

L'interfaccia è un ed è funzionante, almeno credo!

Sto utilizzando la crttografia wep, ho provato anche a toglierla, ma il problema persiste!

Naturalmente ho iptables attivo, ma dovrei averso settato giusto e disattivandolo continuano a non pingarsi i computer.

less /etc/conf.d/net

```

#rete lan

config_eth1="dhcp"

modules_eth1="dhclient"

config_eth0="192.168.0.1/24 broadcast 192.168.0.255"

#rete wifi

config_wlan0="192.168.100.1 netmask 255.255.255.252 broadcast 192.168.100.3"

mode_wlan0="ad-hoc"

essid_wlan0="xxxxxxxxxx"

channel_wlan0="2"

key_irkwik="xxxxxxxxxxxxxxxxxx"

```

L'altro pc (su cui gira xp) ha indirizzo 192.168.0.2 netmask 255.255.255.252 bc 192.168.0.3

dmesg

```

#############DA QUI HO ATTIVATO L'INTARFACCIA###############

[92851.926028] phy0 -> rt2x00mac_conf_tx: Info - Configured TX queue 0 - CWmin: 2, CWmax: 3, Aifs: 2, TXop: 47.

[92851.926039] phy0 -> rt2x00mac_conf_tx: Info - Configured TX queue 1 - CWmin: 3, CWmax: 4, Aifs: 2, TXop: 94.

[92851.926048] phy0 -> rt2x00mac_conf_tx: Info - Configured TX queue 2 - CWmin: 4, CWmax: 10, Aifs: 3, TXop: 0.

[92851.926058] phy0 -> rt2x00mac_conf_tx: Info - Configured TX queue 3 - CWmin: 4, CWmax: 10, Aifs: 7, TXop: 0.

[92852.049059] phy0: device no longer idle - in use

[92852.049079] wlan0: sta_find_ibss (active_ibss=0)

[92852.049083]    sta_find_ibss: selected 1e:38:90:96:22:56 current 00:00:00:00:00:00

[92852.049085] wlan0: Selected IBSS BSSID 1e:38:90:96:22:56 based on configured SSID

[92852.053167] phy0 -> rt2x00mac_conf_tx: Info - Configured TX queue 0 - CWmin: 2, CWmax: 3, Aifs: 2, TXop: 47.

[92852.053174] phy0 -> rt2x00mac_conf_tx: Info - Configured TX queue 1 - CWmin: 3, CWmax: 4, Aifs: 2, TXop: 94.

[92852.053181] phy0 -> rt2x00mac_conf_tx: Info - Configured TX queue 2 - CWmin: 4, CWmax: 10, Aifs: 3, TXop: 0.

[92852.053187] phy0 -> rt2x00mac_conf_tx: Info - Configured TX queue 3 - CWmin: 4, CWmax: 10, Aifs: 7, TXop: 0.

[92862.313011] wlan0: no IPv6 routers present

[92955.332678] UDP: short packet: From 0.136.255.255:8960 13568/115 to 160.60.200.1:31488

```

iwlist scanning

```

Cell 01 - Address: 1E:38:90:96:22:56

                    Channel:2

                    Frequency:2.417 GHz (Channel 2)

                    Quality=70/70  Signal level=0 dBm

                    Encryption key:on

                    ESSID:"xxxxxxxxxxxxx"

                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s

                              9 Mb/s; 12 Mb/s; 18 Mb/s

                    Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s

                    Mode:Ad-Hoc

                    Extra:tsf=000000000b4e322d

                    Extra: Last beacon: 573782ms ago

                    IE: Unknown: 000669726B77696B

                    IE: Unknown: 010802040B160C121824

                    IE: Unknown: 030102

                    IE: Unknown: 06020000

                    IE: Unknown: 32043048606C

```

iwconfig wlan0

```

wlan0     IEEE 802.11bg  ESSID:"xxxxxxxxxxxxxxx"

          Mode:Ad-Hoc  Frequency:2.417 GHz  Cell: 1E:38:90:96:22:56

          Tx-Power=19 dBm

          Retry  long limit:7   RTS thr:off   Fragment thr:off

          Encryption key:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

          Power Management:on

```

ifconfig

```

wlan0     Link encap:Ethernet  HWaddr 00:1c:f0:0d:ed:12

          inet addr:192.168.100.1  Bcast:192.168.100.3  Mask:255.255.255.252

          inet6 addr: fe80::21c:f0ff:fe0d:ed12/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:302 errors:0 dropped:0 overruns:0 frame:0

          TX packets:286 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:22634 (22.1 KiB)  TX bytes:46943 (45.8 KiB)

```

boh, ifconfig indica che si scambiano dati, ma i due computer non scambiano nessun pacchetto quando sono collegati tra loro... non capisco

script iptables

```

#!/bin/bash

#First we flush our current rules

 iptables -F

 iptables -t nat -F

#Setup default policies to handle unmatched traffic

 iptables -P INPUT ACCEPT

 iptables -P OUTPUT ACCEPT

 iptables -P FORWARD DROP

#Copy and paste these examples ...

 export WAN=eth1

 export LAN=eth0

 export WLAN=wlan0

#Then we lock our services so they only work from the LAN

 iptables -I INPUT 1 -i ${LAN} -j ACCEPT

 iptables -I INPUT 1 -i lo -j ACCEPT

 iptables -A INPUT -p UDP --dport bootps ! -i ${LAN} -j REJECT

 iptables -A INPUT -p UDP --dport domain ! -i ${LAN} -j REJECT

#(Optional) Allow access to our ssh server from the WAN

 iptables -A INPUT -p TCP --dport ssh -i ${WAN} -j ACCEPT

#Drop TCP / UDP packets to privileged ports

 iptables -A INPUT -p TCP ! -i ${LAN} -d 0/0 --dport 0:1023 -j DROP

 iptables -A INPUT -p UDP ! -i ${LAN} -d 0/0 --dport 0:1023 -j DROP

#Finally we add the rules for NAT

 iptables -I FORWARD -i ${LAN} -d 192.168.0.0/255.255.0.0 -j DROP

 iptables -A FORWARD -i ${LAN} -s 192.168.0.0/255.255.0.0 -j ACCEPT

 iptables -A FORWARD -i ${WAN} -d 192.168.0.0/255.255.0.0 -j ACCEPT

 iptables -A FORWARD -i ${WLAN} -s 192.168.100.0/255.255.0.0 -j ACCEPT

 iptables -t nat -A POSTROUTING -o ${WAN} -j MASQUERADE

#Tell the kernel that ip forwarding is OK

 echo 1 > /proc/sys/net/ipv4/ip_forward

 for f in /proc/sys/net/ipv4/conf/*/rp_filter ; do echo 1 > $f ; done

#Regole aMule

 iptables -A INPUT -p tcp --dport 4662 -j ACCEPT

 iptables -A INPUT -p udp --dport 4665 -j ACCEPT

 iptables -A INPUT -p udp --dport 4672 -j ACCEPT

 iptables -A INPUT -p tcp --dport 4762 -j ACCEPT

 iptables -A INPUT -p udp --dport 4765 -j ACCEPT

 iptables -A INPUT -p udp --dport 4772 -j ACCEPT

```

----------

## alegioit

Uhm... mi sono accorto che iptables così com'era non poteva funzionare... adesso dovrebbe andare bene, ma comunque i due computer non si scambiano lo stesso nessun pacchetto....

```

#!/bin/bash

#First we flush our current rules

 iptables -F

 iptables -t nat -F

#Setup default policies to handle unmatched traffic

 iptables -P INPUT ACCEPT

 iptables -P OUTPUT ACCEPT

 iptables -P FORWARD DROP

#Copy and paste these examples ...

 export WAN=eth1

 export LAN=eth0

 export WLAN=wlan0

#Then we lock our services so they only work from the LAN

 iptables -I INPUT 1 -i ${LAN} -j ACCEPT

 iptables -I INPUT 1 -i lo -j ACCEPT

 iptables -A INPUT -p UDP --dport bootps ! -i ${LAN} -j REJECT

 iptables -A INPUT -p UDP --dport domain ! -i ${LAN} -j REJECT

#Then we lock our services so they only work from the WLAN

 iptables -I INPUT 1 -i ${WLAN} -j ACCEPT

 iptables -A INPUT -p UDP --dport bootps ! -i ${WLAN} -j REJECT

 iptables -A INPUT -p UDP --dport domain ! -i ${WLAN} -j REJECT

#(Optional) Allow access to our ssh server from the WAN

 iptables -A INPUT -p TCP --dport ssh -i ${WAN} -j ACCEPT

#Drop TCP / UDP packets to privileged ports

 iptables -A INPUT -p TCP ! -i ${LAN} -d 0/0 --dport 0:1023 -j DROP

 iptables -A INPUT -p UDP ! -i ${LAN} -d 0/0 --dport 0:1023 -j DROP

#Drop TCP / UDP packets to privileged ports

 iptables -A INPUT -p TCP ! -i ${WLAN} -d 0/0 --dport 0:1023 -j DROP

 iptables -A INPUT -p UDP ! -i ${WLAN} -d 0/0 --dport 0:1023 -j DROP

#Finally we add the rules for NAT

 iptables -I FORWARD -i ${LAN} -d 192.168.0.0/255.255.0.0 -j DROP

 iptables -A FORWARD -i ${LAN} -s 192.168.0.0/255.255.0.0 -j ACCEPT

 iptables -I FORWARD -i ${WLAN} -d 192.168.100.0/255.255.0.0 -j DROP

 iptables -A FORWARD -i ${WLAN} -s 192.168.100.0/255.255.0.0 -j ACCEPT

 iptables -A FORWARD -i ${WAN} -d 192.168.0.0/255.255.0.0 -j ACCEPT

 iptables -t nat -A POSTROUTING -o ${WAN} -j MASQUERADE

#Tell the kernel that ip forwarding is OK

 echo 1 > /proc/sys/net/ipv4/ip_forward

 for f in /proc/sys/net/ipv4/conf/*/rp_filter ; do echo 1 > $f ; done

#Regole aMule

 iptables -A INPUT -p tcp --dport 4662 -j ACCEPT

 iptables -A INPUT -p udp --dport 4665 -j ACCEPT

 iptables -A INPUT -p udp --dport 4672 -j ACCEPT

 iptables -A INPUT -p tcp --dport 4762 -j ACCEPT

 iptables -A INPUT -p udp --dport 4765 -j ACCEPT

 iptables -A INPUT -p udp --dport 4772 -j ACCEPT

```

----------

## xdarma

 *alegioit wrote:*   

> 
> 
> #rete wifi
> 
> config_wlan0="192.168.100.1 netmask 255.255.255.252 broadcast 192.168.100.3"
> ...

 

Non c'ho capito una mazza, ma:

- forse hai bisogno di un gateway perché wlan0 del server è sulla rete 192.168.100.x mentre eth0 di xp è in 192.168.0.x;

- posta anche il risultato di: route -n

Ciao.

----------

## alegioit

gnem.... era lo script di iptables... con il secondo che ho scritto funziona tutto!!!

----------

