Esperienza su firewall LEAF/Bering uClibc con DMZ ("a tre interfacce") |
|
|
|
Per la realizzazione di questo modulo useremo
Netkit4TIC
con la
connettività
con la rete reale (leggere il file README).
Riportiamo la mappa (pdf, xml) della rete dell'esperienza. Lo schema di numerazione è conforme alla proposta di numerazione presentata in Numerazione Aree dove per l'area interna e per l'area perimetrale abbiamo adottato la numerazione riportata come "area backbone".
In questa esercitazione sono configurati i seguenti nodi:
services con:
tic.fdns.net e net.fdns.netproxy:
Scarica il tarball contenente lo script che genera l'intera esercitazione:
realhost$ lstart
La policy che abbiamo scelto:
# /etc/shorewall/policy #SOURCE DEST POLICY LOG LEVEL loc net ACCEPT net all DROP info all all REJECT info
Le eccezioni alla policy:
# /etc/shorewall/rules #ACTION SOURCE DEST DNS/ACCEPT fw net DNS/ACCEPT dmz net # # Forward the request to 192.168.1.222 in DMZ # DNS/DNAT net dmz:192.168.1.222 Web/DNAT net dmz:192.168.1.222 # # To manage fw from loc network # SNMP/ACCEPT loc fw
Proviamo a vedere quali porte sono aperte dal lato Internet:
router-ext# nmap 80.204.240.182 -p 1-200
Starting nmap 3.75 ( http://www.insecure.org/nmap/ ) at 2005-05-29 19:31 CEST
Interesting ports on ns1.tic.fdns.net (80.204.240.182):
(The 1661 ports scanned but not shown below are in state: filtered)
PORT STATE SERVICE
53/tcp open domain
80/tcp open http
113/tcp closed auth
MAC Address: FE:FD:50:CC:F0:B6 (Unknown)
Nmap run completed -- 1 IP address (1 host up) scanned in 37.089 seconds
Proviamo la risoluzione dei nomi da Internet:
router-ext# host www.tic.fdns.net
www.tic.fdns.net is an alias for ns1.tic.fdns.net.
ns1.tic.fdns.net has address 80.204.240.182
e ora proviamo l'accesso WEB da Internet:
roter-ext# lynx -dump http://www.tic.fdns.net | strings
Benvenuto 80.204.240.177 su www.tic.fdns.net
Stessa cosa per l'accesso WEB dalla rete locale:
aclnt# lynx -dump http://www.tic.fdns.net | strings
Benvenuto 192.168.2.221 su www.tic.fdns.net
È possibile anche interrogare l'agente SNMP configurato nel firewall. Ad esempio per conoscere il nome della quarta interfaccia di rete del firewall:
aclnt# snmpwalk -Os -c public -v 1 192.168.2.254 \
.iso.org.dod.internet.mgmt.mib-2.interfaces.ifTable.ifEntry.ifDescr.5
ifDescr.5 = STRING: eth1
L'agent SNMP in combinazione con mrtg possono essere
impiegati per la raccolta di statistiche sullo stato degli apparati.
Nel nostro caso abbiamo configurato tramite il cron
la raccolta ogni 5 minuti del traffico sulle tre interfacce di rete
del firewall. È possibile osservare i grafici statistici
anche da un browser della macchina reale:
realHost$ mozilla-firefox http://192.168.77.2/mrtg/firewall.eth{0,1,2}.html
Per l'uso del proxy si può forzarne l'uso impedendo qualsiasi uso di intenet/dmz da parte di nodi locali:
# /etc/shorewall/policy #SOURCE DEST POLICY LOG LEVEL LIMIT:BURSTloc net ACCEPTloc dmz ACCEPTloc net DROP info loc dmz DROP info
e permettere l'uscita al solo nodo proxy:
# /etc/shorewall/rules #ACTION SOURCE DESTWeb/ACCEPT loc netWeb/ACCEPT loc dmzWeb/ACCEPT loc:192.168.2.222 net Web/ACCEPT loc:192.168.2.222 dmz
Facciamo ripartire shorewall:
fw# /etc/init.d/shorewall restart
Ora riproviamo impostando il proxy:
aclnt# export http_proxy="http://192.168.2.222:8080/"
aclnt# lynx -dump http://www.tic.fdns.net | strings
Benvenuto 192.168.2.222 su www.tic.fdns.net
Configurazione apache virtual host |
|
Per verificare la risoluzione dei nomi basta provare:
router-ext# host www.tic.fdns.net www.tic.fdns.net is an alias for ns1.tic.fdns.net. ns1.tic.fdns.net has address 80.204.240.182 router-ext# host www.net.fdns.net www.net.fdns.net is an alias for ns1.net.fdns.net. ns1.net.fdns.net has address 80.204.240.182 aclnt# host www.tic.fdns.net www.tic.fdns.net is an alias for ns1.tic.fdns.net. ns1.tic.fdns.net has address 192.168.1.102 aclnt# host www.net.fdns.net www.net.fdns.net is an alias for ns1.net.fdns.net. ns1.net.fdns.net has address 192.168.1.102
Nello stesso nodo è configurato un server WEB apache con il sistema di "virtual host" che permette di configurare un server virtuale per dominio. Nel file di configurazione abbiamo usato:
# /etc/apache/httpd.conf
[...]
NameVirtualHost *
<VirtualHost *>
ServerName www.tic.fdns.net
DocumentRoot /var/www/tic
ErrorLog /var/log/apache/tic-error.log
CustomLog /var/log/apache/tic-access.log combined
<VirtualHost>
<VirtualHost *>
ServerName www.net.fdns.net
DocumentRoot /var/www/net
ErrorLog /var/log/apache/net-error.log
CustomLog /var/log/apache/net-access.log combined
<VirtualHost>
Abbiamo preparato un file index.php con il seguente contenuto:
[...] <?php echo "<p> Benvenuto $REMOTE_ADDR su $HTTP_HOST </p>"; ?> [...]
e lo abbiamo inserito sia sulla directory
/var/www/tic che sulla directory /var/www/net.
In questo modo per testare se il virtual host funziona basta fare un
accesso dall'interno o dall'esterno:
router-ext# lynx -dump http://www.tic.fdns.net/index.php | strings Benvenuto 80.204.240.177 su www.tic.fdns.net router-ext# lynx -dump http://www.net.fdns.net/index.php | strings Benvenuto 80.204.240.177 su www.net.fdns.net aclnt# lynx -dump http://www.tic.fdns.net/index.php | strings Benvenuto 192.168.2.221 su www.tic.fdns.net aclnt# lynx -dump http://www.net.fdns.net/index.php | strings Benvenuto 192.168.2.221 su www.net.fdns.net
|
|
Sandro Doro (email me)