IPTables

From MLDonkey
Jump to: navigation, search


please read the [Forums&fileviewtopic&t503&start0&postdays0&postorderasc&highlight&sid2c1d045147847071c9d64462b92ef6e4 Original Forum Thread]


this setting seems to work (don't hesitate to make comments)

#!/bin/bash

# No ICMP
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
echo 0 > /proc/sys/net/ipv4/ip_forward


### Firewall + Gateway section

# Flush all tables
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X

# Masquerade all outgoing packets on the ppp0 interface
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE

# Drop all by default
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP

# Accept all connections on the loopback interface
iptables -A INPUT -i lo -j ACCEPT

# MLDonkey
iptables -A INPUT -i ppp0 -p tcp ! --syn -j ACCEPT
iptables -A INPUT -i ppp0 -p tcp -m multiport --dports 4662,18491 --syn -j ACCEPT
iptables -A INPUT -i ppp0 -p udp -m multiport --dports 4666,18491 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --dport 4080 -j ACCEPT

# LAN connection
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -m state --state NEW -i ! ppp0 -j ACCEPT


# iptables -A INPUT -i ppp0 -p tcp --syn -j LOG --log-ip-options --log-tcp-options

# Enable IP forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox