[Linux] Configuring DNS Addresses on Linux

DNS determines whether a server can reach the internet via domain names. There are two ways to configure DNS server IP addresses on Linux.

Verification method:

1
ping www.baidu.com
  1. Temporary method
    a) Edit resolv.conf

    1
    
    vi ./etc/resolv.conf
    

    b) Enter

    1
    
    nameserver 8.8.8.8
    

    Save and you’re done.

  2. Permanent method
    a) Edit ifcfg-eth0

    1
    
    vi /etc/sysconfig/network-scripts/ifcfg-eth0
    

    b) Enter

    1
    
    DNS1=8.8.8.8
    

    Save and you’re done.

You can use

1
ifconfig

to view the local network interfaces, where you can see the eth0 configuration information.

Licensed under CC BY-NC-SA 4.0