Koozali.org: home of the SME Server

Resolving a domain to another internal ip

Offline lox

  • *
  • 9
  • +0/-0
    • Gecka.com
Resolving a domain to another internal ip
« on: May 19, 2010, 06:13:13 AM »
Hello,

I want my smeserver dns server to resolve a domain to an internal ip on my network. How can I do that ?

Regards.

Edit1: I have made a little progress, here what I did:

Code: [Select]
nano /etc/e-smith/templates-custom/var/service/tinydns/root/data/80staticdomains

Added:

Code: [Select]
# Web.gecka.nc
# NS Records
.web.gecka.nc::web.gecka.nc
# MX Records
@web.gecka.nc::mail.web.gecka.nc
# A Records for domains
+web.gecka.nc:10.0.4.100
# A Records for Hosts in web.gecka.nc
=mail.web.gecka.nc:10.0.4.100
+www.web.gecka.nc:10.0.4.100

Then:

Code: [Select]
expand-template /var/service/tinydns/root/data
pushd /var/service/tinydns/root/ && tinydns-data && popd

I then restart tinydns and dnscache

Code: [Select]
service tinydns restart && service dnscache restart

So now if I dig web.gecka.nc @127.0.0.1

I get

Code: [Select]
;; QUESTION SECTION:
;web.gecka.nc. IN A

;; ANSWER SECTION:
web.gecka.nc. 86400 IN A 10.0.4.100

;; AUTHORITY SECTION:
web.gecka.nc. 259200 IN NS web.gecka.nc.

That is nice but if I ping web.gecka.nc, it won't resolve either from sme command line or from any computer on the internal network.

Any thought?
« Last Edit: May 19, 2010, 07:30:45 AM by lox »

Offline mmccarn

  • *
  • 2,656
  • +10/-0
Re: Resolving a domain to another internal ip
« Reply #1 on: May 19, 2010, 12:23:46 PM »
I don't know if it will work the same way on SME, but on microsoft networks, I just add each internal host as a domain in the DNS. 

That is, to create an internal mapping for "web.gecka.nc" (and assuming I don't want to affect "xyz.gecka.nc"), I would create a domain named "web.gecka.nc", then set the A record for '@'.

When you create a new domain, SME will automatically create "mail....", "ftp....", and some others -- I think you can delete these from the 'hostnames' panel.

If that doesn't work you will need to create a custom template for 'dnscache' as well as 'tinydns' before internal resolution will work.  'dnscache' needs an entry for each domain in /var/service/dnscache/root/servers indicating where to find authoritative DNS for that "domain".  For internally resolved domains, the DNS host to use is "127.0.0.1".

'dnscache' rebuilds all of the .../servers/... files whenever it restarts, so you can't just add a file and restart to test your settings -- you have to modify the templates or /var/service/dnscache/run.

Offline lox

  • *
  • 9
  • +0/-0
    • Gecka.com
Re: Resolving a domain to another internal ip
« Reply #2 on: May 20, 2010, 01:55:41 AM »
Hello,

That is, to create an internal mapping for "web.gecka.nc" (and assuming I don't want to affect "xyz.gecka.nc"), I would create a domain named "web.gecka.nc", then set the A record for '@'.

That way, web.gecka.nc will still point to my smeserver.

Quote
When you create a new domain, SME will automatically create "mail....", "ftp....", and some others -- I think you can delete these from the 'hostnames' panel.

If that doesn't work you will need to create a custom template for 'dnscache' as well as 'tinydns' before internal resolution will work.  'dnscache' needs an entry for each domain in /var/service/dnscache/root/servers indicating where to find authoritative DNS for that "domain".  For internally resolved domains, the DNS host to use is "127.0.0.1".

'dnscache' rebuilds all of the .../servers/... files whenever it restarts, so you can't just add a file and restart to test your settings -- you have to modify the templates or /var/service/dnscache/run.

This seems better to me. So, could I only alter dnscache configuration? If I create a /var/service/dnscache/root/servers/web.gecka.nc file with 10.0.4.100 in it ?

I created a template /etc/e-smith/templates-custom/var/service/dnscache/root/servers/web.gecka.nc, I can expand. But if I run "signal-event domain-modify" the file is deleted from /var/service/dnscache/root/servers/.

Any thought?

Offline janet

  • *****
  • 4,812
  • +0/-0
Re: Resolving a domain to another internal ip
« Reply #3 on: May 20, 2010, 02:35:56 AM »
lox

Quote
I want my smeserver dns server to resolve a domain to an internal ip on my network. How can I do that ?

I may be misunderstanding your request, but does the following answer your needs.
In server manager Domains panel, you can configure DNS for a domain to resolve locally rather than to Internet DNS servers.
Then in the Hostnames and Addresses server manager panel, you can specify a local host (local IP) for that domains hostname. I think you need to restart sme after doing those changes for them to "take effect".
Please search before asking, an answer may already exist.
The Search & other links to useful information are at top of Forum.

Offline lox

  • *
  • 9
  • +0/-0
    • Gecka.com
Re: Resolving a domain to another internal ip
« Reply #4 on: May 20, 2010, 05:36:37 AM »
My server is in Gateway mode. I want that all request to web.gecka.nc to be redirected to 10.0.4.100. If I create web.gecka.nc I must select an Ibay for it and the hostnames and addresses panel only allows me to change sub-domains like mail.web.gecka.nc but not web.gecka.nc itself.

Offline janet

  • *****
  • 4,812
  • +0/-0
Please search before asking, an answer may already exist.
The Search & other links to useful information are at top of Forum.

Offline lox

  • *
  • 9
  • +0/-0
    • Gecka.com
Re: Resolving a domain to another internal ip
« Reply #6 on: May 21, 2010, 02:54:29 AM »
Proxy pass only does it for http. Why is it so difficult to add a domain that point to another machine on local network?

Offline janet

  • *****
  • 4,812
  • +0/-0
Re: Resolving a domain to another internal ip
« Reply #7 on: May 21, 2010, 04:32:11 AM »
lox

Quote
Proxy pass only does it for http. Why is it so difficult to add a domain that point to another machine on local network?

I believe https is now also supported YMMV. You should remove the domain entry before setting up the proxy pass entry.

Re Hostnames and Addresses.
Did you try setting the internal IP for each hostname, surely that will achieve what you want, as any hostname related to that domain will forward to the nominated IP.

Otherwise please elaborate on what you are wanting to do and which services you want supported.

If it is just web, then you can easily add an index file in the ibay with suitable forwarding code. Search the forums for many suitable examples.

The issue is that SME only supports a single external IP, so such forwarding has to be done within the framework of SME server.

I should also add you can delegate email for all or some or one domain to another internal or external server, see
http://wiki.contribs.org/SME_Server:Documentation:FAQ#Deliver_ALL_email_to_a_single_internal_mail_server
and
http://wiki.contribs.org/SME_Server:Documentation:FAQ#Deliver_email_for_one_domain_to_an_internal_mail_server
Add a db command for each domain if delegating multiple domains.

You can also make use of the port forwarding panel to forward ports (for services) to another IP, but you will need to configure and use alternative port numbers, as the main sme server cannot share ports between itself and another host.
« Last Edit: May 21, 2010, 04:40:58 AM by mary »
Please search before asking, an answer may already exist.
The Search & other links to useful information are at top of Forum.