FTP Connection State Tracking Issue
Hi Everyone,
My question is, that if I have already loaded the ftp connection tracking and nat modules, do i still need to write scripts like the following on my firewall, to enable FTP Access from inside to outside (
My Default Rules are -
Allow Outgoing connection tcp on port 21
Deny all other outgoing connections
Scripts
(For Active FTP)
iptables -A INPUT -p tcp --sport 20 -m state --state
ESTABLISHED,RELATED-j ACCEPT
iptables -A OUTPUT-p tcp --dport 20 -m state --state ESTABLISHED-j ACCEPT
(For Passive FTP)
iptables -A INPUT -p tcp --sport 1024: --dport 1024: -m state
--state ESTABLISHED-j ACCEPT
iptables -A OUTPUT-p tcp --sport 1024: --dport 1024: -m state --state ESTABLISHED,RELATED-j ACCEPT
Signature · 3 lines
Ashutosh Naik Teneoris Networks India Pvt. Ltd www.teneoris.com
Quoted 18 lines · Ashutosh
Hi Everyone,
My question is, that if I have already loaded the ftp connection tracking and nat modules, do i still need to write scripts like the following on my firewall, to enable FTP Access from inside to outside (
My Default Rules are -
Allow Outgoing connection tcp on port 21
Deny all other outgoing connectionsScripts
(For Active FTP)
iptables -A INPUT -p tcp --sport 20 -m state --state
ESTABLISHED,RELATED-j ACCEPT
iptables -A OUTPUT-p tcp --dport 20 -m state --state ESTABLISHED-j ACCEPT
Quoted 5 lines
(For Passive FTP)
iptables -A INPUT -p tcp --sport 1024: --dport 1024: -m state
--state ESTABLISHED-j ACCEPT
iptables -A OUTPUT-p tcp --sport 1024: --dport 1024: -m state --state ESTABLISHED,RELATED-j ACCEPT
no--but you need to write scripts like this:
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT iptables -A FORWARD -p tcp --syn --dport 21 -j ACCEPT
-j
--
"I saw weird stuff in that place last night. Weird, strange, sick,
twisted, eerie, godless, evil stuff. And I want in."
--The Simpsons
Quoted 6 lines
no--but you need to write scripts like this:
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT iptables -A FORWARD -p tcp --syn --dport 21 -j ACCEPT
Well, I thought the Connection Tracking and NAT Modules *for* FTP did the same.. Correct me if I am wrong..
After all, why are the ALGs neccessary, if *user space* iptables rules are still required ?
Signature · 3 lines
Ashutosh Naik Teneoris Networks India Pvt. Ltd www.teneoris.com
Quoted 3 lines · Ashutosh
Quoted 3 lines
no--but you need to write scripts like this:
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
allows packets that match connections in the conntrack table
Quoted 1 line
Quoted 1 line
iptables -A FORWARD -p tcp --syn --dport 21 -j ACCEPT
allows FTP connections outbound
Quoted 2 lines
Well, I thought the Connection Tracking and NAT Modules *for* FTP did the same.. Correct me if I am wrong..
connection tracking does not write filter rules for you.
Quoted 2 lines
After all, why are the ALGs neccessary, if *user space* iptables rules are still required ?
i don't understand this question. what "ALGs" are you speaking of? iptables rules are necessary to allow/deny traffic; as that's how you get firewalls to do what you want (ideally).
-j
--
"I'm better than dirt. Well, most kinds of dirt... not that fancy
store-bought dirt... that stuff's loaded with nutrients, I... I can't compete with that stuff."
--The Simpsons
Quoted 2 lines
Well, I thought the Connection Tracking
and NAT Modules *for* FTP did
please correct me if i am wrong.
2 functions you have.
first is ftp NAT algorithm = kernel module ip_nat_ftp + iptables -t nat ... rules)
second is connection tracking firewall which looks also inside of ftp control streams = kernel module ip_conntrack and ip_conntrack_ftp + user space rules iptables -t filter(implicit table) -m state --state NEW/ESTABLISHED/RELATED...
4 combiantions you get.
none used
NAT no firewall
no NAT and firewall
NAT and firewall
where no firewall translates into setting all built-in chains policy to accept traffic (-t nat/filter/mangle PREROUTING/POSTROUTING/INPUT/OUTPUT/FORWARD -P ACCEPT) and having no additional REJECT/DROP rules
ps: for NAT you can also use dumb nat if it's 1:1 nat. that's probably set up somehow with "ip route/rule whatever"