If you need to fool a machine into believing that a host:port pair is local, you can use ipchains to redirect traffic. For example, the desired destination is www.example.com:80 and you want it to go to localhost:8080:
# echo '1' > /proc/sys/net/ipv4/ip_forward # ipchains -A input -j REDIRECT 8080 -p tcp -s 0.0.0.0/0 -d 0.0.0.0/0 80
Note: No one really uses ipchains anymore, but it can be found on older systems.
commandsfirewallip_forwardipchainsloopredirectshell