DNS mask over LAN to redirect domain to local ip

0

I am trying to setup a DNS MASK to route over LAN like this: client requests https//example.com:4430 to be routed to server https://192.168.1.80:443

DNS mask is running on the server

I point my client to DNS 8.8.8.8 and try to access https//example.com:4430

on my server /etc/dnsmasq.conf

interface=eth0
domain-needed         
bogus-priv            
no-poll              
no-resolv             
cache-size=150 
server=8.8.8.8
address=/example.com/192.168.1.80 

my server /etc/hosts/

127.0.0.1 localhost
127.0.1.1 cloud
example.com

my server apache conf file

<IfModule mod_ssl.c>
 <VirtualHost _default_:443>
  DocumentRoot /var/www/nextcloud
  CustomLog /var/log/apache2/nc-access.log combined
  ErrorLog  /var/log/apache2/nc-error.log
  SSLEngine on
  SSLCertificateFile      /etc/ssl/certs/ssl-cert-snakeoil.pem
  SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
 </VirtualHost>
 <Directory /var/www/nextcloud/>
  Options +FollowSymlinks
  AllowOverride All
 <IfModule mod_dav.c>
  Dav off
 </IfModule>
  LimitRequestBody 0
  SSLRenegBufferSize 10486000
 </Directory>
</IfModule>

<IfModule mod_ssl.c>
 <VirtualHost *:4430>
  DocumentRoot /var/www/nextcloud
  CustomLog /var/log/apache2/nc-access.log combined
  ErrorLog  /var/log/apache2/nc-error.log
  SSLEngine on
  SSLCertificateFile      /etc/ssl/certs/ssl-cert-snakeoil.pem
  SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
 </VirtualHost>
 <Directory /var/www/nextcloud/>
 Options +FollowSymlinks
 AllowOverride All
 <IfModule mod_dav.c>
  Dav off
 </IfModule>
 LimitRequestBody 0
 SSLRenegBufferSize 10486000
 </Directory>
</IfModule>

jotyhista

Posted 2018-07-29T13:11:28.773

Reputation: 43

Answers

2

To use your dnsmasq instance you should make your client point your server and not 8.8.8.8 (or do a DNAT on the client router).

DNS is not enough to do what you want (redirect https//example.com:4430 to https://192.168.1.80:443) because DNS can "change" the address but can't "change" the port. So your *:4430 virtualhost should reply with a redirect to the port 443 in order to make it work.

An alternative to this is to do just a DNAT on the client router natting example_ip:4430 to server_ip:443.

Enrico Polesel

Posted 2018-07-29T13:11:28.773

Reputation: 61