Ubuntu - How to manually set DNS servers? | ATG Learning

Blog

Ubuntu - How to manually set DNS servers?

| Friday, Feb 3, 2017

It's pretty straightforward. To do this you'll need root access so you can modify /etc/network/interfaces. sudo nano /etc/network/interfaces If you're trying to set up a static address, you'll want an entry that reads something like the following for your primary network adapter (usually eth0 or wlan0):

auto eth0 iface eth0 inet static address 192.168.1.109 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.1 dns-nameservers 4.2.2.1 8.8.8.8

What this did is set a static IP of 192.168.1.109 with a network mask of 255.255.255.0. We're on the 192.168.1.0 network (the IP address minus the last number) and the broadcast address is 192.168.1.255 (the IP address with 255 as the last octet).

Do you feel like you're in over your head when dealing with this stuff?

Do lots of numbers scare you?

You might want to take our Network+ crash course-- in just four days, we can help you earn CompTIA's Network+ certification, but more importantly, you'll see past the numbers and abstract terms to be able to read this article in plain English-- it'll be like you just discovered the Rosetta stone! Plus it looks great on your resume.

Anyway, all of our internet traffic flows through a gateway. Usually these are indicated by a .1 as the last octet, hence 192.168.1.1. Lastly, the reason you're here-- the DNS servers. We're specifying Verizon's and Google's DNS servers in this example, but do not recommend them for production use (use your ISP's DNS servers where possible). Just list them one after the other.

For DHCP (where your router or something else assigns your PC an IP address), you'll need a slightly different block: auto eth0 iface eth0 inet dhcp dns-nameservers 4.2.2.1 8.8.8.8 With your DNS entries in place, restart your networking service and you should be good to go!

sudo service networking restart

Request Information

Please fill out the form below to contact a training consultant directly or call 888-862-3784

Full Name

Company

Location

Email

Phone

Message

Enter the text in the image