Geek Pop Quiz.
May. 8th, 2008 08:34 amI have a Ubuntu 6.06 server.
I want all tcp connections to port *X* on the server to automatically be seamlessly and quietly redirected to port *Y* on that very same server. And, obviously, the responses need to go back to the original host on that port. However, normal connections directly to port *Y* should not be affected.
I also want this change to be server-side only. No router changes, no nothing.
How can I do it?
EDIT:
zastrazzi came through with the correct wording of iptables I needed, and now I see my error. Yay!
I want all tcp connections to port *X* on the server to automatically be seamlessly and quietly redirected to port *Y* on that very same server. And, obviously, the responses need to go back to the original host on that port. However, normal connections directly to port *Y* should not be affected.
I also want this change to be server-side only. No router changes, no nothing.
EDIT:
(no subject)
Date: 2008-05-08 12:39 pm (UTC)iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080
(no subject)
Date: 2008-05-08 12:45 pm (UTC)Problem solved! Thanks.
(no subject)
Date: 2008-05-08 12:49 pm (UTC)(no subject)
Date: 2008-05-08 12:59 pm (UTC)And don't undervalue the ability to google *and* comprehend. It's important!
(no subject)
Date: 2008-05-08 01:31 pm (UTC)(no subject)
Date: 2008-05-08 06:29 pm (UTC)(no subject)
Date: 2008-05-08 07:04 pm (UTC)It's because I didn't have --to-port. I was just trying to redirect to localhost:Y and that was causing issues with the server process.