Como impor que o dnsmasq use um servidor de dns upstream apenas para alguns nomes de domínio especificados?

12

Agora eu tenho a seguinte linha no dnsmasq.conf, que lida bem com todas as solicitações ( /#/ corresponde a qualquer domínio; isso é obrigatório):

address=/#/127.0.0.1

No entanto, existem alguns domínios que precisam ser resolvidos para endereços IP diferentes de 127.0.0.1 .

Como solução temporária, eles foram adicionados ao /etc/hosts :

209.85.148.95   ajax.googleapis.com
207.97.227.245  underscorejs.org
72.21.194.31    s3.amazonaws.com

Infelizmente, essa é uma solução muito temporária: ela deixará de funcionar assim que o endereço IP de qualquer domínio de destino for alterado.

A minha pergunta é: como impor o dnsmasq para usar um servidor de dns upstream para resolver os endereços IP de alguns nomes de domínio (especificados)?

    
por nrph 24.08.2012 / 09:59

1 resposta

23

Você pode fazer isso usando a server= directive, por exemplo,

server=/ajax.googleapis.com/8.8.8.8

consultaria o servidor DNS público do google para o domínio ajax.googleapis.com, da mesma forma

server=/amazonaws.com/209.244.0.3

consultaria o servidor DNS público da Level3 para o domínio amazonaws.com.

Você pode agrupar vários domínios juntos

server=/co.uk/com/8.8.4.4

Envia os domínios .co.uk e .com para o servidor DNS em 8.8.4.4

Você também pode ter várias diretivas server=

−S, --server=[/[<domain>]/[domain/]][<ipaddr>[#<port>][@<source>[#<port>]]]

Specify IP address of upstream severs directly. Setting this flag does not suppress reading of /etc/resolv.conf, use -R to do that. If one or more optional domains are given, that server is used only for those domains and they are queried only using the specified server. This is intended for private nameservers: if you have a nameserver on your network which deals with names of the form xxx.internal.thekelleys.org.uk at 192.168.1.1 then giving the flag -S /internal.thekelleys.org.uk/192.168.1.1 will send all queries for internal machines to that nameserver, everything else will go to the servers in /etc/resolv.conf. An empty domain specification, // has the special meaning of "unqualified names only" ie names without any dots in them. A non-standard port may be specified as part of the IP address using a # character. More than one -S flag is allowed, with repeated domain or ipaddr parts as required.

Also permitted is a -S flag which gives a domain but no IP address; this tells dnsmasq that a domain is local and it may answer queries from /etc/hosts or DHCP but should never forward queries on that domain to any upstream servers. local is a synonym for server to make configuration files clearer in this case.

The optional second IP address after the @ character tells dnsmasq how to set the source address of the queries to this nameserver. It should be an address belonging to the machine on which dnsmasq is running otherwise this server line will be logged and then ignored. The query-port flag is ignored for any servers which have a source address specified but the port may be specified directly as part of the source address.

    
por 24.08.2012 / 13:34