[Linuxtrent] NAT, funzia :) !!!!!

  • From: neugens <neugens@xxxxxxxxx>
  • To: linuxtrent@xxxxxxxxxxxxx
  • Date: Fri, 26 Apr 2002 14:00:36 +0200

Ciao!

Ringrazio vivamente chi mi ha aiutato!

Lo scriptino che ho usato per settare il firewall e' questo:

---------------------------- cut -----------------------
#!/bin/sh
# rules to setup a simple firewall for the local network
# where is ipchains?
IPCHAINS=/sbin/ipchains
# input interface
INTIF="eth1"
# output interface
EXTIF="ppp0"
# internal network id
INTNET="192.168.0.0/24"
# all ip addresses
ANY="0.0.0.0/0"
# enable ip forwarding
echo "1" > /proc/sys/net/ipv4/ip_forward
# setup the basic here
$IPCHAINS -P input ACCEPT
$IPCHAINS -P forward MASQ
$IPCHAINS -P output ACCEPT
$IPCHAINS -F
$IPCHAINS -X
# create a chain for the icmp normal traffic.
$IPCHAINS -N icmp-acc
# common ICMP messages, we accept all them
$IPCHAINS -A icmp-acc -p icmp --icmp-type destination-unreachable -j ACCEPT
$IPCHAINS -A icmp-acc -p icmp --icmp-type source-quench -j ACCEPT
$IPCHAINS -A icmp-acc -p icmp --icmp-type time-exceeded -j ACCEPT
$IPCHAINS -A icmp-acc -p icmp --icmp-type parameter-problem -j ACCEPT
# forward
$IPCHAINS -A forward -s $INTNET -d $INTNET -i $INTIF -j ACCEPT
$IPCHAINS -A forward -s $INTNET -d $ANY -i $EXTIF -j MASQ
# input
$IPCHAINS -A input -s 0/0 -d 0/0 -i lo -j ACCEPT
$IPCHAINS -A input -p tcp -y -s ! $INTNET -d $INTNET -i $EXTIF -j DENY
$IPCHAINS -A input -p tcp -s ! $INTNET -d 0/0 0:1023 -y -j DENY
$IPCHAINS -A input -p tcp -s ! $INTNET -d 0/0 2049 -y -j REJECT
$IPCHAINS -A input -p udp -s ! $INTNET -d 0/0 0:1023 -j REJECT
$IPCHAINS -A input -p udp -s ! $INTNET -d 0/0 2049 -j REJECT
$IPCHAINS -A input -p tcp -s ! $INTNET -d 0/0 6000:6009 -y -j REJECT
$IPCHAINS -A input -p tcp -s ! $INTNET -d 0/0 7100 -y -j REJECT
$IPCHAINS -A input -p tcp -s ! $INTNET -d 0/0 8100 -y -j REJECT
# output rules
$IPCHAINS -A output -s $INTNET -d $ANY -i $INTIF -j ACCEPT
$IPCHAINS -A output -s $INTNET -d $ANY -i $EXTIF -j ACCEPT
------------------------------ cut ---------------------------------

Dalle prime analisi, sembra fare tutto quello che mi serve: accesso a tutti 
dalla rete interna all'esterno, e tra gli host della rete interna. Negazione 
di ogni accesso dall'esterno sulle porte tipicamente riservate ai servizi.
Non blocco tutte le porte per permettere cose tipo realplayer etc..

I test effettuati sono tutti di questo tipo:

# /sbin/ipchains -C input -s 151.42.188.149 5000 -p tcp -y
        -d 192.168.0.0 www -i ppp0
denied
# /sbin/ipchains -C input -s 192.168.0.0 8000 -p tcp -y
        -d 192.168.0.0 www -i eth1
accepted

etc...

Spero possa essere di aiuto a qualcuno, ovviamente, se avete suggerimenti, 
e/o se trovate errori, vi prego di scrivermi! :)

Ah, dimenticavo.

Ho trovato utile settare le mtu delle schede di rete in questo modo:

linux eth1 -> 1452
win2k/linux -> 1412

Questo mi ha evitato dei problemi di frammentazione.

Nel kernel 2.2 c'e' la variabile ip_always_defrag, ma nel kernel 2.4 non sono 
riuscito a trovarla. Mica sapete se e' stata sostituita e da cosa?

Oppure se c'e' un motivo valido per non usarla?

Ciao a tutti e grazie di nuovo,
Mario
-- 
Please avoid sending me Word or PowerPoint attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html
-- 
PROSSIMA ASSEMBLEA: lunedi 29 Aprile 2002 ore 20:45
Per iscriversi  (o disiscriversi), basta spedire un  messaggio con SOGGETTO
"subscribe" (o "unsubscribe") a mailto:linuxtrent-request@xxxxxxxxxxxxxxxxx


Other related posts: