Answer the question
In order to leave comments, you need to log in
IP address, domain and subdomain?
And so the bottom line:
There is a server on CentOS (aka a gateway) configured iptables - ip address 22.22.22.22 external IP
There is a web server with the address - 33.33.33.33 (address - site.com) local IP
There is a mail server with the address - 44.44.44.44 (address subdomain.site.com) local IP
The question is how to make site.com redirect to 33.33.33.33 (web server) when contacting subdomain.site.com and redirect to 44.44.44.44 (mail server) when contacting subdomain.site.com
How can it be implemented via iptables or redirect?
Answer the question
In order to leave comments, you need to log in
and when accessing subdomain.site.com redirected to 44.44.44.44 (mail server)The mail server does not care about the domain when establishing a connection, so be guided by the port numbers.
iptables -A PREROUTING -d 22.22.22.22 -p tcp --dport 25 -j DNAT --to-destination 44.44.44.44
iptables -A PREROUTING -d 22.22.22.22 -p tcp --dport 465 -j DNAT --to-destination 44.44.44.44
iptables -A PREROUTING -d 22.22.22.22 -p tcp --dport 587 -j DNAT --to-destination 44.44.44.44
iptables -A PREROUTING -d 22.22.22.22 -p tcp --dport 80 -j DNAT --to-destination 33.33.33.33
iptables -A PREROUTING -d 22.22.22.22 -p tcp --dport 443 -j DNAT --to-destination 33.33.33.33
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question