Ubuntu Server and static IP without DHCP -> no internet

Discussions about using Linux guests in VirtualBox.
Post Reply
Flodda
Posts: 3
Joined: 30. Apr 2014, 11:04

Ubuntu Server and static IP without DHCP -> no internet

Post by Flodda »

Hello everybody,

I have set up a LAMP server in my VirtualBox running Ubuntu Server 14.04. Because I don't want the IP of the server to change on every reboot, I followed the instructions on "howtogeek" (cant post any URLs because this is my first posting...) to disable DHCP and request a static IP from the router instead.

Inside the LAN its working fine, I can access the webserver by its internal IP (in my example 192.168.1.200) and the other way around is working too, I can mount my network drives inside the virtual machine with no problem.

But when I tried to install another PHP extension, I noticed that the internet connection doesnt work anymore after disabling DHCP. Checking that by pinging Google results in an "unknown host" error.

I set the network adapter to network bridge in the settings of the virtual machine when I followed the tutorial and I actually don't know what has been set there before. Can this be an error in the VirtualBox configuration or is my network configuration in Ubuntu wrong?

My /etc/network/interfaces looks like the following:

Code: Select all

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
    address 192.168.1.200
    netmask 255.255.255.0
    network 192.168.1.0
    broadcast 192.168.1.255
    gateway 192.168.1.1
I am not really an expert in computer networks. I just know the basic stuff and the fact that internal access to the virtual machine is working gives me the feeling that I misconfigured the internet connection. My network is a simple home LAN: just a router (192.168.1.1) connecting a bunch of computers via cable or wifi, usually over DHCP. Just my own PC, my NAS and the VirtualBox request static IPs.

I hope this is easy for someone with a bit more experience in networks, thanks for some help in advance ;)
noteirak
Site Moderator
Posts: 5231
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: Ubuntu Server and static IP without DHCP -> no internet

Post by noteirak »

Try the following in the VM and in the host, then post the output for each :

Code: Select all

ping 192.168.1.200
ping 192.168.1.1
ping 8.8.8.8
nslookup 8.8.8.8
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Flodda
Posts: 3
Joined: 30. Apr 2014, 11:04

Re: Ubuntu Server and static IP without DHCP -> no internet

Post by Flodda »

Commands run on my host (Windows 7):

Code: Select all

Pinging 192.168.1.200 with 32 bytes of data:
Reply from 192.168.1.200: bytes=32 time<1ms TTL=64
Reply from 192.168.1.200: bytes=32 time<1ms TTL=64
Reply from 192.168.1.200: bytes=32 time<1ms TTL=64
Reply from 192.168.1.200: bytes=32 time<1ms TTL=64

Ping statistics for 192.168.1.200:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

Code: Select all

Pinging 192.168.1.1 with 32 bytes of data:
Reply from 192.168.1.1: bytes=32 time<1ms TTL=64
Reply from 192.168.1.1: bytes=32 time=1ms TTL=64
Reply from 192.168.1.1: bytes=32 time<1ms TTL=64
Reply from 192.168.1.1: bytes=32 time<1ms TTL=64

Ping statistics for 192.168.1.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 1ms, Average = 0ms

Code: Select all

Pinging 8.8.8.8 with 32 bytes of data:
Reply from 8.8.8.8: bytes=32 time=18ms TTL=48
Reply from 8.8.8.8: bytes=32 time=19ms TTL=48
Reply from 8.8.8.8: bytes=32 time=19ms TTL=48
Reply from 8.8.8.8: bytes=32 time=18ms TTL=48

Ping statistics for 8.8.8.8:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 18ms, Maximum = 19ms, Average = 18ms

Code: Select all

Server:  Router
Address:  192.168.1.1

Name:    google-public-dns-a dot google dot com (had to edit this because I cant post URLs due to my member status)
Address:  8.8.8.8
Commands run on Ubuntu Server guest:

Code: Select all

PING 192.168.1.200 (192.168.1.200) 56(84) bytes of data.
64 bytes from 192.168.1.200: icmp_seq=1 ttl=64 time=0.019 ms
64 bytes from 192.168.1.200: icmp_seq=2 ttl=64 time=0.034 ms
64 bytes from 192.168.1.200: icmp_seq=3 ttl=64 time=0.036 ms
64 bytes from 192.168.1.200: icmp_seq=4 ttl=64 time=0.035 ms

--- 192.168.1.200 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 2997ms
rtt min/avg/max/mdev = 0.019/0.031/0.036/0.007 ms

Code: Select all

PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=1.56 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.744 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.775 ms
64 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=0.728 ms

--- 192.168.1.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 0.728/0.953/1.566/0.354 ms

Code: Select all

PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=48 time=19.0 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=48 time=18.5 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=48 time=19.2 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=48 time=15.9 ms

--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3006ms
rtt min/avg/max/mdev = 15.962/18.182/19.236/1.308 ms

Code: Select all

;; connection timed out; no servers could be reached
noteirak
Site Moderator
Posts: 5231
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: Ubuntu Server and static IP without DHCP -> no internet

Post by noteirak »

seems like you did not define a DNS server in the VM
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Flodda
Posts: 3
Joined: 30. Apr 2014, 11:04

Re: Ubuntu Server and static IP without DHCP -> no internet

Post by Flodda »

Thanks, that brought me back on the right track! I really should get a bit deeper into networking to debug stuff like this myself :D

When I followed the tutorial mentioned in my initial posting, I added my router's IP as DNS server to the /etc/resolv.conf file. Now I found out that the program "resolvconf" overwrites this file every time the network interface gets reinitialized.
I had to configure the DNS server in the /etc/network/interfaces file instead of the /etc/resolv.conf, so "resolvconf" would know about it and add it to the resolv.conf-file.
I just added the line "dns-nameservers 192.168.1.1" to my /etc/network/interfaces file and now internet access is working again!
Post Reply