Iptables - brak internetu na komputerach w sieci
: 15 września 2009, 17:53
Próbuję pisać samemu firewall, na zasadzie - blokuje wszystko, wpuszczam tylko konkretne usługi. Problem jest taki, że przy tej konfiguracji (Domyślna polityka łańcuchów na DROP):
nie działają strony WWW na komputerach w sieci wewnętrznej.
Nie bardzo mogę jakoś dojść przyczyny błędu. Prosiłbym o pomoc.
Czy FORWARD jest tutaj potrzebne? Czy nie?
Kod: Zaznacz cały
####### NET FORWARD #######
echo "1" > /proc/sys/net/ipv4/ip_forward # KERNEL NET FORWARD
####### SECURITY #######
echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts # ICMP ECHO REQUEST @ BROADCAST ignore
echo "1" > /proc/sys/net/ipv4/tcp_syncookies # SYN FLOOD refuse
echo "0" > /proc/sys/net/ipv4/conf/all/accept_source_route # SOURCE ROUTED PACKETS refuse
echo "1" > /proc/sys/net/ipv4/conf/all/secure_redirects
echo "1" > /proc/sys/net/ipv4/conf/all/rp_filter # SOURCE VALIDATION by REVERSED PATH
####### RULES CHAINS FLUSHING #######
iptables -F # STANDARD CHAINS
iptables -t nat -F
iptables -t mangle -F
####### RULES CHAINS GENERATE #######
iptables -P INPUT DROP # STANDARD CHAINS POLICY
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
######## ESTABLISHED CONNECTIONS KEEP #######
iptables -A INPUT -j ACCEPT -m state --state ESTABLISHED,RELATED
iptables -A FORWARD -j ACCEPT -m state --state ESTABLISHED,RELATED
iptables -A OUTPUT -j ACCEPT -m state --state ESTABLISHED,RELATED
####### ALLOWING PROTCOLS #######
#---------- WWW ----------#
iptables -A INPUT -p tcp --sport 80 -j ACCEPT # HTTP:80
iptables -A OUTPUT -p tcp --dport 80 -j ACCEPT
iptables -A FORWARD -p tcp --dport 80 -j ACCEPT
iptables -A FORWARD -p tcp --sport 80 -j ACCEPT
iptables -A INPUT -p tcp --sport 443 -j ACCEPT # HTTPS:443
iptables -A OUTPUT -p tcp --dport 443 -j ACCEPT
#---------- SSH ----------#
iptables -A INPUT -p tcp -i eth0 --dport 22 -j DROP # WAN SSH
iptables -A INPUT -p tcp -i eth1 --dport 22 -j ACCEPT # LAN SSH
#---------- DNS ----------#
iptables -A INPUT -p udp --sport 53 -j ACCEPT # DNS ALLOW
iptables -A OUTPUT -p udp --dport 53 -j ACCEPT
iptables -A FORWARD -p udp --sport 53 -j ACCEPT
iptables -A FORWARD -p udp --dport 53 -j ACCEPT
#------ LO Interface -----#
iptables -A INPUT -i lo -j ACCEPT # LO ALLOW
iptables -A OUTPUT -o lo -j ACCEPT
####### NETWORK ROUTING #######
iptables -t nat -A POSTROUTING -s 192.168.3.0/24 -j MASQUERADE # LAN MASQUARADE
iptables -A FORWARD -s 192.168.3.0/24 -j ACCEPT
Kod: Zaznacz cały
nox-debian:~# iptables -L -v
Chain INPUT (policy DROP 33 packets, 2931 bytes)
pkts bytes target prot opt in out source destination
119 25566 ACCEPT all -- any any anywhere anywhere state RELATED,ESTABLISHED
0 0 ACCEPT tcp -- any any anywhere anywhere tcp spt:www
0 0 ACCEPT tcp -- any any anywhere anywhere tcp spt:https
0 0 DROP tcp -- eth0 any anywhere anywhere tcp dpt:ssh
0 0 ACCEPT tcp -- eth1 any anywhere anywhere tcp dpt:ssh
1 61 ACCEPT udp -- any any anywhere anywhere udp spt:domain
0 0 ACCEPT all -- lo any anywhere anywhere
Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
15 3138 ACCEPT all -- any any anywhere anywhere state RELATED,ESTABLISHED
1 52 ACCEPT tcp -- any any anywhere anywhere tcp dpt:www
0 0 ACCEPT tcp -- any any anywhere anywhere tcp spt:www
0 0 ACCEPT udp -- any any anywhere anywhere udp spt:domain
0 0 ACCEPT udp -- any any anywhere anywhere udp dpt:domain
0 0 ACCEPT all -- any any localnet/24 anywhere
Chain OUTPUT (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
126 25733 ACCEPT all -- any any anywhere anywhere state RELATED,ESTABLISHED
2 120 ACCEPT tcp -- any any anywhere anywhere tcp dpt:www
0 0 ACCEPT tcp -- any any anywhere anywhere tcp dpt:https
3 194 ACCEPT udp -- any any anywhere anywhere udp dpt:domain
0 0 ACCEPT all -- any lo anywhere anywhere
Kod: Zaznacz cały
#---------- WWW ----------#
iptables -A INPUT -p tcp --sport 80 -j ACCEPT # HTTP:80
iptables -A OUTPUT -p tcp --dport 80 -j ACCEPT
iptables -A FORWARD -p tcp --dport 80 -j ACCEPT
iptables -A FORWARD -p tcp --sport 80 -j ACCEPT
iptables -A INPUT -p tcp --sport 443 -j ACCEPT # HTTPS:443
iptables -A OUTPUT -p tcp --dport 443 -j ACCEPT