FTP Forwarding
Hi Dear Members!
i have linux machine which configured as a router
my linux router has 2 NIC one with Public ip 202.147.167.99 and other is local ip 192.168.0.1
i have a another linux machine which configured as a FTP server and that machine ip is 192.168.0.5. Now i want my this ftp server can be access all world. so what kind of iptables rules will be add on linux router that if some one want to access ftp 202.147.167.99 its automaticaly forward or redirect my local machine 192.168.0.5.
Please help me in this regard
Thanks
Umar
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Quoted 4 lines · umar draz
Hi Dear Members!
i have linux machine which configured as a router
Quoted 8 lines
my linux router has 2 NIC one with Public ip 202.147.167.99 and other is local ip 192.168.0.1
i have a another linux machine which configured as a FTP server and that machine ip is 192.168.0.5. Now i want my this ftp server can be access all world. so what kind of iptables rules will be add on linux router that if some one want to access ftp 202.147.167.99 its automaticaly forward or redirect my local machine 192.168.0.5.Please help me in this regard
Thanks
Umar
modprobe ip_conntrack_ftp
modprobe ip_nat_ftp
iptables -t nat -A PREROUTING -i $EXT_IF -p tcp -d 202.147.167.99 \
--dport 21 -j DNAT --to-destination 192.168.0.5
iptables -A FORWARD -i $EXT_IF -o $INT_IF -p tcp --syn -d 192.168.0.5 \
--dport 21 -j ACCEPT
the above assumes you have a rule in FORWARD that accepts established packets, such as:
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
hth...
-j
--
"Well, I'm tired of being a wannabe league bowler. I wanna be a
league bowler!"
--The Simpsons
Hi!Can i have a follow up question regarding FTP server inside internal LAN which can be seen in the internet.....
now what if the scenario is i want to restrict a specific Public IP Address in using my FTP what will be the rules that i should apply?
I was thinking of setting up a rule that will filter incomming Public IP Address request for ftp before it forwards it into my internal FTP Server.
Below are the sample entry in my iptables:
iptables -t filter -A INPUT -p tcp -s $PublicIPAdd --dport 20:21 -j ACCEPT <--- is this correct?
iptables -t filter -A INPUT -j DROP
Below are the previous solution that you gave.
modprobe ip_conntrack_ftp
modprobe ip_nat_ftp
iptables -t nat -A PREROUTING -i $EXT_IF -p tcp -d 202.147.167.99 \
--dport 21 -j DNAT --to-destination 192.168.0.5
iptables -A FORWARD -i $EXT_IF -o $INT_IF -p tcp --syn -d 192.168.0.5 \
--dport 21 -j ACCEPT
the above assumes you have a rule in FORWARD that accepts established packets, such as:
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
hth...
-j
Thanks in advance!
Milo
----- Original Message -----
From: "Jason Opperisano" <[email protected]>
To: <[email protected]>
Sent: Wednesday, December 29, 2004 01:30 AM
Subject: Re: FTP Forwarding
Quoted 6 lines · umar draz
Quoted 5 lines
Hi Dear Members!
i have linux machine which configured as a router
my linux router has 2 NIC one with Public ip 202.147.167.99 and other
is local ip 192.168.0.1
Quoted 1 line
Quoted 1 line
i have a another linux machine which configured as a FTP server and
that machine ip is 192.168.0.5. Now i want my this ftp server can be access all world. so what kind of iptables rules will be add on linux router that if some one want to access ftp 202.147.167.99 its automaticaly forward or redirect my local machine 192.168.0.5.
Quoted 31 lines
Quoted 6 lines
Please help me in this regard
Thanks
Umar
modprobe
ip_conntrack_ftp
modprobeip_nat_ftpiptables -t nat -A PREROUTING -i $EXT_IF -p tcp -d 202.147.167.99 \
--dport 21 -j DNAT --to-destination 192.168.0.5iptables -A FORWARD -i $EXT_IF -o $INT_IF -p tcp --syn -d 192.168.0.5 \
--dport 21 -j ACCEPTthe above assumes you have a rule in FORWARD that accepts established packets, such as:
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
hth...
-j
--
"Well, I'm tired of being a wannabe league bowler. I wanna be a
league bowler!"
--The Simpsons
iptables -t nat -A PREROUTING -i $EXT_IF -p tcp -s $PublicIPAdd -d 202.147.167.99 \
--dport 21 -j DNAT --to-destination 192.168.0.5
Deepak Seshadri
----- Original Message ----- From: "Test Mail" <[email protected]>
To: "Netfilter Mailing List" <[email protected]>
Sent: Friday, January 14, 2005 3:57 AM
Subject: Re: FTP Forwarding
Quoted 89 lines
Hi!Can i have a follow up question regarding FTP server inside internal LAN which can be seen in the internet.....
now what if the scenario is i want to restrict a specific Public IP Address in using my FTP what will be the rules that i should apply?I was thinking of setting up a rule that will filter incomming Public IP Address request for ftp before it forwards it into my internal FTP Server.
Below are the sample entry in my iptables:
iptables -t filter -A INPUT -p tcp -s $PublicIPAdd --dport 20:21 -j ACCEPT <--- is this correct?
iptables -t filter -A INPUT -j DROPBelow are the previous solution that you gave.
modprobe
ip_conntrack_ftp
modprobeip_nat_ftpiptables -t nat -A PREROUTING -i $EXT_IF -p tcp -d 202.147.167.99 \
--dport 21 -j DNAT --to-destination 192.168.0.5iptables -A FORWARD -i $EXT_IF -o $INT_IF -p tcp --syn -d 192.168.0.5 \
--dport 21 -j ACCEPTthe above assumes you have a rule in FORWARD that accepts established packets, such as:
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
hth...
-j
Thanks in advance!
Milo----- Original Message -----
From: "Jason Opperisano" <[email protected]>
To: <[email protected]>
Sent: Wednesday, December 29, 2004 01:30 AM
Subject: Re: FTP ForwardingQuoted 6 lines · umar draz
Quoted 5 lines
Hi Dear Members!
i have linux machine which configured as a router
my linux router has 2 NIC one with Public ip 202.147.167.99 and other
is local ip 192.168.0.1
Quoted 1 line
Quoted 1 line
i have a another linux machine which configured as a FTP server and
that machine ip is 192.168.0.5. Now i want my this ftp server can be access all world. so what kind of iptables rules will be add on linux router that if some one want to access ftp 202.147.167.99 its automaticaly forward or redirect my local machine 192.168.0.5.
Quoted 31 lines
Quoted 6 lines
Please help me in this regard
Thanks
Umar
modprobe
ip_conntrack_ftp
modprobeip_nat_ftpiptables -t nat -A PREROUTING -i $EXT_IF -p tcp -d 202.147.167.99 \
--dport 21 -j DNAT --to-destination 192.168.0.5iptables -A FORWARD -i $EXT_IF -o $INT_IF -p tcp --syn -d 192.168.0.5 \
--dport 21 -j ACCEPTthe above assumes you have a rule in FORWARD that accepts established packets, such as:
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
hth...
-j
--
"Well, I'm tired of being a wannabe league bowler. I wanna be a
league bowler!"
--The Simpsons
Quoted 3 lines · Deepak Seshadri
iptables -t nat -A PREROUTING -i $EXT_IF -p tcp -s $PublicIPAdd -d
202.147.167.99 \ --dport 21 -j DNAT --to-destination 192.168.0.5
personally--i don't believe in filtering in NAT. nat in NAT, and filter in FILTER; that's why they're there. it makes the rule set much easier to troubleshoot, and it saves you time a year from now when you look at your rules and can't figure out why you can't FTP to that server from some random IP address, since the FILTER rule is wide open.
-j
--
"Let us all bask in television's warm glowing warming glow."
--The Simpsons
Quoted 12 lines
-----Original Message-----
From: [email protected] [mailto:netfilter- [email protected]] On Behalf Of Jason Opperisano
Sent: Friday, January 14, 2005 9:28 AM
To: [email protected]
Subject: Re: FTP ForwardingQuoted 3 lines · Deepak Seshadri
iptables -t nat -A PREROUTING -i $EXT_IF -p tcp -s $PublicIPAdd -d
202.147.167.99 \ --dport 21 -j DNAT --to-destination 192.168.0.5
Quoted 6 lines
personally--i don't believe in filtering in NAT. nat in NAT, and filter in FILTER; that's why they're there. it makes the rule set much easier to troubleshoot, and it saves you time a year from now when you look at your rules and can't figure out why you can't FTP to that server from some random IP address, since the FILTER rule is wide open.
Hmm .... thank you for clarifying.
Quoted 1 line
-j
Deepak
Quoted 15 lines · Test Mail
Hi!Can i have a follow up question regarding FTP server inside internal LAN which can be seen in the internet.....
now what if the scenario is i want to restrict a specific Public IP Address in using my FTP what will be the rules that i should apply?I was thinking of setting up a rule that will filter incomming Public IP Address request for ftp before it forwards it into my internal FTP Server.
Below are the sample entry in my iptables:
iptables -t filter -A INPUT -p tcp -s $PublicIPAdd --dport 20:21 -j ACCEPT <--- is this correct?
iptables -t filter -A INPUT -j DROPBelow are the previous solution that you gave.
Quoted 8 lines
modprobe
ip_conntrack_ftp
modprobeip_nat_ftpiptables -t nat -A PREROUTING -i $EXT_IF -p tcp -d 202.147.167.99 \ --dport 21 -j DNAT --to-destination 192.168.0.5iptables -A FORWARD -i $EXT_IF -o $INT_IF -p tcp --syn -d 192.168.0.5 \
--dport 21 -j ACCEPT
change that rule to something like:
iptables -A FORWARD -i $EXT_IF -o $INT_IF -p tcp --syn \
-s $PublicIPAdd -d 192.168.0.5 --dport 21 -j ACCEPTrepeat for multiple instances of $PublicIPAdd.
-j
--
"It's not easy to juggle a pregnant wife and a troubled child, but
somehow I managed to fit in eight hours of TV a day."
--The Simpsons
----- Original Message -----
From: "Jason Opperisano" <[email protected]>
To: <[email protected]>
Sent: Friday, January 14, 2005 10:23 PM
Subject: Re: FTP Forwarding
Quoted 2 lines · Test Mail
Quoted 1 line
Hi!Can i have a follow up question regarding FTP server inside internal
LAN
Quoted 2 lines
Quoted 2 lines
which can be seen in the internet.....
now what if the scenario is i want to restrict a specific Public IP
Address
Quoted 4 lines
Quoted 4 lines
in using my FTP what will be the rules that i should apply?
I was thinking of setting up a rule that will filter incomming Public IP Address request for ftp before it forwards it into my internal FTP
Server.
Quoted 3 lines
Quoted 3 lines
Below are the sample entry in my iptables:
iptables -t filter -A INPUT -p tcp -s $PublicIPAdd --dport 20:21 -j
ACCEPT
Quoted 19 lines
Quoted 5 lines
<--- is this correct?
iptables -t filter -A INPUT -j DROPBelow are the previous solution that you gave.
Quoted 8 lines
modprobe
ip_conntrack_ftp
modprobeip_nat_ftpiptables -t nat -A PREROUTING -i $EXT_IF -p tcp -d 202.147.167.99 \ --dport 21 -j DNAT --to-destination 192.168.0.5iptables -A FORWARD -i $EXT_IF -o $INT_IF -p tcp --syn -d 192.168.0.5 \
--dport 21 -j ACCEPTchange that rule to something like:
iptables -A FORWARD -i $EXT_IF -o $INT_IF -p tcp --syn \ -s $PublicIPAdd -d 192.168.0.5 --dport 21 -j ACCEPT
Quoted 9 lines
repeat for multiple instances of $PublicIPAdd.
-j
--
"It's not easy to juggle a pregnant wife and a troubled child, but
somehow I managed to fit in eight hours of TV a day."
--The Simpsons
I'm sorry but i think this rule will not be the solution to my problem cause my ftp server is inside my internal network and automatically my gateway will "only" be the source from the -s $PublicIPAdd Forward rule parameter... i think???
Below is my schematic on how i want it to be ..
1. only 202...1 ip address in my branch office should be allowed to use
my ftp server in my head office
so incoming ftp request should be filtered and only 202....1 ip
address that is coming from my branch office should be allowed.
| Branch | eth0 202. .1 < external
|
|
| WAN |
|
|
|gateway:firewall:FCore2| eth0 192.168... < internal <<<<<<
| eth1 202........ <external
|
|
|Ftp Server:FCore2| eth0 192.168.0.5 < Internal--------CUT ---------------------------------------------------------------- :::::2nd Question:::::
if i apply a policy >>>> iptables -P INPUT DROP
iptables -t filter -A INPUT -p tcp -s
192.168.0.1 -d 192.168.0.2 --dport 20:21 ACCEPT
means only 192.168.0.1 will only be allowed to use ftp and the rest will be drop ???? am i correct??
--------CUT-----------------------------------------------------------------
Thanks in advance.
Still learning iptables..
Milo
Quoted 4 lines · TestMail
I'm sorry but i think this rule will not be the solution to my problem cause my ftp server is inside my internal network and automatically my gateway will "only" be the source from the -s $PublicIPAdd Forward rule parameter... i think???
either you or i misunderstands what $PublicIPAdd stands for.
Quoted 7 lines
Below is my schematic on how i want it to be ..
1. only 202...1 ip address in my branch office should be allowed to use
my ftp server in my head officeso incoming ftp request should be filtered and only 202....1 ip
address that is coming from my branch office should be allowed.
Quoted 11 lines
| Branch | eth0 202. .1 < external
|
|
| WAN |
|
|
|gateway:firewall:FCore2| eth0 192.168... < internal <<<<<<
| eth1 202........ <external
|
|
|Ftp Server:FCore2| eth0 192.168.0.5 < Internalnow that you've provided some more details:
iptables -A FORWARD -i eth1 -o eth0 -p tcp --syn \
-s 202.x.x.1 -d 192.168.0.5 --dport 21 -j ACCEPT
-j
--
"To alcohol: the cause of, and solution to, all of life's problems."
--The Simpsons