Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Say I want to route all requests to to localhost:333 , how to do so?

share|improve this question
Interesting and suspicious question =). – RJFalconer Jan 9 '10 at 18:20

Shorewall routes. (FAQ)

You want to redirect all local connection requests to a server running in your local zone at and listening on port 333. Your local interface is eth1.

Disclaimer; I've not done exactly this with Shorewall, so modified an example Squid server setup:

  1. Add this entry to your /etc/shorewall/providers file.

    foo     1       202     -               eth1       loose
  2. In /etc/shorewall/tcrules add:

    #MARK    SOURCE              DEST        PROTO    DEST
    #                                                 PORT(S)
    202:P   tcp      80
  3. In /etc/shorewall/interfaces :

    loc     eth1         detect       routeback          
  4. On localhost, arrange for the following command to be executed after networking has come up

    iptables -t nat -A PREROUTING -i eth0 -d ! -p tcp --dport 80 -j REDIRECT --to-ports 333          
share|improve this answer
redirecting google by hand-added IPs won't work very well -- you'll get a different IP for the DNS lookup every 5 minutes or so due to load balancing. for, you'd really want to reroute at the DNS level. can Shorewall do that? – quack quixote Jan 9 '10 at 18:18
I suspect "" should do the trick. Yeah, you caught me mid edit there. – RJFalconer Jan 9 '10 at 18:19
fair enuff. leaving the comment for the time being but glad to see you were working on it already. :) – quack quixote Jan 9 '10 at 18:25
That's the best I can come up with I think. I'll leave it here for someone more experienced with shorewall to comment on / edit. – RJFalconer Jan 9 '10 at 18:35
I want it to be on the same machine, so pinging should go to some port that I specify on my local machine, say 333 – khelll Jan 9 '10 at 21:51

If you just want to do this on a single machine, you can edit:


and add

then restart network services

/etc/rc.d/init.d/network restart

This would redirect normal web traffic to localhost:80 though.

share|improve this answer
Nice idea to keep track of local network connections! :D – dag729 Jan 9 '10 at 21:30
That's what I wanted originally but also I want to control to which port the request will go. – khelll Jan 9 '10 at 21:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.