Listing 2. iptables: Commands for Transparent FTP Proxying
iptables -t nat -A PREROUTING -p tcp -i eth2 \
--dport 21 -j REDIRECT
iptables -t nat -A PREROUTING -p tcp -i eth0 \
--dport 21 -j REDIRECT
# snip...
iptables -A INPUT -p tcp -d $PUBLIC_FTP \
--dport 21 -m state --state NEW,RELATED -j ACCEPT
iptables -A INPUT -p tcp -s $INTERNAL_HOSTS \
--dport 21 -m state --state NEW,RELATED -j ACCEPT
# snip...
iptables -A OUTPUT -p tcp -d $PUBLIC_FTP \
--dport 21 -m state --state NEW,RELATED -j ACCEPT
iptables -A OUTPUT -p tcp -o eth2 --dport 21 \
-m state --state NEW,RELATED -j ACCEPT
Copyright © 1994 - 2019 Linux Journal. All rights reserved.