LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 11-11-2003, 10:11 AM   #1
chtthies
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, 200.69.219.229 port 110) to an internal IP (for example 192.168.5.1 port 110)

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

Thanks in advance

Christian
 
Old 11-11-2003, 08:33 PM   #2
Khabi
Member
 
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.
Code:
#!/bin/bash

# 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 200.69.219.229 --dport 110 -j DNAT --to-destination 192.168.5.1
iptables -A FORWARD -o eth1 -p tcp -d 192.168.5.1 --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.
 
  


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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:24 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
Open Source Consulting | Domain Registration