LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-07-2011, 07:53 AM   #1
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Rep: Reputation: 107Reputation: 107
Question Redirect traffic coming on one port to port of another server


Hi All,

I have two CentOS 5.6 boxes and trying to redirect all traffic coming on port 80 on 192.168.1.10 to port 8080 on 192.168.1.100.

I am using below rules, but it is not working for me.

Code:
$ iptables -A FORWARD -m state -p tcp -d 192.168.1.100 --dport 8080 --state NEW,ESTABLISHED,RELATED -j ACCEPT
$ iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 192.168.1.100:8080

I tried running curl on 192.168.1.10
Code:
[root@box1 ~]# curl -i "http://192.168.1.10"
HTTP/1.1 302 Found
Date: Mon, 07 Nov 2011 13:49:58 GMT
Server: Apache
Location: /rhn/Login.do
Content-Length: 259
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="/rhn/Login.do">here</a>.</p>
<hr>
<address>Apache Server at 192.168.1.10 Port 80</address>
</body></html>
[root@box1 ~]#
and tcpdump on 192.168.1.100
Code:
[root@kick ~]# tcpdump -i eth0  port 8080 -vv
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes

Am I missing something ?

Last edited by vikas027; 11-07-2011 at 08:06 AM.
 
Old 11-07-2011, 12:48 PM   #2
_bsd
Member
 
Registered: Jan 2010
Location: Velveeta, USA
Distribution: Xen, Gentoo,Ubuntu,openSUSE,Debian,pfSense
Posts: 98

Rep: Reputation: 9
just curious if you've previously enabled ip forwarding?
cat /proc/sys/net/ipv4/ip_forward
is it 0 or 1?
 
Old 11-12-2011, 12:28 PM   #3
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Original Poster
Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by _bsd View Post
just curious if you've previously enabled ip forwarding?
cat /proc/sys/net/ipv4/ip_forward
is it 0 or 1?
Yes, I have done so.
 
  


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
with iptables, how-to redirect outgoing mail from port 25 to port 587 thumbelina Linux - Networking 12 03-19-2012 08:26 AM
Redirect incoming traffic to an other port (ubuntu openvpn server) krisox Linux - Newbie 3 12-06-2010 12:22 AM
[HELP] redirect traffic to spesific port based on Traffic Content using iptables summersgone Linux - Server 2 06-22-2009 11:26 AM
debian iptables squid - redirect port 80 to port 8080 on another machine nickleus Linux - Networking 1 08-17-2006 12:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:55 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