Split DNS Server to use internal and external ip
First we need to setup our /etc/named.conf configuration
options {
listen-on port 53 { 127.0.0.1; 192.168.0.107; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query { any; };
forwarders {
8.8.8.8; 8.8.4.4;
};
dnssec-enable yes;
dnssec-validation yes;
bindkeys-file "/etc/named.iscdlv.key";
managed-keys-directory "/var/named/dynamic";
pid-file "/run/named/named.pid";
session-keyfile "/run/named/session.key";
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
#Create a Access Control List for the internal networks that can query the dns
acl internals {
127.0.0.0/8;
10.0.0.0/24;
};
#Create 2 views internal and external
view "internal" {
match-clients { internals; };
recursion yes;
zone "example.com" {
type master;
file "/var/named/int.example.com";
};
};
view "external" {
match-clients { any; };
recursion no;
zone "example.com" {
type master;
file "/var/named/ex.example";
};
};
Create 2 files as follow 1 for internal and other for external changing the respective ip for external and internal networks
int.example
; exaple.com
$TTL 604800
@ IN SOA ns1.example.com. root.example.com. (
2006020201 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800); Negative Cache TTL
;
@ IN NS ns1
IN MX 10 mail
IN A 192.168.0.107
ns1 IN A 192.168.0.107
mail IN A 192.168.0.107 ; We have our mail server somewhere else.
2. Start the named service
systemctl start named
3.- Check if the dns respose to the query with nslookup
root#> nslookup
root#>server localhost
> example.com
Name: example.com
Address: 192.168.0.107
Comments
Post a Comment