2

Couple things. First, I'm relatively new to linux in general. Second, I've done my best to scour google, youtube and other places for help on this first before coming here for help. I appreciate any and all direction you can provide!

Here's what's happening:

I am using VirtualBox to create VMs on my Windows 7 laptop. I have 3 VMs up and running -- one uses Ubuntu Server 14.04.1, another uses Ubuntu Desktop 14.04.1, and the third uses Debian 7.7.0. I am repeating all steps on all boxes.

After installing all of the OS's and confirming I could reach the internet fine via DHCP, I wanted to assign all of my machines static IPs. I used route -n to get my gateway, etc.

Here's what my /etc/network/interfaces file look like for Ubuntu Server. (The others look identical except for the IP addresses which are 192.168.1.130, 192.168.1.140, and 192.168.1.150, respectively):

auto eth0
iface eth0 inet static
address 192.168.1.130
netmask 255.255.255.0
gateway 192.168.1.1

I restarted networking with ifdown eth0 and ifup eth0 and confirmed the change with ifconfig. After this, I tried running apt-get-update to update my packages and found that I was getting Err and Failed to fetch messages. Next, I pinged 8.8.8.8 (which I had heard was Google). I got pings. Then, I tried wget google.com and got "Could not resolve..."

Next, I tried the same thing on Ubuntu Desktop. Got the same results, and confirmed via the graphical interface that when I tried to access the internet through a browser, I got nothing.

Did some poking around and found dhclient -r eth0 which got me internet connectivity back on both Ubuntu Server and Ubuntu Desktop. (Verified with ping and wget on Ubuntu Server and through a browser on Ubuntu Desktop). However, whenever I reboot the Ubuntu VMs, I get the same exact issue -- no connectivity without using dhclient -r eth0.

The reason I bring Debian into the mix is that when I tried the exact same steps for a static IP on Debian 7.7, none of the connectivity issues occurred; everything worked as I'd expected.

Can someone help shed some light on what's happening and how I can resolve it?

Much appreciated!

1
  • 1
    You haven't mention DNS settings at all, yet your problem is DNS resolution. The closest you come to it mentioning it is 8.8.8.8, which is one of Google's public DNS servers.
    – muru
    Jan 1, 2015 at 19:20

2 Answers 2

3

Here is my working config. As previously mentioned, you did not include DNS:

 auto eth0
 iface eth0 inet static
    address 192.168.1.80
    netmask 255.255.255.0
    gateway 192.168.1.1
    dns-nameservers 8.8.8.8 8.8.4.4
13
  • Thanks very much for this! As I say, I'm as new as it gets and know very little about DNS or the need for it, so this gives me something to research. I got as far as I did by watching and reading tutorials, none of which mentioned DNS. It's also strange to me why my settings worked in Debian without anything pertaining to DNS as well. For my own knowledge and understanding, could you explain: 1. Why or how others were able to make this sort of thing work without the dns-nameservers definition 2. What do the specific dns-nameservers values you specify in your example refer to?
    – Steve K
    Jan 1, 2015 at 19:56
  • @SteveK Regarding (2), those are Google's public DNS servers.
    – muru
    Jan 1, 2015 at 20:02
  • @muru Ah, got it, thanks! Should my expectation be that by adding the nameservers line as it is here, my problem should go away? Or, do I need to apt-get the packages for DNS and configure that together with this in order to get things to work?
    – Steve K
    Jan 1, 2015 at 20:05
  • It's usually setup during install with dhcp. If you selected manual config you may have forgot to add the dns. These addresses point to Google dns. Also if this fixed your issue can you please click the check to mark it as an accepted answer.
    – geoffmcc
    Jan 1, 2015 at 20:06
  • Yes, that should be enough. Though you should check what DNS settings your DHCP server provides first. DNS is one of the fundamental aspects of networking, pretty much any OS installation will have tools to support it.
    – muru
    Jan 1, 2015 at 20:06
0

The best way using this bash script.

#!/bin/bash

<< FUNCTION ZONE >>

=====================================================================

SetStaticIpWithInternetOperative(){
GATEWAYNumber=$(nmcli device show | awk ‘FNR==11 {print $2}’)
StaticIPNumber=192.168.1.15
UUID=$(nmcli connection show | awk ‘FNR==2 {print $4}’)
printf «$UUID»
#read
clear
nmcli connection modify $UUID ipv4.address $StaticIPNumber/24 ipv4.gateway $GATEWAYNumber & processIDC=$!
wait $processIDC
/etc/init.d/networking restart & processIDC=$!
wait $processIDC
# OPTIONAL, ENABLE ONLY IF YOU WANT TO RESTART THE OPERATING SYSTEM FOR EXAMPLE AFTER A SYSTEM INSTALLATION
# CUSTOMIZED AN INTRANET MADE WITH RUGBY LANGUAGE OR ANY OTHER LANGUAGE… xD
#reboot
}

=========================================

SetStaticIpWithInternetOperative

1
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Jun 21, 2022 at 8:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .