Welcome to the Linux Foundation Forum!

traffic redirection by domain name to external addresses

setevoy Posts: 1
edited April 2014 in Networking


We using Linux CentOS.

For example - we have 3 hosts - host1.domain.com, host2.domain.com, host3.domain.com. Hosts connected via VPN.

Task: host1.domain.com must be a gateway for http/https traffic, and redirect requestes to host2.domain.com and host3.domain.com.

host1.domain.com will have external IP and accepts request on 80 port.

host2.domain.com and host3.domain.com - internal IP and accepts request on 8080 and 8443 ports.

How this can be realised? IPTABLES, NGINX, something else?

And - what about other traffic? SSH, samba etc.



  • bingrenling
    For port redirection:

    iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080

    iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 8443

    From one IP to another and one port to another:

    iptables -t nat -I PREROUTING --src --dst -p tcp --dport 80 -j REDIRECT --to-ports 8080

    For the redirection of requests from host1 to host2 or host3 (assuming you are loadbalancing), I would probably actually use ldirector and not iptables.

    If you are also controlling your own DNS, you might use round-robin DNS to do this.


Upcoming Training