Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
NAT con modem usb e router wireless [risolto,forward errato]
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) Forum di discussione italiano
View previous topic :: View next topic  
Author Message
power83
l33t
l33t


Joined: 28 Nov 2004
Posts: 638

PostPosted: Sun Jan 14, 2007 10:21 am    Post subject: NAT con modem usb e router wireless [risolto,forward errato] Reply with quote

ciao ragazzi, ho un grave problema al quale non ci salto fuori, nemmeno in chat con l'aiuto di raven79 ci siamo saltati fuori.

Ecco la situazione, se nn chiara chiedete e vi sara' detto :lol:

Code:
 PORTATILE

- ha connesso tramite usb un modem adsl, che il sistema con ifconfig identifica con ppp0
- ha connesso tramite eth0 un router wireless
eth0: 192.168.0.10              indirizzo router wireless 192.168.0.1


Code:
 FISSO (o fesso, dato che non riesce a scroccare)
scheda PCI wireless  ath0 192.168.0.20


Ora, io vorrei fare NAT sul PORTATILE e quindi navigare ed emergere SUL FISSO.

Come posso fare???

Lo scritp seguente funzionava connettendo i 2 computer con cavo incrociato, lanciato da PORTATILE:
Code:
#!/bin/sh

iptables -F
iptables -t nat -F
iptables -X
iptables -X -t nat

# Setup default policies to handle unmatched traffic
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP

export WAN=ppp0
export BR0=eth0

# (Optional) Allow access to our ssh server from the WAN
iptables -A INPUT -p TCP --dport ssh -i ${WAN} -j DROP

# Drop TCP / UDP packets to privileged ports
iptables -A INPUT -p TCP -i ! ${BR0} -d 0/0 --dport 0:1023 -j DROP
iptables -A INPUT -p UDP -i ! ${BR0} -d 0/0 --dport 0:1023 -j DROP

# Finally we add the rules for NAT
iptables -I FORWARD -i ${BR0} -d 192.168.0.0/255.255.255.0 -j DROP
iptables -A FORWARD -i ${BR0} -s 192.168.0.0/255.255.255.0 -j ACCEPT
iptables -A FORWARD -i ${WAN} -d 192.168.0.0/255.255.255.0 -j ACCEPT
iptables -t nat -A POSTROUTING -o ${WAN} -j MASQUERADE


sul FISSO invece:
Code:
route add -net default gw 192.168.0.10 dev ath0 metric 1


Ovivamente, su entrambi:
Code:
cat /etc/resolv.conf
nameserver 213.205.32.70
nameserver 213.205.36.70


tale cosa ha sempre fuznoinato su cavo, ora invece no e non capisco il perche'.

Potrebbe essere perche' deve attraversa l'host 192.168.0.1?

Come posso risolvere???


Last edited by power83 on Sun Jan 14, 2007 2:35 pm; edited 2 times in total
Back to top
View user's profile Send private message
comio
Advocate
Advocate


Joined: 03 Jul 2003
Posts: 2191
Location: Taranto

PostPosted: Sun Jan 14, 2007 10:51 am    Post subject: Reply with quote

Domanda stupida... hai abilitato il forwarding?

Code:

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


In ogni caso, i pc si pingano a vicenda?

ciao
_________________
RTFM!!!!

e

http://www.comio.it
:)
Back to top
View user's profile Send private message
power83
l33t
l33t


Joined: 28 Nov 2004
Posts: 638

PostPosted: Sun Jan 14, 2007 10:53 am    Post subject: Reply with quote

si certo e' abilitato, e i computers si pingano a vicenda e oguno riesce ovviamente a pingare il router.

avevo dimenticato la parte finale dello script:
Code:
# 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
Back to top
View user's profile Send private message
comio
Advocate
Advocate


Joined: 03 Jul 2003
Posts: 2191
Location: Taranto

PostPosted: Sun Jan 14, 2007 11:52 am    Post subject: Reply with quote

power83 wrote:
si certo e' abilitato, e i computers si pingano a vicenda e oguno riesce ovviamente a pingare il router.

avevo dimenticato la parte finale dello script:
Code:
# 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


Prova a mettere tutto in ACCEPT. funzia?

inizia ad abilitare una regola alla volta.

ciao
_________________
RTFM!!!!

e

http://www.comio.it
:)
Back to top
View user's profile Send private message
power83
l33t
l33t


Joined: 28 Nov 2004
Posts: 638

PostPosted: Sun Jan 14, 2007 12:36 pm    Post subject: Reply with quote

FUNZIONAAAAAAAAAA

ecco lo script modificato:
Code:
#!/bin/sh

iptables -F
iptables -t nat -F
iptables -X
iptables -X -t nat

# Setup default policies to handle unmatched traffic
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT

export WAN=ppp0
export BR0=eth0

iptables -A INPUT -p TCP -i ${BR0} -j ACCEPT
iptables -A INPUT -p UDP -i ${BR0} -j ACCEPT

# Finally we add the rules for NAT
iptables -I FORWARD -i ${BR0} -j ACCEPT
iptables -A FORWARD -i ${BR0} -j ACCEPT
iptables -A FORWARD -i ${WAN} -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


cosi funziona!!!

Solo che non posso lasciare delle regole del genere......da delinquente........orafor' varie prove modificando un passo alla volta con l'ausilio della man page di iptables, giusto comio?

ps: ma che cavolo era sbagliato nello script originale che funzionava perfettamente con cavo incrociato?????
Back to top
View user's profile Send private message
comio
Advocate
Advocate


Joined: 03 Jul 2003
Posts: 2191
Location: Taranto

PostPosted: Sun Jan 14, 2007 2:07 pm    Post subject: Reply with quote

power83 wrote:
FUNZIONAAAAAAAAAA

ecco lo script modificato:
Code:
#!/bin/sh

iptables -F
iptables -t nat -F
iptables -X
iptables -X -t nat

# Setup default policies to handle unmatched traffic
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT

export WAN=ppp0
export BR0=eth0

iptables -A INPUT -p TCP -i ${BR0} -j ACCEPT
iptables -A INPUT -p UDP -i ${BR0} -j ACCEPT

# Finally we add the rules for NAT
iptables -I FORWARD -i ${BR0} -j ACCEPT
iptables -A FORWARD -i ${BR0} -j ACCEPT
iptables -A FORWARD -i ${WAN} -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


cosi funziona!!!

Solo che non posso lasciare delle regole del genere......da delinquente........orafor' varie prove modificando un passo alla volta con l'ausilio della man page di iptables, giusto comio?

ps: ma che cavolo era sbagliato nello script originale che funzionava perfettamente con cavo incrociato?????


Dovresti controllare bene le regole in forward. Dai un occhio qui http://www.comio.it/2006/08/attraversamento-catene-di-iptables.html. Per capire meglio l'attraversamento.
Rimetti il forward in DROP, inoltre nota le prime due regole della catena di forward che a mio avviso ti fanno casini. Devi permettere il traffico in/out Wan<->Br in entrambi i sensi, altrimenti non ti funzia.

ciao

luigi
_________________
RTFM!!!!

e

http://www.comio.it
:)
Back to top
View user's profile Send private message
power83
l33t
l33t


Joined: 28 Nov 2004
Posts: 638

PostPosted: Sun Jan 14, 2007 2:34 pm    Post subject: Reply with quote

ok grazie, allora e' il forward che rompeva i......

ps: ma devo droppare -A o -I di FORWARD (premetto che solo stas leggero' la documentazione)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) Forum di discussione italiano All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum