[+] Regu

Masz problemy z siecią bądź internetem? Zapytaj tu
f3t1
Posty: 50
Rejestracja: 05 września 2008, 20:07

[+] Regułki iptables pozwalające na działanie Apache2 itp.

Post autor: f3t1 »

Witka,

Sprawa ma się tak: w tej chwili mój firewall ma zablokowane wszystko, oprócz potrzebnych mi usług. Chciałbym jednak część pootwierać, jako że skonfigurowałem sobie DDNS, przekierowania portów na ruterze itp. tak, by ludzkość mogła zobaczyć moje dzieło :)

Tym w tej chwili dysponuję:

Kod: Zaznacz cały

##################### CLEAN ##################
iptables -F
iptables -X
iptables -F -t nat
iptables -X -t nat
iptables -F -t filter
iptables -X -t filter 

############ DEFAULT POLICY #################
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP
# dla localhost
iptables -A INPUT -s 127.0.0.1 -j ACCEPT

################ PODSTAWOWE #################
# DNS-y
iptables -A INPUT -p udp --sport 53 -j ACCEPT
# www
iptables -A INPUT -p tcp --sport 80 -j ACCEPT
iptables -A INPUT -p tcp --sport 8080 -j ACCEPT
# https
iptables -A INPUT -p tcp --sport 443 -j ACCEPT
# Kadu
iptables -A INPUT -p tcp --sport 8074 -j ACCEPT
# POP3
# iptables -A INPUT -p tcp --sport 110 -j ACCEPT 
# POP3 z TLS/SSL
iptables -A INPUT -p udp --sport 995 -j ACCEPT
iptables -A INPUT -p tcp --sport 995 -j ACCEPT
# SMTP
iptables -A INPUT -p tcp --sport 25 -j ACCEPT 
iptables -A INPUT -p udp --sport 25 -j ACCEPT
# SSMTP ( secure smtp )
iptables -A INPUT -p tcp --sport 465 -j ACCEPT
iptables -A INPUT -p udp --sport 465 -j ACCEPT

################# POZOSTA£E ##################
# torrent
iptables -A INPUT -p udp --dport 4444 -j ACCEPT
iptables -A INPUT -p udp --dport 6880:6999 -j ACCEPT
iptables -A INPUT -p tcp --dport 6880:6999 -j ACCEPT
# amule
iptables -A INPUT  -i eth0 -p tcp  -s 0/0 -m multiport --dport 4661,4662,4665,4672 -j ACCEPT
iptables -A INPUT  -i eth0 -p udp  -s 0/0 -m multiport --dport 4661,4662,4665,4672 -j ACCEPT
iptables -A OUTPUT         -p tcp  -d 0/0 -m multiport --sport 4661,4662,4665,4672 -j ACCEPT
iptables -A OUTPUT         -p udp  -d 0/0 -m multiport --sport 4661,4662,4665,4672 -j ACCEPT

iptables -A INPUT   -j ACCEPT -m state --state ESTABLISHED,RELATED
iptables -A INPUT -m state --state INVALID -j DROP 


# komputer nie odpowiada na pakiety ICMP
# jednocześnie zabezpieczając przed atakiem ping of death
iptables -A INPUT -p icmp --icmp-type echo-reply -j ACCEPT
W jaki sposób go zmodyfikować, by istniała możliwość "wychodzenia" na zewnątrz?
Próbowałem używać jakichś GUI, ale nie wiem, albo jestem dwie lewe ręce albo nie są dla mnie.
Awatar użytkownika
Yampress
Administrator
Posty: 6422
Rejestracja: 09 sierpnia 2007, 21:41
Lokalizacja: PL

Post autor: Yampress »

Kod: Zaznacz cały

# DNS-y 
iptables -A INPUT -p udp --sport 53 -j ACCEPT 
# www 
iptables -A INPUT -p tcp --sport 80 -j ACCEPT 
iptables -A INPUT -p tcp --sport 8080 -j ACCEPT 
# https 
iptables -A INPUT -p tcp --sport 443 -j ACCEPT 
# Kadu 
iptables -A INPUT -p tcp --sport 8074 -j ACCEPT 
# POP3 
# iptables -A INPUT -p tcp --sport 110 -j ACCEPT 
# POP3 z TLS/SSL 
iptables -A INPUT -p udp --sport 995 -j ACCEPT 
iptables -A INPUT -p tcp --sport 995 -j ACCEPT 
# SMTP 
iptables -A INPUT -p tcp --sport 25 -j ACCEPT 
iptables -A INPUT -p udp --sport 25 -j ACCEPT 
# SSMTP ( secure smtp ) 
iptables -A INPUT -p tcp --sport 465 -j ACCEPT 
iptables -A INPUT -p udp --sport 465 -j ACCEPT

raczej powinno byc --dport :) we wszystkich wpisach jeśli chcesz wpuszczać na dane usługi osoby. Te wpisy nic nie dają co masz.

poza tym jeeśli to nie jest router to wystarczy wpis

Kod: Zaznacz cały

iptables -F
iptables -P INPUT DROP 
iptables -P OUTPUT ACCEPT 
iptables -P FORWARD DROP 
# dla localhost 
iptables -A INPUT -s 127.0.0.1 -j ACCEPT

iptables -A INPUT   -j ACCEPT -m state --state ESTABLISHED,RELATED 
iptables -A INPUT -m state --state INVALID -j DROP

+ zmiana tych regułek z --dport co wyżej podałem i to jesszcze nie wszystkie jeśli nie udostepniasz na świat tylu usług
f3t1
Posty: 50
Rejestracja: 05 września 2008, 20:07

Post autor: f3t1 »

Chodzi mi o to by cały ruch zablokować, a zostawić tylko usługi z których korzystam ( np.torrent, kadu ) i/lub chcę udostępniać ( http )

Kod: Zaznacz cały

iptables -F
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP
# dla localhost
iptables -A INPUT -s 127.0.0.1 -j ACCEPT

iptables -A INPUT   -j ACCEPT -m state --state ESTABLISHED,RELATED
iptables -A INPUT -m state --state INVALID -j DROP 

# DNS-y
iptables -A INPUT -p udp --dport 53 -j ACCEPT
# www
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 8080 -j ACCEPT
Awatar użytkownika
Yampress
Administrator
Posty: 6422
Rejestracja: 09 sierpnia 2007, 21:41
Lokalizacja: PL

Post autor: Yampress »

taki skrypt wystarczy
polityka output na accept i iptables -A INPUT -j ACCEPT -m state --state ESTABLISHED,RELATED
załatwia sprawe kadu i torrentów

jak masz www z ssl to jesszcze -dport 443
f3t1
Posty: 50
Rejestracja: 05 września 2008, 20:07

Post autor: f3t1 »

Ok, serdeczne dziękuję.
ODPOWIEDZ