1

On my Ubuntu Server 16.04(it is a virtual machine), after I set the IP to static as follows:

# The primary network interface
auto ens33
iface ens33 inet static
  address 192.168.70.10
  netmask 255.255.255.0
  gateway 192.168.70.1
  dns-nameservers 8.8.8.8 8.8.4.4

I have no access to the internet. The following ping does not work:

dockerize@containerize:~$ ping www.google.ch
ping: unknown host www.google.ch

Then I set back to DHCP, the ping works:

dockerize@containerize:~$ ping www.google.ch
PING www.google.ch (216.58.213.195) 56(84) bytes of data.
64 bytes from ham02s15-in-f195.1e100.net (216.58.213.195): icmp_seq=1 ttl=128 time=29.8 ms
64 bytes from ham02s15-in-f195.1e100.net (216.58.213.195): icmp_seq=2 ttl=128 time=30.1 ms
^C
--- www.google.ch ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 29.882/30.001/30.121/0.210 ms

I've got following IP from DHCP:

dockerize@containerize:~$ ifconfig
ens33     Link encap:Ethernet  HWaddr 00:0c:29:bf:cf:78  
          inet addr:192.168.70.135  Bcast:192.168.70.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:febf:cf78/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:230 errors:0 dropped:0 overruns:0 frame:0
          TX packets:111 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:22864 (22.8 KB)  TX bytes:14513 (14.5 KB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:160 errors:0 dropped:0 overruns:0 frame:0
          TX packets:160 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:11840 (11.8 KB)  TX bytes:11840 (11.8 KB)

I can access the server via ssh. What is wrong?

Update

Network information with DHCP:

dockerize@containerize:~$ cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 192.168.70.2
search localdomain

dockerize@containerize:~$ ip route
default via 192.168.70.2 dev ens33 
192.168.70.0/24 dev ens33  proto kernel  scope link  src 192.168.70.135 

Then I change interfaces to:

# The primary network interface
auto ens33
iface ens33 inet static
address 192.168.70.10
netmask 255.255.255.0
gateway 192.168.70.1
dns-nameservers 192.168.70.2
12
  • What output does poing produce?
    – vidarlo
    Oct 20, 2017 at 9:56
  • Nothing. Just empty line. Oct 20, 2017 at 9:56
  • That doesn't seem possible. If ping failed, it should give an error message. Please edit your question and clarify that. Also explain how you access the server via ssh. Is it over a local area connection, or are you connecting over the internet? If you can connect over the internet through ssh, the machine is obviously connected to the internet and the issue is somewhere else.
    – terdon
    Oct 20, 2017 at 10:03
  • I edited my post. Oct 20, 2017 at 10:13
  • When connected via DHCP - which DNS servers do you get (cat /etc/resolv.conf) and what is the route you get (ip route)? Is it possible outgoing DNS probes are blocked? Try using the same DNS as handed per DHCP.
    – vidarlo
    Oct 20, 2017 at 10:16

1 Answer 1

2

From the information you provided based on terdons questions I conclude the following problem:

You expected the default gateway to be 192.168.70.1 when it actually is available at 192.168.70.2.

To fix this, try the following configuration for /etc/network/interfaces:

# The primary network interface
auto ens33
iface ens33 inet static
address 192.168.70.10
netmask 255.255.255.0
gateway 192.168.70.2
dns-nameservers 192.168.70.2

Note: You could still use google's DNS IPs for the values in dns-nameservers. If you want to do so, use the following configuration:

# The primary network interface
auto ens33
iface ens33 inet static
address 192.168.70.10
netmask 255.255.255.0
gateway 192.168.70.2
dns-nameservers 8.8.8.8 8.8.4.4

You must log in to answer this question.

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