LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-13-2006, 09:16 AM   #1
shorto
Member
 
Registered: Jul 2006
Distribution: Debian 6.0.2.1 i386
Posts: 111

Rep: Reputation: 15
Iptables port forwording


Hi!
I just wanted to ask does anyone know how to "modify" this command:

iptables -t nat -A PREROUTING -p TCP --dport 6689 -j REDIRECT --to-port 6689

so that the port will forward from 192.168.0.1 to 192.168.0.2 (From my Linux server to my Workstation), so I can be connectable on irc, torrents and other p2p programs. I was given the command at one point by someone but not on a forum on irc but i had to format my disk and this is the only "simular" command that i could find to tell you what i need (even n00bs have to exist don't we? )

Tnx in advance,
shorto
 
Old 07-13-2006, 09:23 AM   #2
cdhgee
Member
 
Registered: Oct 2003
Location: St Paul, MN
Distribution: Fedora 8, Fedora 9
Posts: 513

Rep: Reputation: 30
Try this:

Code:
iptables -t nat -A PREROUTING -p TCP --dport 6689 -j REDIRECT --to-destination 192.168.0.2:6689
I haven't tested this so I can't guarantee it works but something like this ought to. Have a look at the iptables man page if you get stuck.
 
Old 07-13-2006, 09:26 AM   #3
shorto
Member
 
Registered: Jul 2006
Distribution: Debian 6.0.2.1 i386
Posts: 111

Original Poster
Rep: Reputation: 15
shorto:/home/shorto# iptables -t nat -A PREROUTING -p TCP --dport 32459 -j REDIRECT --to-destination 192.168.0.2:32459
iptables v1.2.11: Unknown arg `--to-destination'
Try `iptables -h' or 'iptables --help' for more information.

tnx for the link will try to get it right
 
Old 07-13-2006, 09:30 AM   #4
cdhgee
Member
 
Registered: Oct 2003
Location: St Paul, MN
Distribution: Fedora 8, Fedora 9
Posts: 513

Rep: Reputation: 30
Just found this link too, ignore the bit about the bastille firewall but the bit about iptables might help you. It's for a slightly older version of the kernel though so somethings may have changed since then.
 
Old 07-13-2006, 09:40 AM   #5
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
-j REDIRECT changes ports within the same machine (to redirect port 80 to 8080, for example). You need to use -j DNAT (destination network address translation) instead.
 
Old 07-13-2006, 11:19 AM   #6
shorto
Member
 
Registered: Jul 2006
Distribution: Debian 6.0.2.1 i386
Posts: 111

Original Poster
Rep: Reputation: 15
hmm now i don't get an error it just doesnt do what it's supposed to do
 
Old 07-13-2006, 11:30 AM   #7
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
You want connections from the internet (through the server) to reach 192.168.0.2, right? Make sure the port is open on the firewall as well as being NAT'd. You'd need
Code:
iptables -A FORWARD -p tcp --dport 6689 -j ACCEPT
 
Old 07-13-2006, 01:33 PM   #8
shorto
Member
 
Registered: Jul 2006
Distribution: Debian 6.0.2.1 i386
Posts: 111

Original Poster
Rep: Reputation: 15
iptables -t nat -A PREROUTING -p UDP --dport 32459 -j DNAT --to-destination 192.168.0.2:32459
iptables -A FORWARD -p tcp --dport 32459 -j ACCEPT

this is what i enterd but still nothing ): Matir yes thats what i need
 
Old 07-13-2006, 02:06 PM   #9
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
How have you tested that this is not working? What symptoms do you experience?
 
Old 07-13-2006, 02:19 PM   #10
shorto
Member
 
Registered: Jul 2006
Distribution: Debian 6.0.2.1 i386
Posts: 111

Original Poster
Rep: Reputation: 15
well i enter this and just restarted the aplications runing on my workstation (192.168.0.2) it was a torrent client and on the site it still says i'm unconnectable and my client says the same...
 
Old 07-13-2006, 02:50 PM   #11
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Did you open/forward all the neccessary ports? I don't remember exactly, but I seem to recall it being 6881-6899 or something similar.
 
Old 08-26-2006, 08:05 PM   #12
shorto
Member
 
Registered: Jul 2006
Distribution: Debian 6.0.2.1 i386
Posts: 111

Original Poster
Rep: Reputation: 15
well i forgot that i asked this here but thanks i have fixed the problem i found my old iptables save file and i just restored it and it works fine now.

thank you for your help
 
  


Reply



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
Iptables - incomming port to external port - possible? ziggie216 Linux - Software 1 07-13-2006 02:08 PM
Port Forwording Problem on Debian shorto Linux - Networking 2 07-09-2006 08:55 AM
port forwording siralek88 Linux - Networking 1 02-09-2005 07:12 PM
Can an one tell me the simple working method of Port Forwording abimanyu007 Linux - Networking 3 08-13-2004 03:43 AM
video forwording.. sound forwording? exodist Linux - Networking 0 06-01-2004 11:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:43 AM.

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
Open Source Consulting | Domain Registration