Iptables - ładowanie reguł
: 25 maja 2016, 20:44
Dotyczy IPv4. Iptables uzywam jako skrypt startowy a nie usluge w systemd.
Dopisalem do pliku firewalla (/etc/network/if-pre-up.d/firewall) 3xDROP w Defoult Policy.
Po modyfikacji, dla pewnosci komenda:
Reboot.
Niestety w lancuchu OUTPUT Defoult Policy jest ciagle ACCEPT.
Pytania:
- czy w takiej konfiguracji Defoult Policy 3xDROP ma racje bytu? Czy tez jest zbedna?
- Dlaczego w lancuchu OUTPUT policy jest ciagle ACCEPT zamiast DROP? Czy z tego wynika ze iptables nie zaladowaly zmienionej tresci skryptu?
Jak przeladowac skrypt, zeby zaktualizowal zmiany?
Dopisalem do pliku firewalla (/etc/network/if-pre-up.d/firewall) 3xDROP w Defoult Policy.
Kod: Zaznacz cały
#!/bin/sh
echo "Starting firewall"
iptables -F
iptables -X
iptables INPUT DROP
iptables FORWARD DROP
iptables OUTPUT DROP
# what was incoming but denied (optional but useful).
iptables -A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables_INPUT_denied: " --log-level 7
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -P INPUT DROP
# Log any traffic which was sent to you
# for forwarding (optional but useful).
iptables -A FORWARD -m limit --limit 5/min -j LOG --log-prefix "iptables_FORWARD_denied: " --log-level 7
iptables -P FORWARD DROP
iptables -I OUTPUT -m conntrack --ctstate NEW,INVALID -j LOG --log-prefix "OUTPUT"
iptables -A OUTPUT -m state –state ESTABLISHED -j ACCEPT
#iptables -A OUTPUT -j REJECT
ip6tables -F
ip6tables -X
# Log what was incoming but denied (optional but useful).
ip6tables -A INPUT -m limit --limit 5/min -j LOG --log-prefix "ip6tables_INPUT_denied: " --log-level 7
ip6tables -A INPUT -i lo -j ACCEPT
ip6tables -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
ip6tables -P INPUT DROP
# Log any traffic which was sent to you
# for forwarding (optional but useful).
ip6tables -A FORWARD -m limit --limit 5/min -j LOG --log-prefix "ip6tables_FORWARD_denied: " --log-level 7
ip6tables -P FORWARD DROP
ip6tables -P OUTPUT DROP
Kod: Zaznacz cały
chmod +x /etc/network/if-pre-up.d/firewall
Niestety w lancuchu OUTPUT Defoult Policy jest ciagle ACCEPT.
Kod: Zaznacz cały
root@debian:/home/robin# iptables -L
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT udp -- anywhere anywhere udp dpt:domain
ACCEPT tcp -- anywhere anywhere tcp dpt:domain
ACCEPT udp -- anywhere anywhere udp dpt:bootps
ACCEPT tcp -- anywhere anywhere tcp dpt:bootps
LOG all -- anywhere anywhere limit: avg 5/min burst 5 LOG level debug prefix "iptables_INPUT_denied: "
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
Chain FORWARD (policy DROP)
target prot opt source destination
ACCEPT all -- anywhere 192.168.100.0/24 ctstate RELATED,ESTABLISHED
ACCEPT all -- 192.168.100.0/24 anywhere
ACCEPT all -- anywhere anywhere
REJECT all -- anywhere anywhere reject-with icmp-port-unreachable
REJECT all -- anywhere anywhere reject-with icmp-port-unreachable
LOG all -- anywhere anywhere limit: avg 5/min burst 5 LOG level debug prefix "iptables_FORWARD_denied: "
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ACCEPT udp -- anywhere anywhere udp dpt:bootpc
LOG all -- anywhere anywhere ctstate INVALID,NEW LOG level warning prefix "OUTPUT"
- czy w takiej konfiguracji Defoult Policy 3xDROP ma racje bytu? Czy tez jest zbedna?
- Dlaczego w lancuchu OUTPUT policy jest ciagle ACCEPT zamiast DROP? Czy z tego wynika ze iptables nie zaladowaly zmienionej tresci skryptu?
Jak przeladowac skrypt, zeby zaktualizowal zmiany?
