Configure a DNS server vanaf nic interface (eth0
Related movie: Four Ordinary Order Flow Strategies for Trading Bitcoin
You can’t lightly do what you want.
Or how do I configure a different DNS Name Server for eth0 vs eth1?
The name lookup for a hostname happens through standard system libraries and isn’t associated te any way with a particular “connection”. Te fact, at the time the DNS query happens, there is no connection, because your application hasn’t even figured out the address to which it’s going to connect (which is why it’s using DNS ter the very first place).
How do I get it to respect the DNS settings ter ifcfg rather than a default for resolv.conf?
The Linux resolver only has a single, mundial configuration ( /etc/resolv.conf ). There is no per-interface, per-domain, or per-connection setting of any sort. The settings ter /etc/sysconfig/network-scripts/. are only used to populate /etc/resolv.conf , and generally if you specify DNS1 and DNS2 ter thesis files, the last interface to come up will be what you see te /etc/resolv.conf .
Is there a better way of treating this?
Can you tell us what you’re actually attempting to accomplish? Wij might be able to suggest better solutions if you can tell us more about your specific situation.
A DNS request is basically either
- “what’s the IP address of host1.domain1.com,” or
- “what’s the hostname of 192.168.0.Five.”
So there’s no knowing at “request” time which Ethernet card is going to be involved. What you could reasonably ask would be “all requests ending te ‘domain1.com’ should go to 192.168.0.Two, and all other requests should go to Ten.0.0.Two.”
And likewise, “All switch roles DNS requests matching 192.168.0.0/24 should go to 192.168.0.Two, and the surplus should go to Ten.0.0.Two.”
Spil larsks said, Linux doesn’t support such a configuration. However, you could run your own, minimal DNS server that implements the above logic, and forwards requests to the adequate “auténtico” DNS server.
I believe dnsmasq can do this (see How to configure dnsmasq to forward numerous DNS servers?). But before I found that out, I spinned my own te Twisted:
The response to all your three questions is now systemd-resolved (emphasis mine):
Lookup requests are routed to the available DNS servers and LLMNR interfaces according to the following rules:
Lookups for the special hostname “localhost” are never routed to the network. (A few other, special domains are treated the same way.)
Single-label names are routed to all regional interfaces capable of IP multicasting, using the LLMNR protocol. Lookups for IPv4 addresses are only sent via LLMNR on IPv4, and lookups for IPv6 addresses are only sent via LLMNR on IPv6. Lookups for the locally configured host name and the “gateway” host name are never routed to LLMNR.
Multi-label names are routed to all lugar interfaces that have a DNS sever configured, plus the globally configured DNS server if there is one. Address lookups from the link-local address range are never routed to DNS.
If lookups are routed to numerous interfaces, the very first successful response is returned (thus effectively merging the lookup zones on all matching interfaces). If the lookup failed on all interfaces, the last failing response is returned.