Solved how to use resolvconf command to add DNS record for multi network interface in freebsd14.2 ?

Dear all:
i have three network interfaces in my freebsd14.2. i want to use resolvconf tool to add dns for each network interface s with different dns ..how to do that ?

my searching is : resolvconf -a netinterface1 -x ??????
how to add dns nameserver 8.8.8.8 to netinterface1 ?
add dns nameserver 10.0.0.254 to netinterface2
add dns nameserver 192.168.100.254 to netinterface3

thanks,
 
A way to do it, if you have a static configuration for each interface is have a different resolve.conf for each.

resolv.conf.interface1 containing:
search blah.net
nameserver 8.8.8.8

resolv.conf.interface2 containing:
search home.net
nameserver 10.0.0.254

resolv.conf.interface3 containing:
search test.net
nameserver 192.168.100.254

then:
resolvconf -a interface1 < resolv.conf.interface1
resolvconf -a interface2 < resolv.conf.interface2
resolvconf -a interface3 < resolv.conf.interface3

But you may need to double check on HOW resolvconf chooses; not sure if it's based on the search directives or if it's based on the source interface.

I do something like this for when I bring up VPN to work so I want work names to be resolved by work DNS servers, everything else by my standard non-work DNS servers.
For openvpn command I put things in a vpn-up.sh and vpn-down.sh and add "--route-up" and "--route-pre-down" options to the openvpn command.
vpn-up.sh is simply
resolvconf -a tun0 < resolv.conf.tun0 (this contains my work DNS configuration, can also be parsed from DHCP options)

vpn-down.sh is
resolvconf -d tun0
 
A way to do it, if you have a static configuration for each interface is have a different resolve.conf for each.

resolv.conf.interface1 containing:
search blah.net
nameserver 8.8.8.8

resolv.conf.interface2 containing:
search home.net
nameserver 10.0.0.254

resolv.conf.interface3 containing:
search test.net
nameserver 192.168.100.254

then:
resolvconf -a interface1 < resolv.conf.interface1
resolvconf -a interface2 < resolv.conf.interface2
resolvconf -a interface3 < resolv.conf.interface3

But you may need to double check on HOW resolvconf chooses; not sure if it's based on the search directives or if it's based on the source interface.

I do something like this for when I bring up VPN to work so I want work names to be resolved by work DNS servers, everything else by my standard non-work DNS servers.
For openvpn command I put things in a vpn-up.sh and vpn-down.sh and add "--route-up" and "--route-pre-down" options to the openvpn command.
vpn-up.sh is simply
resolvconf -a tun0 < resolv.conf.tun0 (this contains my work DNS configuration, can also be parsed from DHCP options)

vpn-down.sh is
resolvconf -d tun0
Dear mer :
thanks for your help . other question about DNS .
below was my rc.conf content.
#--------------------------------------------------------------------
hostname="worffff"
ifconfig_em0="inet 192.168.1.9 netmask 255.255.255.0"
defaultrouter="192.168.1.1"
ifconfig_em0_ipv6="inet6 accept_rtadv"
sshd_enable="YES"
#---------------------------------------------------------------------

my /etc/resolv.conf was below
nameserver fe80::1%em0

now, i compute got ipv4 and ipv6 address . i add some dns servers in my /etc/resolve.conf . but when i reboot this computer , the new dns record will disappear. how can stop this . and keep my new dns server record in /etc/resolve.conf ? thanks.
 
There are probably several ways.

resolv.conf is populated by the service resolv and its setting file resolvconf(8).
It uses resolv.conf as it settings file and should not be edited.
Instead you edit resolvconf.conf to achieve goals.
You can also turn off resolvconf and manually set resolv.conf.
Many options.
 
Dear all :
thanks for your help . below was every important :
1. when you create different resolv.conf for each interface .
2. your special one resolv.conf for interface with command : resolvconf -a interface3 -x < /etc/resolv.conf.interface3

all done. thanks for your help .
 
Back
Top