tcproxy/iptables_init.sh

17 lines
545 B
Bash

#!/bin/bash
# Apply IPv4 rules
iptables -t nat -A PREROUTING -i enX0 -p tcp --dport 443 -j REDIRECT --to-ports 4443
iptables -t nat -A PREROUTING -i enX0 -p tcp --dport 80 -j REDIRECT --to-ports 4443
# Apply IPv6 rules
ip6tables -t nat -A PREROUTING -i enX0 -p tcp --dport 443 -j REDIRECT --to-ports 4443
ip6tables -t nat -A PREROUTING -i enX0 -p tcp --dport 80 -j REDIRECT --to-ports 4443
# Save rules
iptables-save > /etc/iptables/rules.v4
ip6tables-save > /etc/iptables/rules.v6
echo "iptables and ip6tables rules applied successfully."