DNS, Changing your

From PCLinuxOShelp Knowledge Base

Jump to: navigation, search

Here is a simple way to change your DNS numbers.

In your favorite text editor open the /etc/sysconfig/network-scripts/ifcfg-xxxx where as ifcfg.xxxx could be ppp0, eth0 or wlan0 as the root user.

In our example I will be using a command line editor called nano. Also since I am using a Ethernet connection I will be using ifcfg-eth0


First I change to the root user using "SU"

[dwmoar@workbox ~]$ su
Password:

Now I open the ifcfg-eth0 file using nano

[root@workbox dwmoar]# nano /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
BOOTPROTO=static
IPADDR=192.168.1.25
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
ONBOOT=yes
METRIC=10
MII_NOT_SUPPORTED=no
USERCTL=yes
DNS1=192.168.1.1
RESOLV_MODS=no
IPV6INIT=no
IPV6TO4INIT=no
ACCOUNTING=yes

Now to this I want to add my new DNS number. Add the following lines if they are not already there. If they are there than just change the numbers. Normally the DNS is set to your ISP DNS or that of your Modem/Router


DNS1=208.67.222.222  <-- Open DNS servers
DNS2=208.67.220.220  <-- Open DNS servers

These could be any public DNS server numbers such as Google 4.4.4.4 or 4.4.2.2

When you are finished you file should look something like this

DEVICE=eth0
BOOTPROTO=static
IPADDR=192.168.1.25
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
ONBOOT=yes
METRIC=10
MII_NOT_SUPPORTED=no
USERCTL=yes
DNS1=208.67.222.222
DNS2=208.67.220.220 
RESOLV_MODS=no
IPV6INIT=no
IPV6TO4INIT=no
ACCOUNTING=yes

Your DNS numbers may vary depending on which DNS server you have chosen to use. Save your file and than close your editor. Now in order to make them active we need to restart our network. To do this open a console window and change to the root user. For those of you that are command line challenged simply reboot your computer

[dwmoar@workbox ~]$ su
Password:

Now enter the command

service network restart

you should see something like this

[root@workbox dwmoar]# service network restart
Shutting down interface eth0:                                                                                  [  OK  ]
Shutting down loopback interface:                                                                              [  OK  ]
Bringing up loopback interface:                                                                                [  OK  ]
Bringing up interface eth0:                                                                                    [  OK  ]
[root@workbox dwmoar]#


Now you are using your new DNS server numbers. These new DNS numbers will be used each and every time that you power on your computer.

Personal tools