Can you assign different DNS servers to different network interfaces?
Clash Royale CLAN TAG#URR8PPP
I am trying to have my eth1 use 10.50.1.11 and 10.50.1.12 dns servers whilst my eth0 interface uses 8.8.8.8 and 8.8.4.4 dns servers.
I am running centos 7 vms within xenserver 6.5. eth1 is a closed-circuit vlan, whilst eth0 is the public network. The problem im having is that my centos
client automatically picks which dns server it uses based upon which interface comes up first. I know that when you define dns servers in
/etc/network-scripts/ifcfg-eth0 or /etc/network-scripts/ifcfg-eth1, it prints it out inside of /etc/resolv.conf, but i cant find a workaround for this.
Does anyone know if you can assign different DNS servers to different network interfaces?
centos networking dns network-interface xen
add a comment |
I am trying to have my eth1 use 10.50.1.11 and 10.50.1.12 dns servers whilst my eth0 interface uses 8.8.8.8 and 8.8.4.4 dns servers.
I am running centos 7 vms within xenserver 6.5. eth1 is a closed-circuit vlan, whilst eth0 is the public network. The problem im having is that my centos
client automatically picks which dns server it uses based upon which interface comes up first. I know that when you define dns servers in
/etc/network-scripts/ifcfg-eth0 or /etc/network-scripts/ifcfg-eth1, it prints it out inside of /etc/resolv.conf, but i cant find a workaround for this.
Does anyone know if you can assign different DNS servers to different network interfaces?
centos networking dns network-interface xen
3
DNS does not work as you think it works. It is global to the system, not based on interface.
– Rui F Ribeiro
Mar 5 at 17:31
1
This sounds like an XY problem. Consider asking a separate question where you explain what exactly is the end result that you want to achieve. This general question is still perfectly valid and interesting for people wondering how DNS resolution works.
– TooTea
Mar 5 at 18:05
1
You can use network namespaces, puteth0
andeth1
into different namespaces (or one in the main namespace, one in a new namespace). Network namespace allows different versions ofresolv.conf
in/etc/netns/<namespace_name>/resolv.conf
, at least for sufficiently modern applications that pay attention to that.
– dirkt
Mar 6 at 11:08
add a comment |
I am trying to have my eth1 use 10.50.1.11 and 10.50.1.12 dns servers whilst my eth0 interface uses 8.8.8.8 and 8.8.4.4 dns servers.
I am running centos 7 vms within xenserver 6.5. eth1 is a closed-circuit vlan, whilst eth0 is the public network. The problem im having is that my centos
client automatically picks which dns server it uses based upon which interface comes up first. I know that when you define dns servers in
/etc/network-scripts/ifcfg-eth0 or /etc/network-scripts/ifcfg-eth1, it prints it out inside of /etc/resolv.conf, but i cant find a workaround for this.
Does anyone know if you can assign different DNS servers to different network interfaces?
centos networking dns network-interface xen
I am trying to have my eth1 use 10.50.1.11 and 10.50.1.12 dns servers whilst my eth0 interface uses 8.8.8.8 and 8.8.4.4 dns servers.
I am running centos 7 vms within xenserver 6.5. eth1 is a closed-circuit vlan, whilst eth0 is the public network. The problem im having is that my centos
client automatically picks which dns server it uses based upon which interface comes up first. I know that when you define dns servers in
/etc/network-scripts/ifcfg-eth0 or /etc/network-scripts/ifcfg-eth1, it prints it out inside of /etc/resolv.conf, but i cant find a workaround for this.
Does anyone know if you can assign different DNS servers to different network interfaces?
centos networking dns network-interface xen
centos networking dns network-interface xen
edited Mar 5 at 17:30
Rui F Ribeiro
41.8k1483142
41.8k1483142
asked Mar 5 at 17:11
DodeDode
32
32
3
DNS does not work as you think it works. It is global to the system, not based on interface.
– Rui F Ribeiro
Mar 5 at 17:31
1
This sounds like an XY problem. Consider asking a separate question where you explain what exactly is the end result that you want to achieve. This general question is still perfectly valid and interesting for people wondering how DNS resolution works.
– TooTea
Mar 5 at 18:05
1
You can use network namespaces, puteth0
andeth1
into different namespaces (or one in the main namespace, one in a new namespace). Network namespace allows different versions ofresolv.conf
in/etc/netns/<namespace_name>/resolv.conf
, at least for sufficiently modern applications that pay attention to that.
– dirkt
Mar 6 at 11:08
add a comment |
3
DNS does not work as you think it works. It is global to the system, not based on interface.
– Rui F Ribeiro
Mar 5 at 17:31
1
This sounds like an XY problem. Consider asking a separate question where you explain what exactly is the end result that you want to achieve. This general question is still perfectly valid and interesting for people wondering how DNS resolution works.
– TooTea
Mar 5 at 18:05
1
You can use network namespaces, puteth0
andeth1
into different namespaces (or one in the main namespace, one in a new namespace). Network namespace allows different versions ofresolv.conf
in/etc/netns/<namespace_name>/resolv.conf
, at least for sufficiently modern applications that pay attention to that.
– dirkt
Mar 6 at 11:08
3
3
DNS does not work as you think it works. It is global to the system, not based on interface.
– Rui F Ribeiro
Mar 5 at 17:31
DNS does not work as you think it works. It is global to the system, not based on interface.
– Rui F Ribeiro
Mar 5 at 17:31
1
1
This sounds like an XY problem. Consider asking a separate question where you explain what exactly is the end result that you want to achieve. This general question is still perfectly valid and interesting for people wondering how DNS resolution works.
– TooTea
Mar 5 at 18:05
This sounds like an XY problem. Consider asking a separate question where you explain what exactly is the end result that you want to achieve. This general question is still perfectly valid and interesting for people wondering how DNS resolution works.
– TooTea
Mar 5 at 18:05
1
1
You can use network namespaces, put
eth0
and eth1
into different namespaces (or one in the main namespace, one in a new namespace). Network namespace allows different versions of resolv.conf
in /etc/netns/<namespace_name>/resolv.conf
, at least for sufficiently modern applications that pay attention to that.– dirkt
Mar 6 at 11:08
You can use network namespaces, put
eth0
and eth1
into different namespaces (or one in the main namespace, one in a new namespace). Network namespace allows different versions of resolv.conf
in /etc/netns/<namespace_name>/resolv.conf
, at least for sufficiently modern applications that pay attention to that.– dirkt
Mar 6 at 11:08
add a comment |
1 Answer
1
active
oldest
votes
No, that simply can't be done due to the way address resolution works.
When a process on the machine wants to connect to, say, example.com, it first calls a library routine like getaddrinfo
or gethostbyname
. The purpose of these routines is to translate the DNS name to an IP address. So they look into /etc/resolv.conf
, read the IP address of a DNS server, send a DNS query packet to that server, receive the reply and return the resulting IP address to the caller.
At that point, the process takes the resolved IP address and passes it to a system call such as connect
. This is where the kernel steps in, looks into its routing table and figures out which interface to use to connect to that address.
So in short, DNS settings simply cannot depend on the interface used for communication, because the choice of that interface itself depends on the DNS settings.
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f504547%2fcan-you-assign-different-dns-servers-to-different-network-interfaces%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
No, that simply can't be done due to the way address resolution works.
When a process on the machine wants to connect to, say, example.com, it first calls a library routine like getaddrinfo
or gethostbyname
. The purpose of these routines is to translate the DNS name to an IP address. So they look into /etc/resolv.conf
, read the IP address of a DNS server, send a DNS query packet to that server, receive the reply and return the resulting IP address to the caller.
At that point, the process takes the resolved IP address and passes it to a system call such as connect
. This is where the kernel steps in, looks into its routing table and figures out which interface to use to connect to that address.
So in short, DNS settings simply cannot depend on the interface used for communication, because the choice of that interface itself depends on the DNS settings.
add a comment |
No, that simply can't be done due to the way address resolution works.
When a process on the machine wants to connect to, say, example.com, it first calls a library routine like getaddrinfo
or gethostbyname
. The purpose of these routines is to translate the DNS name to an IP address. So they look into /etc/resolv.conf
, read the IP address of a DNS server, send a DNS query packet to that server, receive the reply and return the resulting IP address to the caller.
At that point, the process takes the resolved IP address and passes it to a system call such as connect
. This is where the kernel steps in, looks into its routing table and figures out which interface to use to connect to that address.
So in short, DNS settings simply cannot depend on the interface used for communication, because the choice of that interface itself depends on the DNS settings.
add a comment |
No, that simply can't be done due to the way address resolution works.
When a process on the machine wants to connect to, say, example.com, it first calls a library routine like getaddrinfo
or gethostbyname
. The purpose of these routines is to translate the DNS name to an IP address. So they look into /etc/resolv.conf
, read the IP address of a DNS server, send a DNS query packet to that server, receive the reply and return the resulting IP address to the caller.
At that point, the process takes the resolved IP address and passes it to a system call such as connect
. This is where the kernel steps in, looks into its routing table and figures out which interface to use to connect to that address.
So in short, DNS settings simply cannot depend on the interface used for communication, because the choice of that interface itself depends on the DNS settings.
No, that simply can't be done due to the way address resolution works.
When a process on the machine wants to connect to, say, example.com, it first calls a library routine like getaddrinfo
or gethostbyname
. The purpose of these routines is to translate the DNS name to an IP address. So they look into /etc/resolv.conf
, read the IP address of a DNS server, send a DNS query packet to that server, receive the reply and return the resulting IP address to the caller.
At that point, the process takes the resolved IP address and passes it to a system call such as connect
. This is where the kernel steps in, looks into its routing table and figures out which interface to use to connect to that address.
So in short, DNS settings simply cannot depend on the interface used for communication, because the choice of that interface itself depends on the DNS settings.
answered Mar 5 at 18:00
TooTeaTooTea
784211
784211
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f504547%2fcan-you-assign-different-dns-servers-to-different-network-interfaces%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
DNS does not work as you think it works. It is global to the system, not based on interface.
– Rui F Ribeiro
Mar 5 at 17:31
1
This sounds like an XY problem. Consider asking a separate question where you explain what exactly is the end result that you want to achieve. This general question is still perfectly valid and interesting for people wondering how DNS resolution works.
– TooTea
Mar 5 at 18:05
1
You can use network namespaces, put
eth0
andeth1
into different namespaces (or one in the main namespace, one in a new namespace). Network namespace allows different versions ofresolv.conf
in/etc/netns/<namespace_name>/resolv.conf
, at least for sufficiently modern applications that pay attention to that.– dirkt
Mar 6 at 11:08