Set Static IP on Ubuntu Trusty Server (14.04.1)

Hello, everyone,

I’m setting up VMware for the first time. I’m also setting up Ubuntu Server for the first time (using Trusty 14.04.1).

I’m trying to set a static IP for the server, and I’ve Googled for the instructions, looked at several posts/articles and followed the directions, but it just isn’t working.

Unfortunately, many instructions are how to do it from the GUI. Well, Ubuntu Server doesn’t come with a GUI, and I really don’t want to install one.

Some instructions indicate to remove the networking manager; or remove it and replace it with Wicd. I’ve modified config files, and tried to restart the networking service, only to have it fail. Either it says that the instance is unknown, or it won’t restart.

I’m at work, now, and don’t have access to it… but if you need to know anything about the installation, I’ll be at home, tonight, and can look things up.

I’m hoping someone can help me set it so that my Ubuntu Server can claim a static IP (I’m trying to use one that is OUTSIDE the DHCP reserved IPs.)

V/r,

:slight_smile:

Okay… ignore the VMware part, that is superfluous information that doesn’t apply.

How can I set Ubuntu Trusty (14.04.1 without a GUI) for a static IP address?

V/r,

:slight_smile:

It looks like it has a shell CLI
Did you make through these steps OK ?
http://developer.ubuntu.com/en/start/ubuntu-sdk/installing-the-sdk/

An SDK? I’m sorry, Mittineague, I’m not following. How will installing an SDK for making Ubuntu Apps help with setting a static IP address?

V/r,

:slight_smile:

Sorry, I was thinking this was a localhost install. Is this something the host can help with?

It is a local install in VMware, no hosting service. I have an internal network (ie, 192.168.x.x) and I’m trying to set up an Ubuntu server, but do not want a dynamic IP address, as this will be for my personal development network. I will also be adding another (Windows) server for database; but I know how to set a static IP address in Windows. :smile:

V/r,

:slight_smile:

I have Windows as well and have a rough time with VMs (more luck than anything else when I succeed). I’ll try a bit to find out more, but hopefully @cpradio has the know-how.

1 Like

Thanks, @Mittineague. I’ve got Ubuntu installed and seeing the internet, it’s just with a dynamic IP address.

But if @cpradio has any advice on getting that to a static IP, I’m all ears! :smile:

V/r,

:slight_smile:

So VMWare isn’t handing your VM with an IP? The VM is auto-assigning its own IP?

If you want Ubuntu to have a specific IP, I can definitely help with that :smile:

sudo nano /etc/network/interfaces

Comment out the following line

iface eth0 inet dhcp

Add the following lines:

iface eth0 inet static
        address 192.168.X.X # replace the X's accordingly
        netmask 255.255.255.0
        gateway 192.168.1.1 # or 192.168.0.1, or whatever your network is setup to use

Restart the networking service (although you may need to reboot the VM)

I tried that. When rebooting (or restarting network services), network service fails.

V/r,

:slight_smile:

hmm… Okay, so I’d probably make the server back to iface eth0 inet dhcp and look at the VM Network Settings in VMWare. There should be a way to statically set the IP within the VMWare Web App or GUI for a given VM.

It has been many years since I’ve had to do it, but I know it can be done.

Here’s the thing that’s confusing (non-intuitive) for me as far as VMware is concerned.

I asked a friend of mine about the Network Editor for VMware (I’m running Workstation v11). I was confused that it (by default) set itself with two IP addresses that are not in my local network (I have 192.168.2.x; it assigned 192.168.332.0 and 192.168.333.0 to two VMnets.) He said something about VM needing to have it’s own IP addresses for a different network to act as proxy, so when it gets an IP address from my DHCP server (it’s in bridged mode), it will process the NAT and assign the correct IP address for the OS inside the VM. (Confused, yet? I am.)

So… yeah… maybe it IS an issue in VM and not Ubuntu. IDK. I should have spent years learning VM, and am regretting not having done so.

V/r,

:slight_smile:

Okay, so it seems my original advice should have worked… maybe you had the gateway incorrect?
http://webcache.googleusercontent.com/search?q=cache:oilgw4oC3j4J:www.doublecloud.org/2013/03/configure-static-ip-address-on-linux-vm-in-vmware-player/+&cd=8&hl=en&ct=clnk&gl=us

And in case you can’t access that.

[quote]If you run VMware Player, you would have 3 networking options for virtual machines running there: Bridged, NAT, Host-Only. In the latest 5.0.1, I also found a new one: LAN Segment. This blog has a nice explanation on these three settings if you want to get more details.

In most of cases, I use NAT for networking because the virtual machine can have Internet access which allows me to install additional software as needed. By default, VMware Player uses DHCP to dynamically assign IP address while using NAT. So you cannot guarantee to get same IP address after each rebooting.

You can set static IP address for a VM running on VMware Player with a little trick. On a Debian Linux machine like Ubuntu, you can edit a configuration file:[/quote]

sudo vim /etc/network/interfaces
# 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 static
  address 192.168.47.200
  netmask 255.255.255.0
  broadcast 192.168.47.255
  gateway 192.168.47.2
dns-nameservers 192.168.47.2
sudo service networking restart

[quote]In my case, the VMnet8 which is the network adapter for the NAT network has an IP address of 192.168.47.1. When I first modified the interfaces file, I used it as the gateway IP address and failed to ping outside the network.

To figure it out why, I reversed back to the DHCP configuration (change the ifacce line to “iface eth0 dhcp” and delete the lines afterwards). In the DHCP mode, typing command “route –n” will show working gateway IP address: 192.168.47.2.

By default, the gateway IP is configured to use X.X.X.2. This can be changed with Virtual Network Editor which is not included in VMware Player. I will show you how to hack it in next post.[/quote]

My network is 192.168.2.x. My host system is static 192.168.2.160. My gateway is 192.168.2.1. What I had edited for the /etc/network/interfaces:

auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
  address 192.168.2.161
  netmask 255.255.255.0
  broadcast 192.168.2.255
  gateway 192.168.2.1
dns-nameservers 8.8.8.8

When I typed sudo service networking restart, I saw something about stop: unknown service and start: networking services failed.

The VM is in bridged mode, two CPU cores, 4Gb RAM, 80Gb drive.

V/r,

:slight_smile:

Yeah, the service command may not be applicable any more.

Try

sudo /etc/init.d/networking restart

If you still get a failure, see what errors may be present in /var/log/syslog

Thanks, cpradio. I’ll give that a shot after I get home from work.

V/r,

:slight_smile:

Okay… I don’t know what just happened.

sudo /etc/init.d/networking restart didn’t work, either. I think I got rid of the default networking manager and installed wicd.

But, I re-edited the /etc/network/interfaces file, did a reboot, and there were no issues with networking when it booted up. I even did a ping google.com and got responses.

So… I have ZERO idea why it’s now working, but it’s working. :blush:

Thanks to everyone for your help!

V/r,

:slight_smile:

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.