Results 1 to 5 of 5

Thread: DNS woes

  1. #1
    Join Date
    Jan 2008
    Location
    Faversham UK
    Beans
    64

    DNS woes

    I'm still very much a Linux noob and have just started playing with Ubuntu Server 12.40 and I'm trying to set up a static IP on the server.

    After doing a bit of research on how to change Ubuntu Server network from DHCP to a static IP I discovered that it looks in /etc/network/interfaces for the network configuration.

    As I'm new to all this editing of config files I wanted to make sure I have a backup of the file, so i did the following:
    Code:
    sudo cp /etc/network/interfaces /etc/network/interfaces.bak
    Now that I have a backup in case I mess things up I edited the file using the built in text editor nano, by issuing the following command:
    Code:
    sudo nano /etc/network/interfaces
    I started by commenting out the dhcp line by putting a # at the beginning of the line and then I added the following:
    Code:
    iface eth0 inet static
    address 192.168.1.210
    netmask 255.255.255.0 
    gateway 192.168.1.254 
    network 192.168.1.0 
    broadcast 192.168.1.255
    dns-nameservers 8.8.8.8
    Once I entered the relevant info I saved the file by pressing Ctrl+O and then exited nano with Ctrl+X.

    I then restarted the network service with:
    Code:
    sudo /etc/init.d/networking restart
    My /etc/network/interfaces looks like this:
    Code:
    # This file describes the network interfaces available on your system
    # and how to activate them. For more information, see interfaces(5).
    
    # The loopback network interface
    auto lo
    iface lo inet loopback
    
    # The primary network interface
    auto eth0
    # iface eth0 inet dhcp
    iface eth0 inet static
    address 192.168.1.210
    netmask 255.255.255.0
    gateway 192.168.1.254
    network 192.168.1.0
    broadcast 192.168.1.255
    dns-nameserver 8.8.8.8
    My /etc/resolv.conf looks like this
    Code:
    # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
    #     DO NO EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
    when i issue an sudo aptitude update i get the following:
    Code:
    new@ubuntu:~$ sudo aptitude update
    Err http://gb.archive.ubuntu.com precise Release.gpg
      Temporary failure resolving âgb.archive.ubuntu.comâ
    Err http://gb.archive.ubuntu.com precise-updates Release.gpg
      Temporary failure resolving âgb.archive.ubuntu.comâ
    Err http://gb.archive.ubuntu.com precise-backports Release.gpg
      Temporary failure resolving âgb.archive.ubuntu.comâ
    Err http://security.ubuntu.com precise-security Release.gpg
      Temporary failure resolving âsecurity.ubuntu.comâ
    W: Failed to fetch http://gb.archive.ubuntu.com/ubuntu/dists/precise/Release.gpg  Temporary failure resolving âgb.archive.ubuntu.comâ
    
    W: Failed to fetch http://gb.archive.ubuntu.com/ubuntu/dists/precise-updates/Release.gpg  Temporary failure resolving âgb.archive.ubuntu.comâ
    
    W: Failed to fetch http://gb.archive.ubuntu.com/ubuntu/dists/precise-backports/Release.gpg  Temporary failure resolving âgb.archive.ubuntu.comâ
    
    W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/Release.gpg  Temporary failure resolving âsecurity.ubuntu.comâ
    
    W: Some index files failed to download. They have been ignored, or old ones used instead.
    Which lead me to think it was network config error so I tried ping google.com which gave:
    Code:
    new@ubuntu:~$ ping google.com
    ping: unknown host google.com
    But ping 8.8.8.8.8 gave:
    Code:
    new@ubuntu:~$ ping 8.8.8.8
    PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
    64 bytes from 8.8.8.8: icmp_req=1 ttl=44 time=34.1 ms
    64 bytes from 8.8.8.8: icmp_req=2 ttl=44 time=37.7 ms
    64 bytes from 8.8.8.8: icmp_req=3 ttl=44 time=33.5 ms
    64 bytes from 8.8.8.8: icmp_req=4 ttl=44 time=32.9 ms
    64 bytes from 8.8.8.8: icmp_req=5 ttl=44 time=32.8 ms
    ^C
    --- 8.8.8.8 ping statistics ---
    5 packets transmitted, 5 received, 0% packet loss, time 4011ms
    rtt min/avg/max/mdev = 32.884/34.272/37.750/1.804 ms
    That ping was successful so I came to the conclusion that it was a dns issue.

    After a bit of googgling I added nameserver 8.8.8.8 to the /etc/resolv.conf and after restarting the service I was able to run an sudo aptitude update with out issues.

    The problem is that after a reboot the nameserver 8.8.8.8 I added to /etc/resolv.conf doesn't stick, I didn't think it would because of the warning at the top of the file.

    What am I doing wrong? I know its a silly noob mistake but I'm having fun learning this stuff.

    Sorry for the long post tried to get as much info as i could to help you guys help me out.

  2. #2
    Join Date
    Aug 2005
    Location
    South Carolina, USA
    Beans
    21,462
    Distro
    Ubuntu 15.04 Vivid Vervet

    Re: DNS woes

    I'm not sure it is a factor here, but your file looks a little busy. I suggest:
    Code:
    # The loopback network interface
    auto lo
    iface lo inet loopback
    
    # The primary network interface
    auto eth0
    # iface eth0 inet dhcp
    iface eth0 inet static
    address 192.168.1.210
    netmask 255.255.255.0
    gateway 192.168.1.254
    dns-nameservers 8.8.8.8 8.8.4.4
    As you see, I've also suggested adding a backup DNS in case the primary is out. Get the system to re-read the file and use the changes:
    Code:
    sudo ifdown eth0 && sudo ifup -v eth0
    Check:
    Code:
    ping -c3 www.google.com
    Is it working as expected? If so, I'm not sure I'd go poking around looking for things to dislike.
    "Oh, Ubuntu, you are my favorite Linux-based operating system" --Dr. Sheldon Cooper, Ph.D.

  3. #3
    Join Date
    Jan 2008
    Location
    Faversham UK
    Beans
    64

    Re: DNS woes

    Wow that worked, many thanks, cant believe I missed the s on the nameserver line.

    Also tried it with my original config and that worked:
    Code:
    # iface eth0 inet dhcp
    iface eth0 inet static
    address 192.168.1.210
    netmask 255.255.255.0
    gateway 192.168.1.254
    network 192.168.1.0
    broadcast 192.168.1.255
    dns-nameservers 8.8.8.8 8.8.4.4
    Question though as I'm very new to this, how does
    Code:
    sudo ifdown eth0 && sudo ifup -v eth0
    compare to this,
    Code:
    sudo /etc/init.d/networking restart
    whats the difference?

  4. #4
    Join Date
    Feb 2011
    Location
    Coquitlam, B.C. Canada
    Beans
    1,898
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: DNS woes

    Quote Originally Posted by Icerat View Post
    Question though as I'm very new to this, how does
    Code:
    sudo ifdown eth0 && sudo ifup -v eth0
    compare to this,
    Code:
    sudo /etc/init.d/networking restart
    whats the difference?
    It seems that using the networking restart method will take down the dbus and leave it down, and so the down/up method is preferred. The Serverguide has being fixed for 14.04 for these references, see here.
    Any follow-up information on your issue would be appreciated. Please have the courtesy to report back.

  5. #5
    Join Date
    Aug 2005
    Location
    South Carolina, USA
    Beans
    21,462
    Distro
    Ubuntu 15.04 Vivid Vervet

    Re: DNS woes

    Exactly. I'm lazy; I never re-start more than I need to restart. In this case, all we need to restart is eth0. By the way, the -v flag is for verbose. You get a chance to see what, if anything, is going wrong.

    Glad it's working.
    "Oh, Ubuntu, you are my favorite Linux-based operating system" --Dr. Sheldon Cooper, Ph.D.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •