Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Problemi connessione..... [risolto]
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)
View previous topic :: View next topic  
Author Message
HunterD
Apprentice
Apprentice


Joined: 10 Mar 2004
Posts: 165

PostPosted: Mon Apr 12, 2004 2:54 pm    Post subject: Problemi connessione..... [risolto] Reply with quote

Dovrei condividere la connessione internet fra il pc fisso e il portatile , ave
ndo un modem ethernet ho sul pc due schede di rete ! La prima eth0 192.168.1.1
è collegata al modem , l'altra eth1 192.168.1.3 è collegata al portatile ,(il p
ortatile è 192.168.1.2 .... ) il problema è che non mi funge.... Ho seguito un
post di un pò di giorni fà che diceva di fare così

echo '0' > /proc/sys/net/ipv4/ip_forward
echo "Attivo le regole del firewall"
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

echo "Abilito il forward sulla lan"
iptables -A FORWARD -s 192.168.0.0/24 -j ACCEPT
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

echo "Riabilito l'ip forward"
echo '1' > /proc/sys/net/ipv4/ip_forward

Poi non ho fatto latro che dare sul portatile route add default gateway 192.168
.1.3 , ma nada...
oltretutto prima di dare le regole a iptables riuscivo a pingare dal portatile
poi neance quello !!
Un iptables -L mi restituisce

iptables -L
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT all -- anywhere anywhere state RELATED,ESTA
BLISHED
ACCEPT all -- 192.168.0.0/24 anywhere
ACCEPT all -- 192.168.0.0/24 anywhere

Chain FORWARD (policy DROP)
target prot opt source destination
ACCEPT all -- 192.168.0.0/24 anywhere
ACCEPT all -- anywhere anywhere state RELATED,ESTA
BLISHED

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

Che posso fare ??


Last edited by HunterD on Thu Apr 15, 2004 8:42 am; edited 1 time in total
Back to top
View user's profile Send private message
n3mo
l33t
l33t


Joined: 28 Mar 2004
Posts: 657
Location: In a Cruel World

PostPosted: Mon Apr 12, 2004 3:43 pm    Post subject: Reply with quote

Io cercherei di essere più preciso e cioè:

iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT

iptables -A INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i eth1 -s 192.168.0.0/24 -j ACCEPT
iptables -A INPUT REJECT

iptables -A FORWARD -s 192.168.0.0/24 -j ACCEPT
iptables -A FORWARD REJECT

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

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

Sul portatile:

route add default gw 192.168.0.3 netmask 255.255.255.0

a questo punto se ancora non funziona, devi cominciare a fare dei tentativi, dal portatile: ping su se stesso, ping skeda di rete interna del "server", ping un IP pubblico, ping un indirizzo pubblico.

Il comando iptables -L -v ti fa vedere i pacchetti che hanno fatto match con le regole, questo ti dovrebbe aiutare abbastanza per vedere dove si fermano i pacchetti.

Ricordati di Flushare le regole di Iptables prima dei vari tentativi altrimenti no fai altro che accodarle.
Back to top
View user's profile Send private message
n3mo
l33t
l33t


Joined: 28 Mar 2004
Posts: 657
Location: In a Cruel World

PostPosted: Mon Apr 12, 2004 4:40 pm    Post subject: Reply with quote

Devo scusarmi, ho avuro il tempo di fare un po' di prove e ho dato delle informazioni imprecise, vediamo di sistemare le cose: (appena testato e funzionante)

iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT

iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -s 127.0.0.1 -j ACCEPT
iptables -A INPUT -i eth1 -s 192.168.0.0/24 -j ACCEPT
iptables -A INPUT REJECT

iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -s 192.168.0.0/24 -j ACCEPT
iptables -A FORWARD REJECT

Spero di essere stato di aiuto.
Back to top
View user's profile Send private message
OKreZ
Guru
Guru


Joined: 27 Apr 2003
Posts: 372
Location: Padova (IT)

PostPosted: Mon Apr 12, 2004 4:47 pm    Post subject: Re: Problemi connessione..... Reply with quote

HunterD wrote:
[...]ho sul pc due schede di rete ! La prima eth0 192.168.1.1
è collegata al modem , l'altra eth1 192.168.1.3 è collegata al portatile ,(il p
ortatile è 192.168.1.2 .... )

Credo che dare ip della stessa sottoclasse a due schede di rete sullo stesso pc crei problemi, prova ad usare 192.168.0.3 su eth1 (con relative modifiche sul portatile)

EDIT: leggo ora
Code:
 echo "Abilito il forward sulla lan"
iptables -A FORWARD -s 192.168.0.0/24 -j ACCEPT
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

nel tuo caso la riga
Code:
iptables -A FORWARD -s 192.168.0.0/24 -j ACCEPT

diventa
Code:
iptables -A FORWARD -s 192.168.1.0/24 -j ACCEPT

_________________
(HCS)OKreZ
Back to top
View user's profile Send private message
HunterD
Apprentice
Apprentice


Joined: 10 Mar 2004
Posts: 165

PostPosted: Mon Apr 12, 2004 7:15 pm    Post subject: Reply with quote

Dunque ho provato a fare come dice n3mo ma ( a parte che per l'opzione iptables -A INPUT REJECT e iptables -A FORWARD REJECT mi ritorna che reject non è una regola valida.....)
in effetti una volta caricate le regole riesco a pingare da entrambe le parti , ma non riesco a navigare cmq !!! Iptables -L -v mi dà

iptables -L -v
Chain INPUT (policy DROP 73 packets, 3290 bytes)
pkts bytes target prot opt in out source destination
118 56210 ACCEPT all -- any any anywhere anywhere state RELATED,ESTABLISHED
0 0 ACCEPT all -- any any localhost anywhere
11 924 ACCEPT all -- eth1 any 192.168.0.0/24 anywhere

Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- any any anywhere anywhere state RELATED,ESTABLISHED
0 0 ACCEPT all -- any any 192.168.0.0/24 anywhere

Chain OUTPUT (policy ACCEPT 153 packets, 22275 bytes)
pkts bytes target prot opt in out source destination

ho cambiato classe di ip come consigliato adesso eth1 è 192.168.0.3 e sul portatile ho messo 192.168.0.2 .

route sul portatile mi restituisce

route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.0.3 255.255.255.0 UG 0 0 0 eth0
192.168.0.0 * 255.255.255.0 U 0 0 0 eth0
loopback localhost 255.0.0.0 UG 0 0 0 lo

non riesco a pingare nessun host esterno , riesco a raggiungere solo eth1 e localhost quindi nn effettua per niente il forward giusto ??
Idee per risolvere la cosa ?
Back to top
View user's profile Send private message
n3mo
l33t
l33t


Joined: 28 Mar 2004
Posts: 657
Location: In a Cruel World

PostPosted: Tue Apr 13, 2004 7:26 am    Post subject: Reply with quote

Le feste ci hanno davvero annebbiato tutti quanti, il proposito per la prossima pasqua è.........meno spumante.......ricapitolando:

server:

eth0 - 192.168.0.1/255.255.255.0 - interfaccia esterna
eth1 - 192.168.0.3/255.255.255.0 - interfaccia interna

portatile:

eth0 - 192.168.0.2/255.255.255.0

Iptables:

iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT

iptables -A INPUT -s 127.0.0.1 -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i eth1 -s 192.168.0.0/24 -j ACCEPT
iptables -A INPUT -j REJECT

iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -s 192.168.0.0/24 -j ACCEPT
iptables -A FORWARD -j REJECT

iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -d !192.168.0.0/24 -j MASQUERADE

Routing:

server:
echo '1' > /proc/sys/net/ipv4/ip_forward

portatile:
route add default gw 192.168.0.3 netmask 255.255.255.0

Se ancora non funziona prova a postare "iptables -L -n -v" e le tabelle di routing del server e del portatile.
Back to top
View user's profile Send private message
HunterD
Apprentice
Apprentice


Joined: 10 Mar 2004
Posts: 165

PostPosted: Tue Apr 13, 2004 9:16 am    Post subject: Reply with quote

Stà faccenda mi stà facendo diventare matto..... Considerando la cosa a monte ho controllato il kernel per vedere se c'era qualcosa che mancava , ma "dovrebbe" esserci TUTTO e staticamente .

Per n3mo..

iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -d !192.168.0.0/24 -j MASQUERADE

quel punto esclamativo dopo il -d non ci và giusto ?

Cmq ecco il mio iptables -L -n -v

Chain INPUT (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- * * 127.0.0.1 0.0.0.0/0
977 778K ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
11 924 ACCEPT all -- eth1 * 192.168.0.0/24 0.0.0.0/0
127 6594 REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable

Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
0 0 ACCEPT all -- * * 192.168.0.0/24 0.0.0.0/0
0 0 REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable

Chain OUTPUT (policy ACCEPT 1160 packets, 212K bytes)
pkts bytes target prot opt in out source destination

Il route sul server

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.100.1 * 255.255.255.255 UH 0 0 0 ppp0
192.168.0.0 * 255.255.255.0 U 0 0 0 eth1
loopback localhost 255.0.0.0 UG 0 0 0 lo
default 192.168.100.1 0.0.0.0 UG 0 0 0 ppp0

il route del portatile

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.0.3 255.255.255.0 UG 0 0 0 eth0
192.168.0.0 * 255.255.255.0 U 0 0 0 eth0
loopback localhost 255.0.0.0 UG 0 0 0 lo

Riesco a pingare ma navigare zero.... Network unreachable !
L'ip di etho è 192.168.1.1 ma penso proprio che non influisca....

Ps. Giusto per precisare , io stò facendo tutto live , nel senso che sono connesso ad internet e nel frattempo dò tutti i comandi etc. devo forse fare tutto offline ??


Last edited by HunterD on Tue Apr 13, 2004 9:20 am; edited 1 time in total
Back to top
View user's profile Send private message
OKreZ
Guru
Guru


Joined: 27 Apr 2003
Posts: 372
Location: Padova (IT)

PostPosted: Tue Apr 13, 2004 9:18 am    Post subject: Reply with quote

Sicuro che nel portatile hai specificato dei server dns validi in /etc/resolv.conf ?
_________________
(HCS)OKreZ
Back to top
View user's profile Send private message
HunterD
Apprentice
Apprentice


Joined: 10 Mar 2004
Posts: 165

PostPosted: Tue Apr 13, 2004 9:23 am    Post subject: Reply with quote

Si sono validi , sono gli stessi che stò usando sul server !! Infatti visto che un ping su google mi ritorna unknowhost ho provato a pingare proprio il dns ma... Network unreahable !!
Back to top
View user's profile Send private message
HunterD
Apprentice
Apprentice


Joined: 10 Mar 2004
Posts: 165

PostPosted: Tue Apr 13, 2004 8:25 pm    Post subject: Reply with quote

C'è nessuno che può darmi una mano a capire perchè non funge ??

Mi sà che dovrò stamparmi il manuale di iptables fra un pò..... :cry:
Back to top
View user's profile Send private message
OKreZ
Guru
Guru


Joined: 27 Apr 2003
Posts: 372
Location: Padova (IT)

PostPosted: Tue Apr 13, 2004 9:13 pm    Post subject: Reply with quote

prova a vedere qui
_________________
(HCS)OKreZ
Back to top
View user's profile Send private message
koma
Advocate
Advocate


Joined: 06 Jun 2003
Posts: 2702
Location: Italy

PostPosted: Tue Apr 13, 2004 9:15 pm    Post subject: Reply with quote

Code:
# Location in which iptables initscript will save set rules on
# service shutdown
IPTABLES_SAVE="/var/lib/iptables/rules-save"

# Change to "yes" to enable forwarding support in the kernel.  Please
# note that this will override any setting placed in /etc/sysctl.conf.
ENABLE_FORWARDING_IPv4="yes"

#Options to pass to iptables-save and iptables-restore
SAVE_RESTORE_OPTIONS="-c"
iptables -t nat -A POSTROUTING -s 10.5.0.5/32 -o eth0 -j MASQUERADE
la mia configuraizone è così :)
_________________
http://www.youtube.com/watch?v=_yoJI-Tl94g GLORY GLORY HYPNOTOAD
Back to top
View user's profile Send private message
n3mo
l33t
l33t


Joined: 28 Mar 2004
Posts: 657
Location: In a Cruel World

PostPosted: Wed Apr 14, 2004 3:43 pm    Post subject: Reply with quote

Il ! lo devi mettere, significa diverso:

traduco:
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -d !192.168.0.0/24 -j MASQUERADE
iptables tabella "nat" aggiungi POSTROUTING sorgente 192.168.0.0./24 con destinazione diversa da 192.168.0.0/24 fai il MASQUERADE.

:)
Back to top
View user's profile Send private message
HunterD
Apprentice
Apprentice


Joined: 10 Mar 2004
Posts: 165

PostPosted: Wed Apr 14, 2004 10:27 pm    Post subject: Reply with quote

Quote:

Il ! lo devi mettere, significa diverso:


Alt un attimo deve essere per forza !192.168.0.0/24 o lo becca anche staccato ! 192.168....

perchè mi succede una cosa assurda !!! con qualsiasi console ( xterm , konsole etc... ) il !192.
me lo tramuta nell'ultimo comando rimasto in cache !!!! Piccolo esempio

iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -d !192.168.0.0/24 -j MASQUERADE
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -d lsmod.168.0.0/24 -j MASQUERADE
iptables v1.2.9: host/network `lsmod.168.0.0' not found
Try `iptables -h' or 'iptables --help' for more information.

In questo caso per magia è diventato lsmod !!!

Stò veramente raggiungendo il limite !!!!

Altra cosa ho notato che in /etc/init.d/ c'è un servizio iptables... devo forse controllare qualcosa riguardo questo script ??
Back to top
View user's profile Send private message
motaboy
Retired Dev
Retired Dev


Joined: 15 Dec 2003
Posts: 1483

PostPosted: Wed Apr 14, 2004 11:33 pm    Post subject: Reply with quote

Non è una cosa assurda, è una funzionalità della bash.

con "!" ripeti l'ultimo comando eseguito che inizia con quella lettera.

o nel caso di un numero di ripete l'n-simo comando.

Nel tuo caso !192 era lsmod...

Metti una slash davanti al !

Code:

iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -d \!192.168.0.0/24 -j MASQUERADE


Bye!
_________________
...
Back to top
View user's profile Send private message
randomaze
Bodhisattva
Bodhisattva


Joined: 21 Oct 2003
Posts: 9985

PostPosted: Thu Apr 15, 2004 7:50 am    Post subject: Reply with quote

motaboy wrote:
Non è una cosa assurda, è una funzionalità della bash.

con "!" ripeti l'ultimo comando eseguito che inizia con quella lettera.

o nel caso di un numero di ripete l'n-simo comando.

Nel tuo caso !192 era lsmod...


La feature dovrebbe essere disabilitabile con:
Code:

$set +H

;-)
_________________
Ciao da me!
Back to top
View user's profile Send private message
HunterD
Apprentice
Apprentice


Joined: 10 Mar 2004
Posts: 165

PostPosted: Thu Apr 15, 2004 8:42 am    Post subject: Reply with quote

Finaaaaalmenteeeeee ci sono riuscito !!! Mi è stato molto utile questo post

https://forums.gentoo.org/viewtopic.php?t=159133&highlight=iptables+nat

Non ci speravo veramente più ! Grazie a tutti per il supporto
:wink:
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) 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