Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 11-11-2003, 11:11 AM   #1
LQ Newbie
Registered: Nov 2003
Posts: 10

Rep: Reputation: 0
Question communication redirection

Hi there.
I am absolutely new in this, and I have something to solve.

I have 2 Linux acting as proxy servers. Each Linux connects two different nets to Internet, so each of them have two nics, with one public and one private IP address.

The fact is: I need to redirect connection attempted to the externalIP and PORT (For example, port 110) to an internal IP (for example port 110)

I think I must use iptables, but MAN is a bit confusing thing to mee yet.

Thanks in advance

Old 11-11-2003, 09:33 PM   #2
Registered: Aug 2003
Location: Arizona
Distribution: Gentoo
Posts: 142

Rep: Reputation: 15
eth0 is bound to the external IP
eth1 is bound to the internal 10.0.0.X

This example uses the IPs you gave above.

# Delete and flush. Default table is "filter". Others like "nat" must be explicitly stated.
iptables --flush
iptables --table nat --flush
iptables --delete-chain
iptables --table nat --delete-chain

# Set up IP FORWARDing and Masquerading
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface eth1 -j ACCEPT

# Allow loopback access. This rule must come before the rules denying port access!!
iptables -A INPUT -i lo -p all -j ACCEPT
iptables -A OUTPUT -o lo -p all -j ACCEPT

#Used for forwarding ports to Internal Box
iptables -t nat -A PREROUTING -p tcp -d --dport 110 -j DNAT --to-destination
iptables -A FORWARD -o eth1 -p tcp -d --dport 100 -m state --state NEW -j ACCEPT

echo 1 > /proc/sys/net/ipv4/ip_forward
I use that code on a firewall box and I haven't had any problems with it.


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
communication between threads alaios Programming 9 07-15-2005 05:39 PM
comport communication neerukamra Linux - General 0 09-06-2004 01:18 AM
redirection in C pantera Programming 2 08-11-2004 02:06 PM
communication redirection chtthies Linux - Networking 1 12-08-2003 11:49 AM
communication apps Daniel Nichols General 2 03-07-2001 11:30 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:10 AM.

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