Discussione:Rete del GOLEM

Da GolemWiki.
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Vecchie configurazioni

Proxy+cacher

La configurazione è spiegata alla pagina Apt-cacher. Si usa il solo squid per la cache e netmasq come DHCP server (e server DNS) anziché dhcpd.

A titolo di reference si riportano i files di configurazione di rilievo, privati dei commenti e già adattati alla presenza della rete wireless condivisa:

squid - /etc/squid3/squid.conf

acl SSL_ports port 443
acl Safe_ports port 80          # http
acl Safe_ports port 21          # ftp
acl Safe_ports port 443         # https
acl Safe_ports port 70          # gopher
acl Safe_ports port 210         # wais
acl Safe_ports port 1025-65535  # unregistered ports
acl Safe_ports port 280         # http-mgmt
acl Safe_ports port 488         # gss-http
acl Safe_ports port 591         # filemaker
acl Safe_ports port 777         # multiling http
acl CONNECT method CONNECT
acl our_networks src 192.168.xx.0/24
http_access allow our_networks
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost manager
http_access deny manager
http_access allow localhost
http_access deny all
http_port 192.168.xx.yy:3128 transparent
maximum_object_size 400 MB
cache_dir ufs /var/spool/squid3 60000 16 256
coredump_dir /var/spool/squid3
refresh_pattern deb$            1576800 100%    1576800
refresh_pattern Packages.gz$    1440    100%    1440
refresh_pattern pkg.tar.xz$     43200   100%    43200
refresh_pattern ^ftp:           1440    20%     10080
refresh_pattern ^gopher:        1440    0%      1440
refresh_pattern -i (/cgi-bin/|\?) 0     0%      0
refresh_pattern .               360     20%     4320
dnsmasq - /etc/dnsmasq.conf

domain-needed
bogus-priv
interface=br0
dhcp-range=192.168.xx.101,192.168.xx.254,12h
script iptables

#!/bin/sh

# IP dello Squid server
SQUID_SERVER="192.168.xx.yy"

# Interface connected to Internet
INTERNET="ethE"

# Interface connected to LAN
LAN_IN="br0"

# Squid port
SQUID_PORT="3128"

# Clean old firewall
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X

# Load IPTABLES modules for NAT and IP conntrack support
modprobe ip_tables
modprobe ip_conntrack
modprobe iptable_nat
modprobe ipt_MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward

# Set this system as a router for Rest of LAN
iptables -t nat -A POSTROUTING -o $INTERNET -j MASQUERADE

# DNAT port 80 request coming from LAN to ( $SQUID_PORT ), aka transparent proxy
iptables -t nat -A PREROUTING -i $LAN_IN -p tcp --dport 80 -j DNAT --to $SQUID_SERVER:$SQUID_PORT
iptables -t nat -A PREROUTING -i $INTERNET -p tcp --dport 80 -j REDIRECT --to-port $SQUID_PORT

Sostituire con xx ed yy i parametri di rete corretti.

Condivisione rete Wireless

Per impostare la scheda WiFi in modalità Access Point si fa uso di hostapd. Prima di tutto bisogna verificare se la scheda di rete supporta tale modalità

# iw list

Supported interface modes:
    * IBSS
    * managed
    * AP                 <===
    * AP/VLAN
    * WDS
    * monitor
    * mesh point

La scheda wireless deve essere esattamente al pari dell'interfaccia ethernet interna (ethI), dunque si legano entrambe in un bridge. In questo modo entrambi i devices saranno visti da squid, iptables, etc.. come un singolo oggetto.

# nano /etc/network/interfaces

# Interfaccia di rete esterna
allow-hotplug ethE
auto ethE
iface ethE inet dhcp

# Interfaccia di rete interna al GOLEM
allow-hotplug ethI
auto ethI
iface ethI inet static
        address 0.0.0.0

# Ponte/Bridge per il WiFi
auto br0
iface br0 inet static
        address 192.168.xx.yy
        netmask 255.255.255.0
        bridge_ports ethI

Naturalmente in luogo di address 192.168.xx.yy dovrà essere posto l'IP statico del server. Non si inserisce qui l'interfaccia wireless perché sarà hostapd a fare i dovuti settaggi e ad aggiungerla al bridge, operando come segue:

# nano /etc/hostapd/hostapd.conf

# Interfaccia di rete
interface=wlan0
driver=nl80211

# Nome della rete (SSID)
ssid=GOLEM-WiFi
hw_mode=g

# Canale di trasmissione
channel=6
macaddr_acl=0

# Righe per la protezione
auth_algs=1
ignore_broadcast_ssid=0
wpa=2

# Password del WiFi
wpa_passphrase=password

wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

# aggiunge l'interfaccia al bridge
bridge=br0