Welcome to the Linux Foundation Forum!

traffic redirection by domain name to external addresses

Posts: 1
edited April 2014 in Networking

Hi.

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.

Thanks.

Comments

  • 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 1.1.1.1 --dst 2.2.2.2 -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.

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training