Diese Seite (Version-45) wurde zuletzt am 29-Dez.-2024 12:08 von Administrator geändert.

Diese Seite wurde am 23-Dez.-2024 12:59 von Administrator erstellt.

Du bist nicht autorisiert, diese Seite umzubenennen.

Du bist nicht autorisiert, diese Seite zu löschen.

Versionsgeschichte der Seite

Version Zuletzt geändert Größe Autor Änderungen Kommentar
45 29-Dez.-2024 12:08 10 KB Administrator zur vorherigen
44 29-Dez.-2024 12:06 10 KB Administrator zur vorherigen | zur neuesten
43 29-Dez.-2024 12:05 10 KB Administrator zur vorherigen | zur neuesten
42 29-Dez.-2024 12:02 9 KB Administrator zur vorherigen | zur neuesten
41 29-Dez.-2024 12:01 9 KB Administrator zur vorherigen | zur neuesten

Links

Eingehende Links Ausgehende Links

Versionsunterschiede

Unterschiede zwischen Version und .

Zeile 13: Eine Zeile geändert.
* all iptables commands (for ipv4) have an ip__6__tabbles* equivalent (for ipv6)
* all iptables commands (for ipv4 only) have an ip__6__tables* equivalent for ipv6
Zeile 19: 2 Zeilen gelöscht.
> sudo ip6tables -L -v # list all ipv6 rules
> sudo ip6tables -n -v --line-numbers -L # list all ipv6 rules with numeric IPs and rule number
Zeile 21: 12 Zeilen hinzugefügt.
! Logging
{{{
> iptables -A INPUT -j LOG --log-level 4 --log-prefix 'IP INPUT '
}}}
! Load rules after reboot
{{{
> sudo apt-get install iptables-persistent
}}}
* Current iptables rules can be saved to the configuration file /etc/iptables/rules.v4. These rules will then be loaded automatically during system startup.
* Rules are only saved automatically during package installation. See the manual page of iptables-save(8) for instructions on keeping the rules file up-to-date.
Zeile 26: 7 Zeilen geändert.
> sudo iptables -L -v
> sudo iptables -nvL # thjis is most compact
> sudo iptables -n -v --line-numbers -L
> sudo service iptables start # activate firewalling
> sudo service ip6tables start
> sudo chkconfig iptables on # enable after reboot
> sudo chkconfig ip6tables on
> sudo ip6tables -L -v
> sudo ip6tables -nvL # thjis is most compact
> sudo ip6tables -n -v --line-numbers -L # list all ipv6 rules with numeric IPs and rule number
> sudo service ip6tables start # activate firewalling
> sudo chkconfig ip6tables on # enable after reboot
Zeile 36: Eine Zeile geändert.
iptables [-t <table-name>] <command> <chain-name> <parameter-1> <option-1> <parameter-n> <option-n>
ip6tables [-t <table-name>] <command> <chain-name> <parameter-1> <option-1> <parameter-n> <option-n>
Zeile 60: Eine Zeile geändert.
** -j : jump to ~[ACCEPT, DROP, QUEUE, RETURN~] (or others added with modules)
** -j : jump to ~[ACCEPT, DROP, QUEUE, RETURN~] (or others added with modules), REJECT= notify other end, DROP= silently ignore
Zeile 78: 10 Zeilen hinzugefügt.
! [Examples|https://www.iitk.ac.in/LDP/HOWTO/Linux+IPv6-HOWTO/ch18s03.html]
{{{
ip6tables -A INPUT -i eth0 -p tcp -s 2001:0db8:100::1/128 --sport 512:65535 --dport 22 -j ACCEPT #Allow incoming SSH from 2001:0db8:100::1/128
ip6tables -A OUTPUT -o eth0 -p tcp -d 2001:0db8:100::1/128 --dport 512:65535 --sport 22 ! --syn -j ACCEPT #Allow response packets (no longer needed if connection tracking is used!)
ip6tables -I INPUT -i eth0 -p tcp --syn -j DROP #Block incoming TCP connection requests to this host
ip6tables -I FORWARD -i eth0 -p tcp --syn -j DROP #Block incoming TCP connection requests to hosts behind this router
ip6tables -I INPUT -i eth0 -p udp ! --dport 32768:60999 -j DROP #Block incoming UDP packets which cannot be responses of outgoing requests of this host
ip6tables -I FORWARD -i eth0 -p udp ! --dport 32768:60999 -j DROP #Block incoming UDP packets which cannot be responses of forwarded requests of hosts behind this router
ip6tables -A INPUT --protocol icmpv6 --icmpv6-type echo-request -j ACCEPT --match limit --limit 30/minute #Rate-limiting
}}}
Zeile 71: 4 Zeilen gelöscht.
! 4. my general ruleset
We also need to enable the local interface and the DNS nameservers.\\
I use a custom DNS server setting, because the fritzbox does not resolve my dynv6 domains (?).
Zeile 76: 2 Zeilen geändert.
> sudo nmcli -o device show # show interfaces settings
> sudo nmcli -p connection show # show interface status
-A RH-Firewall-1-INPUT -p icmpv6 -j ACCEPT
-A RH-Firewall-1-INPUT -p 50 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp --dport 5353 -d ff02::fb -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -p tcp --dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp6-adm-prohibited
}}}
Zeile 79: 6 Zeilen geändert.
#THIS IS NECESSARY
> sudo nmcli con mod "Wired connection 1" ipv4.dns "1.1.1.1,8.8.8.8" # add cloudflare and google dns
> sudo nmcli con mod "Wired connection 1" ipv4.ignore-auto-dns no # this adds "search fritz.box" to get ips at all from frit.box
> sudo nmcli con mod "Wired connection 1" ipv6.ignore-auto-dns yes # we skip ipv6 dns
> sudo nmcli c down "Wired connection 1" && sudo nmcli c up "Wired connection 1" # restart
> sudo vi /etc/resolv.conf # validate settings
more {examples|https://www.linux.com/topic/networking/iptables-rules-ipv6/]
{{{
ipt6="/sbin/ip6tables" # Define your command variables
$ipt6 -A INPUT -i lo -j ACCEPT # Must allow loopback interface
$ipt6 -A INPUT -p tcp --syn -j DROP # Reject connection attempts not initiated from the host
$ipt6 -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT # Allow return connections initiated from the host
$ipt6 -A INPUT -p icmpv6 -j ACCEPT # Accept all ICMP v6 packets
# to services. Delete $ipt6 -A INPUT -p tcp --syn -j DROP # Optional rules to allow other LAN hosts access
$ipt6 -A INPUT -m state --state NEW -m udp -p udp # Allow DHCPv6 from LAN only
-s fe80::/10 --dport 546 -j ACCEPT
$ipt6 -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT # Allow connections from SSH clients
$ipt6 -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT # Allow HTTP and HTTPS traffic
$ipt6 -A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT # Allow HTTP and HTTPS traffic
Zeile 115: 7 Zeilen hinzugefügt.
! My RuleSet
This one is
* allowing dhcp, dns and router traffic
* not allowing ipv4
* allowing ipv6 for 3 distinct ipv6 addresses, these are the first three ipv6 rules, which we replace at [Exposing Raspberry to Internet]
Zeile 89: Eine Zeile geändert.
# MARKUS
Zeile 98: 2 Zeilen geändert.
# drop all ipv4 traffic, we want to use ipv6 only
iptables -A INPUT -s 1.1.1.1 -j ACCEPT
# enable dns nameserver
iptables -A INPUT -s 1.1.1.1 -j ACCEPT # cloudflare
Zeile 101: Eine Zeile geändert.
iptables -A INPUT -s 8.8.8.8 -j ACCEPT
iptables -A INPUT -s 8.8.8.8 -j ACCEPT # google
Zeile 139: 24 Zeilen hinzugefügt.
# connection
iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -m conntrack --ctstate ESTABLISHED -j ACCEPT
# enable router for dhcp
iptables -A INPUT -s 192.168.188.1/24 -j ACCEPT
iptables -A OUTPUT -d 192.168.188.1/24 -j ACCEPT
# enable dns
iptables -A INPUT -p udp -m multiport --sport 53,67,68,90,135,853,5353,8245 -j ACCEPT
iptables -A OUTPUT -p udp -m multiport --dport 53,67,68,90,135,853,5353,8245 -j ACCEPT
#iptables -A INPUT -i eth0 -p udp --dport 67:68 --sport 67:68 -j ACCEPT
#iptables -A INPUT -i eth0 -p udp -m udp -m multiport --dports 67:68 -j ACCEPT
#iptables -A OUTPUT -o eth0 -p udp -m udp -m multiport --dports 67:68 -j ACCEPT
# enable dhcp
iptables -A INPUT -i eth0 -p icmp -j ACCEPT
iptables -A OUTPUT -o eth0 -p icmp -j ACCEPT
iptables -A INPUT -i eth0 -p icmp -m icmp --icmp-type 134 -m comment --comment router-advertisement -j ACCEPT
iptables -A INPUT -p icmp -m icmp --icmp-type 135 -m comment --comment neighbor-solicitation -j ACCEPT
iptables -A INPUT -p icmp -m icmp --icmp-type 136 -m comment --comment neighbor-advertisement -j ACCEPT
# allow local loopback
Zeile 106: 3 Zeilen gelöscht.
iptables -A INPUT -j DROP
iptables -A FORWARD -j DROP
iptables -A OUTPUT -j DROP
Zeile 166: 5 Zeilen hinzugefügt.
# drop everything else
iptables -A INPUT DROP
iptables -P FORWARD -j DROP
iptables -A OUTPUT -j DROP
Zeile 116: Eine Zeile geändert.
# drop all ipv6 traffic, except EbelStube
# drop all ipv6 traffic, except special ipv6, see below
Zeile 180: 2 Zeilen hinzugefügt.
# placeholder for first device
Zeile 185: 38 Zeilen hinzugefügt.
# placeholder for second device
ip6tables -A INPUT -s $SOURCE -j ACCEPT
ip6tables -A OUTPUT -d $SOURCE -j ACCEPT
# placeholder for third device
ip6tables -A INPUT -s $SOURCE -j ACCEPT
ip6tables -A OUTPUT -d $SOURCE -j ACCEPT
# dns nameserver
ip6tables -A INPUT -s 2606:4700:4700::1111 -j ACCEPT # cloudflare
ip6tables -A OUTPUT -d 2606:4700:4700::1111 -j ACCEPT
ip6tables -A INPUT -s 2001:4860:4860::8888 -j ACCEPT # google
ip6tables -A OUTPUT -d 2001:4860:4860::8888 -j ACCEPT
# connection
ip6tables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
ip6tables -A OUTPUT -m conntrack --ctstate ESTABLISHED -j ACCEPT
# enable dhcp
ip6tables -A INPUT -s fd94::/16 -j ACCEPT
ip6tables -A OUTPUT -d fd94::/16 -j ACCEPT
ip6tables -A INPUT -s fe80::/16 -j ACCEPT
ip6tables -A OUTPUT -d fe80::/16 -j ACCEPT
# enable dns
ip6tables -A INPUT -p udp -m multiport --sport 53,67,68,90,135,853,5353,8245 -j ACCEPT
ip6tables -A OUTPUT -p udp -m multiport --dport 53,67,68,90,135,853,5353,8245 -j ACCEPT
# enable dhcp
ip6tables -A INPUT -p ipv6-icmp -j ACCEPT
ip6tables -A OUTPUT -p ipv6-icmp -j ACCEPT
#ip6tables -A INPUT -i eth0 -p ipv6-icmp -m icmp6 --icmpv6-type 134 -m comment --comment router-advertisement -j ACCEPT
#ip6tables -A INPUT -p ipv6-icmp -m icmp6 --icmpv6-type 135 -m comment --comment neighbor-solicitation -j ACCEPT
#ip6tables -A INPUT -p ipv6-icmp -m icmp6 --icmpv6-type 136 -m comment --comment neighbor-advertisement -j ACCEPT
Zeile 128: 2 Zeilen geändert.
ip6tables -A INPUT -j DROP
ip6tables -A OUTPUT -j DROP
ip6tables -A INPUT -j DROP
ip6tables -A OUTPUT -j DROP
Zeile 131: Eine Zeile geändert.
# update first ip6tables rules and enable my computer
# update first ip6tables rules and enable my computers
Zeile 133: Eine Zeile gelöscht.
}}}
Zeile 235: 6 Zeilen hinzugefügt.
echo "---- iptables ----"
iptables -vnL
echo
echo "---- ip6tables ----"
ip6tables -vnL
}}}