LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-06-2020, 10:49 AM   #1
ddenial
Member
 
Registered: Dec 2016
Distribution: CentOS, Fedora, Ubuntu
Posts: 359

Rep: Reputation: 56
remove nameserver line from resolv.conf


Hello All,

Following is an output of resolv.conf from CentOS 7.8 KVM guest.
Code:
# cat /etc/resolv.conf 
# Generated by NetworkManager
search kvmlab.lan cntnix.lan
nameserver 192.168.122.1
nameserver 192.168.1.7
I want to remove the line 'nameserver 192.168.122.1'. I don't know from where it is appending. I have not mentioned it anywhere.

This is my network config file
Code:
# cat /etc/sysconfig/network-scripts/ifcfg-enp1s0 
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="dhcp"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="enp1s0"
DEVICE="enp1s0"
ONBOOT="yes"
DOMAIN="kvmlab.lan cntnix.lan"
DNS1=192.168.1.7
How do I remove that nameserver from libvirt (192.168.122.1)?

Thanks
 
Old 05-06-2020, 10:56 AM   #2
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
This is for RHEL 8, but IIRC the RHEL/CentOS 7 is very similar in this respect.
 
Old 05-07-2020, 01:19 AM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Just fyi, 192.168.122.X is the subnet for the built-in VM system (aka kvm), so comes as std.
eg if you run ifconfig, you'll probably see something like
Code:
virbr0    Link encap:Ethernet  HWaddr 52:54:00:AF:7E:4A  
          inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
You could just ignore it.
 
1 members found this post helpful.
Old 05-07-2020, 01:24 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
Quote:
Originally Posted by chrism01 View Post
Just fyi, 192.168.122.X is the subnet for the built-in VM system (aka kvm), so comes as std.
eg if you run ifconfig, you'll probably see something like
Code:
virbr0    Link encap:Ethernet  HWaddr 52:54:00:AF:7E:4A  
          inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
You could just ignore it.
Exactly. With other words: it is automatically configured for you according to your [virtual] network setup. If you wish to modify it most probably you need to [re]configure your bridge virbr0.

By the way: why do you want to remove it?
 
1 members found this post helpful.
Old 05-07-2020, 09:31 AM   #5
ddenial
Member
 
Registered: Dec 2016
Distribution: CentOS, Fedora, Ubuntu
Posts: 359

Original Poster
Rep: Reputation: 56
Quote:
Originally Posted by pan64 View Post
By the way: why do you want to remove it?
Cause I've installed the Bind DNS server on IP 192.168.1.7. As I am learning the DNS server and the KVM guest in question is used for testing the Bind server as an outsider. So every time I 'dig' something, it is resolved by 192.168.122.1 IP, which I don't want to use. I want it to use IP 192.168.1.7 instead of where my DNS server is.

Code:
# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 52:54:00:0c:a8:83 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.78/24 brd 192.168.122.255 scope global noprefixroute dynamic enp1s0
       valid_lft 3372sec preferred_lft 3372sec
    inet6 fe80::cf9f:806f:2faa:e858/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever


# nmap -p 53 192.168.1.7
Starting Nmap 6.40 ( http://nmap.org ) at 2020-05-07 19:52 IST
Nmap scan report for svr.cntnix.lan (192.168.1.7)
Host is up (0.00018s latency).
PORT   STATE SERVICE
53/tcp open  domain

# dig google.com
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-16.P2.el7_8.2 <<>> google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 57136
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;google.com.			IN	A

;; ANSWER SECTION:
google.com.		177	IN	A	172.217.163.78

;; Query time: 55 msec
;; SERVER: 192.168.122.1#53(192.168.122.1)
;; WHEN: Thu May 07 19:59:09 IST 2020
;; MSG SIZE  rcvd: 55


# cat /etc/resolv.conf
# Generated by NetworkManager
search kvmlab.lan cntnix.lan
nameserver 192.168.122.1
nameserver 192.168.1.7
At least I want 192.168.1.7 to be my primary DNS server.
 
Old 05-07-2020, 09:42 AM   #6
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by ddenial View Post
How do I remove that nameserver from libvirt (192.168.122.1)?
My guess: It comes from DHCP. Not sure how that interferes with the DNS1 in the ifcfg file.

Assuming NetworkManager is used in the guest, you could add NM_CONTROLLED=no to ifcfg-xxx. Or set dns=no in /etc/NetworkManager/NetworkManager.conf.
 
1 members found this post helpful.
Old 05-07-2020, 10:30 AM   #7
ddenial
Member
 
Registered: Dec 2016
Distribution: CentOS, Fedora, Ubuntu
Posts: 359

Original Poster
Rep: Reputation: 56
I finally resolved it by adding PEERDNS=no in ifcfg config file.

Thanks everybody.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
nameserver entries in /etc/resolv.conf Ron7 Linux - Software 11 09-03-2010 03:18 PM
resolv.conf nameserver ordering/priorities jmoschetti45 Linux - Networking 6 01-25-2010 11:27 AM
resolv.conf deletes nameserver entries Mirkridian Linux - Wireless Networking 1 02-19-2007 01:59 AM
router being added to resolv.conf as nameserver thatwouldbeme Linux - Networking 3 11-15-2006 12:44 PM
pppd: nameserver -> /etc/resolv.conf ?? tredegar Linux - Networking 6 03-21-2004 07:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration