squid 2netkapcsolat
A probléma:
Adott egy linux szerver:
debian 5.0
squid 3.0 (csomagból)
4db hálózati kártya (2db külső, 2 db belső)
eth0 ip: 195.199.2.2
mask: 255.255.255.0
gw: 195.199.2.1
eth1 ip: 195.199.1.2
mask: 255.255.255.0
gw: 195.199.1.1
eth2 ip: 192.168.1.1
mask: 255.255.255.0
eth3 ip: 192.168.2.1
mask: 255.255.255.0
Azt szeretném, hogy az eth2-es kártya az eth0-s kártyán, az eth3-as kártya az eth1-es kártyán kommunikáljon. Ez működik is proxy nélkül(tracert helyes, ping megy) az alábbi route/iptables szabályokkal.
route:
ip route add default via 195.199.1.1 dev eth0 table 2
ip route add default via 195.199.2.1 dev eth1 table 3
ip rule add from 192.168.1.0/24 dev eth2 table 2 pri 33
ip rule add from 192.168.2.0/24 dev eth3 table 3 pri 33
tuzfal:
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -F INPUT
iptables -F OUTPUT
iptables -F FORWARD
iptables -t nat -F PREROUTING
iptables -t nat -F POSTROUTING
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
iptables -A INPUT -d 127.0.0.1 -j ACCEPT
iptables -A OUTPUT -s 127.0.0.1 -j ACCEPT
iptables -A INPUT -s 192.168.1.0/24 -i eth2 -j ACCEPT
iptables -A OUTPUT -d 192.168.1.0/24 -o eth2 -j ACCEPT
iptables -A INPUT -s 192.168.2.0/24 -i eth3 -j ACCEPT
iptables -A OUTPUT -d 192.168.2.0/24 -o eth3 -j ACCEPT
#SNAT beallitasok
iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth0 -j SNAT --to 195.199.1.2
#sulinet1-tanar
iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -o eth1 -j SNAT --to 195.199.2.2
#transparent proxy
#iptables -t nat -A PREROUTING -i eth2 -p tcp -m tcp --dport 80 -j DNAT --to-destination 192.168.1.1:3128
#iptables -t nat -A PREROUTING -i eth3 -p tcp -m tcp --dport 80 -j DNAT --to-destination 192.168.2.1:3228
#iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128
#iptables -t nat -A PREROUTING -i eth1 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3228
De ha bekapcsolom a proxy-t, akkor csak az "egyik_net"-en megy a webböngészés, melynek a squid.conf-ban megadott átjárója megegyezik a szerver route táblájában először szereplő default átjáróval.
squid.conf
acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl to_localhost dst 127.0.0.0/8
acl SSL_ports port 443
acl Safe_ports port 80 81 8080 8081 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 5222
acl Safe_ports port 443 # https
acl PURGE method PURGE
acl CONNECT method CONNECT
acl egyik_net src 192.168.1.0/255.255.255.0
acl masik_net src 192.168.2.0/255.255.255.0
tcp_outgoing_address 195.199.1.2 egyik_net
tcp_outgoing_address 195.199.2.2 masik_net
http_access allow egyik_net
http_access allow masik_net
http_access allow manager localhost
http_access deny manager
http_access allow PURGE localhost
http_access deny PURGE
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost
http_access deny all
icp_access deny all
htcp_access deny all
http_port 3128 transparent
http_port 3228 transparent
hierarchy_stoplist cgi-bin ?
cache_mem 32 MB
cache_dir ufs /var/spool/squid3 1024 16 256
access_log /var/log/squid3/access.log squid
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern (cgi-bin|\?) 0 0% 0
refresh_pattern . 0 20% 4320
icp_port 3130
forwarded_for off
coredump_dir /var/spool/squid3
server_persistent_connections off
route parancs kimenete:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
195.199.2.0 * 255.255.255.0 U 0 0 0 eth1
195.199.1.0 * 255.255.255.0 U 0 0 0 eth0
192.168.2.0 * 255.255.255.0 U 0 0 0 eth3
192.168.1.0 * 255.255.255.0 U 0 0 0 eth2
default 195.199.1.1 0.0.0.0 UG 0 0 0 eth0
default 195.199.2.1 0.0.0.0 UG 0 0 0 eth1
köszönettel várom a javaslatokat
András
- Tovább (squid 2netkapcsolat)
- 3625 megtekintés