INTELLIGENT WORK FORUMS FOR COMPUTER PROFESSIONALS
Come Join Us!
Are you a Computer / IT professional? Join Tek-Tips now!
- Talk With Other Members
- Be Notified Of Responses
To Your Posts
- Keyword Search
- One-Click Access To Your
Favorite Forums
- Automated Signatures
On Your Posts
- Best Of All, It's Free!
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.
Partner With Us!
"Best Of Breed" Forums Add Stickiness To Your Site

(Download This Button Today!)
Member Feedback
"...Congratulations on a brilliant idea and a great site..."
Geography
Where in the world do Tek-Tips members come from?
|
iptable PREROUTING questions
|
|
|
stfaprc (Programmer) |
11 Oct 07 18:14 |
Running RH FC4. I want to redirect requests to local port 8080 to another server's port 80 (which is working). I tried: echo 1 > /proc/sys/net/ipv4/ip_forward
/sbin/iptables -t nat -A PREROUTING -p tcp --dport 8080 -j DNAT --to 192.168.1.53:80
/sbin/iptables -t nat -A PREROUTING -p tcp --dport 8080 -j LOG --log-prefix "PREROUTING: " --log-tcp-options --log-ip-options
----- when i try accessing 8080 with a browser, nothing seems to happen and eventually the browser times out. The only lines showing in messages log on the server is: Oct 11 15:01:02 ls2 kernel: Removing netfilter NETLINK layer. Oct 11 15:01:03 ls2 kernel: ip_tables: (C) 2000-2006 Netfilter Core Team Oct 11 15:01:03 ls2 kernel: Netfilter messages via NETLINK v0.30. Oct 11 15:01:03 ls2 kernel: ip_conntrack version 2.4 (1920 buckets, 15360 max) - 224 bytes per conntrack ----- Questions: what is the proper syntax for redirecting to the other server?
I may not know the interface number at all times - How can I get iptable to listen for a specific local ipaddress ?
How can I have the log entries go to a file other than the "messages" log file?
Thanks. |
|
zeland (IS/IT--Management) |
11 Oct 07 19:38 |
Your PREROUTING syntax seem a bit vague. It should be more like: CODEiptables -A PREROUTING -t nat -i EXT_IF -p tcp -d EXT_IP --dport 80 -j DNAT --to-destination 192.168.1.53:80 EXT_IF = Incoming interface EXT_IP = Router IP Once we have changed the information for the incoming packet, we need to allow it through CODEiptables -A FORWARD -i EXT_IF -p tcp -d 192.168.1.53 --dport 80 -j ACCEPT --== Anything can go wrong. It's just a matter of how far wrong it will go till people think its right. ==--
|
|
|
stfaprc (Programmer) |
12 Oct 07 13:03 |
Can I use an ip address instead of "-i EXT_IF" ?
So to do this redirection I need to have 3 iptable commands: PREROUTING -p tcp --dport 8080 -j DNAT --to 192.168.1.53:80
PREROUTING -p tcp --dport 8080 -j LOG --log-prefix "PREROUTING: " --log-tcp-options --log-ip-options
FORWARD -p tcp -d 192.168.1.53 --dport 80 -j ACCEPT ?
|
|
zeland (IS/IT--Management) |
12 Oct 07 19:57 |
Quote: Can I use an ip address instead of "-i EXT_IF" ?
No, -i must be an interface name, i.e. eth0, eth1. Quote: So to do this redirection I need to have 3 iptable commands
Technically you only need 2. I'm not sure you can have logging at the PRE/POSTROUTING sections. You could however log it at the FORWARD section. --== Anything can go wrong. It's just a matter of how far wrong it will go till people think its right. ==--
|
|
|
stfaprc (Programmer) |
14 Oct 07 17:49 |
hmm, than it seems that I am going about this the wrong way.
Situation: we are using simpleproxy to redirect ports on specific ip address to another pc (ie: simpleproxy -L 10.10.10.11:80 -R 192.168.1.58:80 -d)
It works fine, except that the target server sees the requests as coming from 10.10.10.11 and putting that in the web logs, whereas we want to see the real originating address (ie: 255.001.001.257) in the web logs of the target server.
|
|
zeland (IS/IT--Management) |
14 Oct 07 20:35 |
Quote: ...we want to see the real originating address
That is not possible. By nature of their design, proxies (as opposed to routers) don't forward the original connection request but instead initiates a separate connection to the destination, retrieving related information and storing it in its cache, hence the name proxy. --== Anything can go wrong. It's just a matter of how far wrong it will go till people think its right. ==--
|
|
|
 |
|