Issues related to configuring your network
Post Reply
User avatar
Posts: 3
Joined: 2020/01/21 18:32:18
Location: Tel Aviv


Post by nicholas5421 » 2020/03/03 19:23:25

Hello All,

I am trying to block access to youtube by adding the static record to hosts file.
But i still have youtube access. It seems like the hosts file have been ignored.

Code: Select all

$ cat /etc/hosts   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

Code: Select all

$ ping -c1
PING ( 56(84) bytes of data.
64 bytes from localhost ( icmp_seq=1 ttl=64 time=0.035 ms

Code: Select all

$ dig

; <<>> DiG 9.11.4-P2-RedHat-9.11.4-26.P2.el8 <<>>
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 36706
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

; EDNS: version: 0, flags:; udp: 1452
;			IN	A


;; Query time: 77 msec
;; WHEN: Tue Mar 03 21:19:30 IST 2020
;; MSG SIZE  rcvd: 56
Please help.

Posts: 116
Joined: 2020/01/17 09:01:44

Re: Block

Post by sml » 2020/03/04 07:40:30

First, ensure that files comes before anything in your /etc/nsswitch.conf:

Code: Select all

grep ^hosts: /etc/nsswitch.conf
But most probably, it's a DNS caching issue:

Code: Select all

sudo resolvectl flush-caches
DNS lookups may also be cached by another service (dnsmasq, nscd, ...). See How to Flush the DNS Cache on Linux.

Code: Select all

sudo pkill -USR1 dnsmasq


Code: Select all

grep ^dns= /etc/NetworkManager/NetworkManager.conf
and see if it gives you dns=systemd-resolved or dns=dnsmasq. From Configuring and managing networking:
  • dns=dnsmasq or dns=systemd-resolved:

    When you use one of these settings, NetworkManager sets either for dnsmasq or as nameserver entry in the /etc/resolv.conf file
Last edited by sml on 2020/03/04 08:44:12, edited 4 times in total.

User avatar
Forum Moderator
Posts: 29985
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Block

Post by TrevorH » 2020/03/04 07:43:06

You'll also find that youtube has multiple URLs so blocking like that will not also block or any other variants on that theme.
CentOS 6 died in November 2020 - migrate to a new version!
Info for USB installs on
CentOS 5 is dead, do not use it.
Full time Geek, part time moderator. Use the FAQ Luke

User avatar
Posts: 3
Joined: 2020/01/21 18:32:18
Location: Tel Aviv

Re: Block

Post by nicholas5421 » 2020/03/04 17:59:18

Thanks, for your help. It seems to be the solution.

In Centos 8, the newer Firefox adds "www" to So there is no any problem.
Also, we could see that configuration worked in my pings.

I will try to block it with firewalld.

Posts: 13
Joined: 2020/01/20 07:26:39

Re: Block

Post by matt2020 » 2020/03/07 19:11:34

Also remember the latest Firefox is turning on DoH so will be bypassing all local DNS Settings ! ... over-https

You may want to turn that Off.

Post Reply

Return to “CentOS 8 - Networking Support”