1

I use a script that creates multiple network interfaces with IP adresses. An example of commands used by the script:

ip addr flush eth0 
ip addr flush eth1

ip addr add 192.168.1.10 dev eth0 route add default gw 192.168.1.1 eth0
ip addr add 10.1.1.10 dev eth1 route add default gw 10.1.1.1 eth1

I didn't find an option to set the DNS server. The file at /etc/resolv.conf has a DNS entry but it's not working. And /etc/network/interfaces is empty (just loopback information).

My question is : is there a way to set the DNS servers using a cmd line that I can include in the script? Or do I have to manually add all the information to /etc/network/interfaces?

guntbert
  • 553
  • 7
  • 21
  • different linux distros use different methods of adding DNS. There is NetworkManager as a GUI. And there is `ifupdown`, `systemd-networkd`, `resolvconf`. Additionally there is `netplan` handling such thing. The dhcp-client can also do this, but there is more than one dhcp-client available (isc-dhcp-client, dnsmasq). You see, your info is not enough to help you. – Marco May 06 '22 at 15:54
  • `resolf.conf` doesn't work? Strange. What `grep hosts /etc/nsswitch.conf` says? – Nikita Kipriyanov May 09 '22 at 04:13

0 Answers0