Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Configurazione IP-Tables (principiante!!!) [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
gibbs
n00b
n00b


Joined: 12 Jul 2004
Posts: 7
Location: Torino

PostPosted: Mon Jan 31, 2005 5:32 pm    Post subject: Configurazione IP-Tables (principiante!!!) [RISOLTO] Reply with quote

Scusate se propongo un argomento visto e stravisto.
Ho letto i manuali e diversi suggerimenti nei forum, ma non riesco a venirne fuori. Ho bisogno di attivare un proxy per connettere un pc portatile ad Internet. Sul server (nome ciccio) ho un kernel 2.6.9 e sul client il 2.6.8 con yoper (nome mitac6120). Ho compilato il kernel con il supporto ip_tables ed il caricamento dei moduli funziona in modo eccellente. Sul server ho 3 schede di rete:
eth0 - connessa a internet,
eth1 - connessa ad un pc fisso che ha una connessione diretta ad internet,
eth2 - connessa al portatile.
Ho anche installato un server DHCP sul server, eth2 ha IP statico 192.168.0.1 ed il client ha IP 192.168.0.249. Per ip_tables ho dato la seguente serie di comandi:
Code:

# iptables -F
# iptables -X
# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
# iptables -A FORWARD -i eth2 -o eth0 -m state --state NEW,ESTABLISHED -j ACCEPT
# iptables -A INPUT --protocol tcp --dport 22 -j ACCEPT
# iptables -A INPUT --protocol tcp --dport 80 -j ACCEPT
# iptables -A INPUT -i eth0 -m state --state NEW,INVALID -j DROP
# iptables -A FORWARD -i eth0 -m state --state NEW,INVALID -j DROP

prelevati da un ottimo howto per principianti.
La conclusione è che i due pc comunicano perfettamente con SSH e con FISH di Konqueror, ma non riesco assolutamente ad accedere ai siti. Se do: ping google.it mi dice server unknown.
Dando il comando:
Code:
ciccio root #  iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ssh
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:www
DROP       all  --  anywhere             anywhere            state INVALID,NEW

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere            state NEW,ESTABLISHED
DROP       all  --  anywhere             anywhere            state INVALID,NEW

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination


Se do:
Code:
ciccio root # route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 eth2
192.168.10.0    0.0.0.0         255.255.255.0   U     0      0        0 eth1
41.255.40.0     0.0.0.0         255.255.248.0   U     0      0        0 eth0
127.0.0.0       127.0.0.1       255.0.0.0       UG    0      0        0 lo
0.0.0.0         41.255.40.1     0.0.0.0         UG    0      0        0 eth0


Qualcuno ha voglia e pazienza per aiutarmi?
Scusate se disturbo e se mancano alcune informazioni, ma le posso dare tranquillamente se mi indicate quanto necessario.
Un caro saluto e grazie :lol:


Last edited by gibbs on Wed Feb 02, 2005 2:36 pm; edited 1 time in total
Back to top
View user's profile Send private message
Manuelixm
l33t
l33t


Joined: 03 Apr 2004
Posts: 832
Location: Brescia

PostPosted: Mon Jan 31, 2005 5:52 pm    Post subject: Reply with quote

Hai provato a fare una ricerca sul forum? Al massimo fai un giro qui:
www.netfilter.org
_________________
Linux user#370732
Back to top
View user's profile Send private message
gibbs
n00b
n00b


Joined: 12 Jul 2004
Posts: 7
Location: Torino

PostPosted: Mon Jan 31, 2005 6:28 pm    Post subject: Reply with quote

Grazie del consiglio. In effeti sto già studiandomi i documenti del forum e la documentazione generale presente nel sito netfilter.
Back to top
View user's profile Send private message
lan
Apprentice
Apprentice


Joined: 06 Mar 2004
Posts: 215
Location: Verona, Italy (Romeo & juliet`s City)

PostPosted: Mon Jan 31, 2005 6:47 pm    Post subject: Reply with quote

a prima vista mi pare ti machi un bel RELATED quando specifichi uno stato...
comunque questa guida è molto buona http://www.commedia.it/ccontavalli/docs-it/iptables/iptables4dummies/iptables4dummies.html

salta la prima parte e vai subito a iptables


Ciao
_________________
--
http://www.giuseppe-marocchio.com
skype: l4nz0r /voice
USH team www.ush.it
Back to top
View user's profile Send private message
FonderiaDigitale
Veteran
Veteran


Joined: 06 Nov 2003
Posts: 1710
Location: Rome, Italy

PostPosted: Tue Feb 01, 2005 2:19 am    Post subject: Re: Configurazione IP-Tables (principiante!!!) Reply with quote

gibbs wrote:

Code:

# iptables -F
# iptables -X
# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
# iptables -A FORWARD -i eth2 -o eth0 -m state --state NEW,ESTABLISHED -j ACCEPT
# iptables -A INPUT --protocol tcp --dport 22 -j ACCEPT
# iptables -A INPUT --protocol tcp --dport 80 -j ACCEPT
# iptables -A INPUT -i eth0 -m state --state NEW,INVALID -j DROP
# iptables -A FORWARD -i eth0 -m state --state NEW,INVALID -j DROP

prelevati da un ottimo howto per principianti.
La conclusione è che i due pc comunicano perfettamente con SSH e con FISH di Konqueror, ma non riesco assolutamente ad accedere ai siti. Se do: ping google.it mi dice server unknown.


dovresti avere problemi di dns.
la prima prova da fare e' pingare un ip statico pubblico, ad es. 62.94.0.2.
inoltre controlla il forwarding:
Code:
# sysctl -w net.ipv4.ip_forward=1

inoltre questa regola:
Code:
# iptables -A FORWARD -i eth2 -o eth0 -m state --state NEW,ESTABLISHED -j ACCEPT

cosi messa e' inutile; ci sono due opzioni:
a. se ti preme la sicurezza, limita le porte in uscita e accetta le connessioni dalla tua lan gia intraprese (parti dal presupposto che la tua lan non sia sicura, pensa ai vari sasser e blaster) e da porte dinamiche valide per il range specificato nel kernel:
Code:
#!/bin/sh
portrange=(`cat /proc/sys/net/ipv4/ip_local_port_range`)
portrange="${portange[0]}:${portrange[1]}"
modprobe ip_conntrack*
iptables -A FORWARD -i eth2 -s 192.168.0.249 -o eth0 -m state --state NEW -p tcp --sport ${portrange} --dport ssh,www,pop3,pop3s,smtp,smtpsrsync -j ACCEPT
iptables -A FORWARD -i eth2 -s 192.168.0.249 ! -d 192.168.0.0/24 -o eth0 -m state --state NEW -p udp --sport ${portrange} --dport domain -j ACCEPT
iptables -A FORWARD -i eth0 -d 192.168.0.249  ! -s 192.168.0.0/24 -o eth2 -m state --state RELATED,ESTABLISHED -j ACCEPT

b. se non sei cosi paranoico (come me :roll: ) questa cambia le regole di iptables sopra con:
Code:

iptables -A FORWARD -i eth2 -s 192.168.0.0/24 -o eth0 -m state --state NEW  -j ACCEPT
iptables -A FORWARD -i eth0 -d 192.168.0.0/24 -o eth2 -m state --state RELATED,ESTABLISHED -j ACCEPT

considera anche la possibilta' di installare una cache interna, ad esempio con dnscache (pacchetto djbdns).

ciao
_________________
Come disse un amico, i sistemisti sono un po' come gli artigiani per l'informatica :)
Back to top
View user's profile Send private message
seryna
n00b
n00b


Joined: 27 Jan 2005
Posts: 36

PostPosted: Tue Feb 01, 2005 11:10 am    Post subject: Reply with quote

C'è un programma che si chiama Firewall Builder che ha una facile interfaccia grafica. Cerca su internet come scaricarlo. E' davvero utile.
Back to top
View user's profile Send private message
dboogieman
Apprentice
Apprentice


Joined: 02 Oct 2004
Posts: 197

PostPosted: Tue Feb 01, 2005 11:29 am    Post subject: Reply with quote

Ciao verifica la risoluzione dei nomi come ti hanno giustamente consigliato, in particolare visto che hai un dhcp server devi verificare in:

Code:

#/etc/dhcp/dhcpd.conf

la presenza di un name server che verra' utilizzato dai dhcp client, in secondo luogo vedo che ti consigliano di vericare il forward, allora assicurati che sulla macchina con iptables tu abbia settato

Code:

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

con la relativa regola di NAT gia' settata. Ho scritto tutto cio' ipotizzando che tu abbia a disposizione dal tuo ISP un solo IP pubblico e tu voglia far navigare i PC della tua LAN.
Spero possa esserti utile

Ciao

dboogieman
Back to top
View user's profile Send private message
gibbs
n00b
n00b


Joined: 12 Jul 2004
Posts: 7
Location: Torino

PostPosted: Tue Feb 01, 2005 7:36 pm    Post subject: Reply with quote

Innanzi tutto un ringraziamento a tutti voi

Ho provato quanto suggerito (Fonderia Digitale).
Code:
Andando con ordine, effettivamente dando il ping dell?IP statico proposto il portatile riesce effettivamentea pingare.
Ho controllato con:
ciccio root # sysctl -w net.ipv4.ip_forward=1
net.ipv4.ip_forward = 1

risultato che mi pare soddisfacente.
Poi ho cambiato
Code:
# iptables -A FORWARD -i eth2 -o eth0 -m state --state NEW,ESTABLISHED -j ACCEPT  -----»»  inutile da modificare

in:
# iptables -A FORWARD -i eth2 -s 192.168.0.0/24 -o eth0 -m state --state NEW  -j ACCEPT
# iptables -A FORWARD -i eth0 -d 192.168.0.0/24 -o eth2 -m state --state RELATED,ESTABLISHED -j ACCEPT

ed ha preso tutti i comandi senza errori.
Il problema del collegamento ai siti comunque resta.


Mi sto domandando se il fatto di essere connesso a Fastweb possa causare problemi di DNS.
Per quanto concerne il file di configurazione del server DHCP, esso è:

Code:
# dhcpd.conf
#
# Configuration file for ISC dhcpd (see 'man dhcpd.conf')
#
#Here is a sample configuration file:
authoritative;
ddns-update-style ad-hoc;
subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.100 192.168.0.250;
default-lease-time 259200;
max-lease-time 518400;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.0.255;
option routers 192.168.0.1;
option domain-name-servers 192.168.0.1;
option domain-name "ciccio";
# option domain-name-servers 62.101.66.80;
# option domain-name "fastwebnet.it";
}


Qualcuno ha altri suggerimenti?
Un grazie anticipato e saluti cari.
P.S. Do anche i risultati dei comandi iptables -L e route -n:

Code:
ciccio root #   iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ssh
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:www
DROP       all  --  anywhere             anywhere            state INVALID,NEW

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

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
--------------------------------------------------------------------------------------------------------
ciccio root # route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 eth2
192.168.10.0    0.0.0.0         255.255.255.0   U     0      0        0 eth1
41.255.40.0     0.0.0.0         255.255.248.0   U     0      0        0 eth0
127.0.0.0       127.0.0.1       255.0.0.0       UG    0      0        0 lo
0.0.0.0         41.255.40.1     0.0.0.0         UG    0      0        0 eth0
ciccio root #                   
Back to top
View user's profile Send private message
FonderiaDigitale
Veteran
Veteran


Joined: 06 Nov 2003
Posts: 1710
Location: Rome, Italy

PostPosted: Wed Feb 02, 2005 2:35 am    Post subject: Reply with quote

Code:
option domain-name-servers 192.168.0.1;

a questo indirizzo corrisponde un server dns che funzioni come recurser per i client (ovvero ci possono fare le query)? altrimenti devi mettere i dns che ti assegna fastweb, uno per riga.
_________________
Come disse un amico, i sistemisti sono un po' come gli artigiani per l'informatica :)
Back to top
View user's profile Send private message
gibbs
n00b
n00b


Joined: 12 Jul 2004
Posts: 7
Location: Torino

PostPosted: Wed Feb 02, 2005 1:38 pm    Post subject: Reply with quote

RISOLTO
:lol:

Grazie Fonderia, in effetti bastava sostituire i DNS di Fastweb in dhcpd.conf e voilà.
MAGIA!!

Mi potete dire come si deve comunicare il fatto che il problema è stato risolto?

A risentirci...
Back to top
View user's profile Send private message
realthing
Apprentice
Apprentice


Joined: 29 Jul 2003
Posts: 163
Location: Milano, Italy

PostPosted: Wed Feb 02, 2005 1:41 pm    Post subject: Reply with quote

Basta che editi il titolo del treadh e ci aggiungi [RISOLTO]

:)
Back to top
View user's profile Send private message
koma
Advocate
Advocate


Joined: 06 Jun 2003
Posts: 2702
Location: Italy

PostPosted: Wed Feb 02, 2005 1:41 pm    Post subject: Reply with quote

gibbs tu sei di torino e socmmetto anche della mia zona a vedere il tuo GW per fastweb ;)
_________________
http://www.youtube.com/watch?v=_yoJI-Tl94g GLORY GLORY HYPNOTOAD
Back to top
View user's profile Send private message
gibbs
n00b
n00b


Joined: 12 Jul 2004
Posts: 7
Location: Torino

PostPosted: Wed Feb 02, 2005 2:22 pm    Post subject: Reply with quote

Non riesco a modificare il titolo, potete dirmi come si fa in dettaglio?
Scusate sono proprio un novellino.
Per koma: abito a Torino vicino a Stazione Dora, se fossimo vicini sarebbe un'ottima cosa.
Posso contattarti con GAIM / Jabber? Ho parecchie cose che mi danno problemi in linux e sono una specie di apprendista stregone.
Back to top
View user's profile Send private message
mouser
Veteran
Veteran


Joined: 10 Aug 2004
Posts: 1419
Location: Milano

PostPosted: Wed Feb 02, 2005 2:32 pm    Post subject: Reply with quote

gibbs wrote:
Non riesco a modificare il titolo, potete dirmi come si fa in dettaglio?
Scusate sono proprio un novellino.

Basta che vai sul tuo primo post e, in alto a destra del messaggio c'e' un pulsante "Edit". Fai click e modifichi il titolo :D

Ciriciao
mouser :wink:
Back to top
View user's profile Send private message
gibbs
n00b
n00b


Joined: 12 Jul 2004
Posts: 7
Location: Torino

PostPosted: Wed Feb 02, 2005 2:38 pm    Post subject: Reply with quote

Fatto, grazie mouser
:o CIAO
Back to top
View user's profile Send private message
FonderiaDigitale
Veteran
Veteran


Joined: 06 Nov 2003
Posts: 1710
Location: Rome, Italy

PostPosted: Wed Feb 02, 2005 10:51 pm    Post subject: Reply with quote

apposto 8)
_________________
Come disse un amico, i sistemisti sono un po' come gli artigiani per l'informatica :)
Back to top
View user's profile Send private message
gibbs
n00b
n00b


Joined: 12 Jul 2004
Posts: 7
Location: Torino

PostPosted: Wed Feb 02, 2005 11:31 pm    Post subject: Reply with quote

Per Fonderia Digitale, ti ringrazio dell'aiuto. Probabilmente ci si rivedrà nel forum, ho ancora parecchie cose da sistemare.
A presto
GIBBS
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