When working with Debian servers (or any Linux system), it's crucial to understand that IPv4 and IPv6 are completely separate networking stacks. Your existing iptables rules only affect IPv4 traffic, leaving IPv6 ports potentially unprotected.
From your configuration, we can see:
# IPv4 rules (existing)
ACCEPT tcp -- eee.fff.ggg.hhh aaa.bbb.ccc.ddd tcp dpt:80
DROP tcp -- 0.0.0.0/0 aaa.bbb.ccc.ddd tcp dpt:80
# Network status showing IPv6 listener
tcp6 0 0 :::80 :::* LISTEN
If you don't configure ip6tables (IPv6 firewall), your port 80 is wide open to the entire IPv6 internet, completely bypassing your IPv4 restrictions. This is a serious security oversight that attackers could exploit.
For Debian systems, the ip6tables syntax is nearly identical to iptables. Here's how to mirror your IPv4 rules for IPv6:
# First, allow your specific IPv6 host
ip6tables -A INPUT -p tcp -s your:ipv6:address::here --dport 80 -j ACCEPT
# Then block all other IPv6 traffic to port 80
ip6tables -A INPUT -p tcp --dport 80 -j DROP
To identify both your server's IPv6 address and the allowed client's IPv6 address:
# For your server's IPv6 addresses
ip -6 addr show
# For remote connection testing (from client)
curl -6 ifconfig.co
Here's a more complete example that handles both IPv4 and IPv6:
# IPv4 rules
iptables -A INPUT -p tcp -s 192.168.1.100 --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j DROP
# IPv6 rules
ip6tables -A INPUT -p tcp -s 2001:db8::abc:def --dport 80 -j ACCEPT
ip6tables -A INPUT -p tcp --dport 80 -j DROP
On Debian, install and use iptables-persistent:
apt install iptables-persistent
netfilter-persistent save
netfilter-persistent reload
Always test your firewall rules from both IPv4 and IPv6 perspectives:
# Check IPv4 rules
iptables -L -n -v
# Check IPv6 rules
ip6tables -L -n -v
# Test connection from allowed IP
curl --interface eth0 -4 http://yourserver
curl --interface eth0 -6 http://yourserver
If you're not using IPv6, you can disable it completely (not recommended):
# Add to /etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
sysctl -p
When running services on modern Linux systems, you'll often encounter both IPv4 and IPv6 connectivity. The key observation in your case is that Apache is listening on :::80
(all IPv6 addresses) while your iptables rules only manage IPv4 traffic. This creates a potential security gap where IPv6 connections could bypass your firewall.
Linux provides separate tools for IPv4 and IPv6 firewall management:
iptables
for IPv4 rulesip6tables
for IPv6 rules
Here's how to check existing IPv6 rules:
sudo ip6tables -L -n -v
To mirror your existing IPv4 rules for IPv6, you would use:
# Allow specific IPv6 address
sudo ip6tables -A INPUT -p tcp -s 2001:db8::1 --dport 80 -j ACCEPT
# Block all other IPv6 traffic
sudo ip6tables -A INPUT -p tcp --dport 80 -j DROP
IPv6 addressing differs significantly from IPv4. Some important considerations:
# Allow from specific IPv6 address
ip6tables -A INPUT -s 2001:db8:abcd:0012::1/128 -j ACCEPT
# Allow from entire IPv6 subnet
ip6tables -A INPUT -s 2001:db8:abcd:0012::/64 -j ACCEPT
# Allow localhost IPv6 traffic
ip6tables -A INPUT -s ::1/128 -j ACCEPT
Here's a complete example for securing port 80 on both protocols:
# IPv4 Rules
iptables -A INPUT -p tcp -s 192.168.1.100 --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j DROP
# IPv6 Rules
ip6tables -A INPUT -p tcp -s 2001:db8::100 --dport 80 -j ACCEPT
ip6tables -A INPUT -p tcp --dport 80 -j DROP
On Debian systems, install and use these packages to save rules:
sudo apt install iptables-persistent ip6tables-persistent
sudo netfilter-persistent save
sudo netfilter-persistent reload
Verify your rules with these commands:
sudo iptables -L -n -v
sudo ip6tables -L -n -v
For comprehensive testing, attempt connections from both IPv4 and IPv6 clients using tools like curl
or telnet
.
If you don't need IPv6 support, you can disable it in Apache:
# Edit /etc/apache2/ports.conf
Listen 0.0.0.0:80
# Instead of Listen 80 which listens on both protocols