Ubuntu 16.04 setting static IP address

I’m trying to set up an Ubuntu server on a virtual machine hosted on a windows OS. When I set it to the default DHCP the internet works fine. When I attempt to setup a static IP I get TX but no RX.

The following is my /etc/network/interfaces

# The loopback network interface
auto lo
iface lo inet loopback

# Primary network interface
auto enp0s3
iface enp0s3 inet static
    address 192.168.1.151
    netmask 255.255.255.0
    gateway 192.168.1.1
    dns-nameservers 8.8.8.8 8.8.4.4

I got the address from my host machine when I did an ipconfig /all

Most of the solutions ive seen to similar problems have to do with not having a DNS server named but I do have one so I’m not sure what else to do.

Any help is greatly appreciated. Thanks!

Answer

Since ipconfig /all is a windows command I assume you ran it on the host. Your virtualization software will use a different subnet for the internal network.

If you have configured your virtual network with NAT you can either look up in the documentation of whatever software you are using which IP subnet is used, or switch back to DHCP and check inside the VM which IP settings are used. Then configure your static IP accordingly.

A second possibility would be to configure bridged networking, then you can use IP addresses in the same IP range as your host.

Attribution
Source : Link , Question Author : Justin , Answer Author : Gerald Schneider

Leave a Comment