LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-22-2007, 10:33 PM   #1
talusog
LQ Newbie
 
Registered: Feb 2007
Posts: 11

Rep: Reputation: 0
how to port forward


hello everyone..
what is the command to forward port 21(ftp) request to 192.168.x.xx(this acts as a ftp server) in my linux gateway.i am using mandrake 10.can anybody pls help me.i cannot connect to my ftp server when i try to access it outside.
 
Old 03-23-2007, 08:45 AM   #2
Quigi
Member
 
Registered: Mar 2003
Location: Cambridge, MA, USA
Distribution: Ubuntu (Dapper and Heron)
Posts: 377

Rep: Reputation: 31
Usually 'iptables', but I don't know Mandrake. Iptables is discussed plenty and recently on linuxquestions.

You probably have NAT-HOWTO.html right on your coputer, maybe in /usr/share/doc/iptables/html/ -- otherwise see http://www.netfilter.org/documentati...NAT-HOWTO.html. It states that port forwarding is a form of DNAT, and explains how to do it.

Last edited by Quigi; 03-23-2007 at 08:59 AM.
 
Old 03-23-2007, 02:59 PM   #3
linuxjamil
Member
 
Registered: Dec 2005
Distribution: Fedora Core 5, Sun Solaris 8
Posts: 122

Rep: Reputation: 15
Wink port forwarding

I dont know why u need to forward the port as 21 port data connefction port already assigned for ftp service ...used for enabling data control connection for ftp server
 
Old 03-23-2007, 08:11 PM   #4
ethics
Senior Member
 
Registered: Apr 2005
Location: London
Distribution: Arch - Latest
Posts: 1,522

Rep: Reputation: 45
Quote:
Originally Posted by linuxjamil
I dont know why u need to forward the port as 21 port data connefction port already assigned for ftp service ...used for enabling data control connection for ftp server
If his linux gateway is infact a gateway as suggested, he would need to forward the connections onto a machine running the ftp server...
 
Old 03-24-2007, 10:38 PM   #5
talusog
LQ Newbie
 
Registered: Feb 2007
Posts: 11

Original Poster
Rep: Reputation: 0
yah.i have a linux gateway which is also a proxy cahing server(squid)and i want to forward ftp connections to my ftp server(cerberus ftp)that runs on windows 2003 which is inside my network.i have no bright idea about port forwarding on linux so i jump into this forum for help and info..anyway i have done searching and looking at some linux forums and someone suggested that i should used rinetd but further searching revealed that rinetd does not redirect ftp because ftp uses more that one socket.another one suggested that i should do this iptable rule on my firewall script:

iptables -t nat -I PREROUTING -p tcp -i INTERNET --dport 21 -j DNAT --to 192.168.x.xx:21

where INTERNET is my gateway(eth0).

is that correct? or is there anything else that i should do.how about rinetd?is it true that rinetd wont work on ftp or is there a workaround for it?

thanks for all the help and suggestions.
 
Old 03-28-2007, 01:57 AM   #6
fotoguy
Senior Member
 
Registered: Mar 2003
Location: Brisbane Queensland Australia
Distribution: KirraMail Live Email Server
Posts: 1,285

Rep: Reputation: 61
Quote:
Originally Posted by talusog
yah.i have a linux gateway which is also a proxy cahing server(squid)and i want to forward ftp connections to my ftp server(cerberus ftp)that runs on windows 2003 which is inside my network.i have no bright idea about port forwarding on linux so i jump into this forum for help and info..anyway i have done searching and looking at some linux forums and someone suggested that i should used rinetd but further searching revealed that rinetd does not redirect ftp because ftp uses more that one socket.another one suggested that i should do this iptable rule on my firewall script:

iptables -t nat -I PREROUTING -p tcp -i INTERNET --dport 21 -j DNAT --to 192.168.x.xx:21

where INTERNET is my gateway(eth0).

is that correct? or is there anything else that i should do.how about rinetd?is it true that rinetd wont work on ftp or is there a workaround for it?

thanks for all the help and suggestions.
Yeah that's getting the idea, but you also need to turn on port forwarding in the kernel if it's not already turned on, most distro's will not turn it on by default. try

turn on ip forwarding:
Code:
echo "1" > /proc/sys/net/ipv4/ip_forward
turn off ip forwarding
Code:
echo "0" > /proc/sys/net/ipv4/ip_forward
And then you will need a forwarding rule to allow the packet to now traverse the forward chain:

Code:
iptables -A FORWARD -p tcp -i INTERNET --dport 21 -d 192.168.x.xx -j ACCEPT
And I think you will need to load the modules for ftp tracking, this is used to except the data port 20 that ftp uses

Code:
/sbin/modprobe ip_nat_ftp
/sbin/modprobe ip_conntrack_ftp

Last edited by fotoguy; 03-28-2007 at 01:59 AM.
 
  


Reply

Tags
forwarding, port


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
forward port to another on the same IP 5amYan Linux - Security 2 08-23-2005 11:26 AM
Port Forward prbspfc Linux - Networking 9 03-24-2004 06:00 AM
A way to forward an IP/Port to another system's IP/Port astroboy5714 Linux - Networking 6 01-26-2004 05:45 PM
Port forward help please hanxuerui Linux - Networking 6 05-05-2003 01:20 PM
Forward port port 80 to lan web server dulaus Linux - Networking 9 10-04-2002 03:45 AM


All times are GMT -5. The time now is 05:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration