2

I've setup a VM running Ubuntu 12.04 specifically for local web development and am having some problems ensuring it has a static IP address. A static IP address is important as I'm using the IP address in my hosts file to assign a .local suffix to addresses used both in browser and to connect to the correct database on the VM.

Currently, every time I connect to a new network or my VM is assigned a new IP address I need to reconfigure my whole environment which is becoming quite a pain. It also probably doesn't help that the default-lease-time on the Ubuntu VM is set to 1800 by default.

At the moment I'm using VMWare Fusion and the Network Adapter is enabled and set to "Autodetect" under Bridged Networking.

I've tried to set a static IP address within the dhcpd.conf using the code below:

host ubuntu {
    hardware ethernet 00:50:56:35:0f:f1;
    fixed-address: 192.168.100.100;
}

The fixed-address that I've used is also outside the range specified in the subnet block (which in this case is 192.168.100.128 to 192.168.100.254).

I've tried adding and removing the network adapter and restarting my Mac after each time to no avail.

Below is an ifconfig of the VM that might be of some help:

eth0  Link encap:Ethernet  HWaddr 00:50:56:35:0f:f1
      inet addr:192.168.0.25  Bcast:192.168.0.255  Mask:255.255.255.0
      inet6 addr: fe80::250:56ff:fe35:ff1/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:1624 errors:0 dropped:0 overruns:0 frame:0
      TX packets:416 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000
      RX bytes:147348 (147.3 KB)  TX bytes:41756 (41.7 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:16436  Metric:1
      RX packets:0 errors:0 dropped:0 overruns:0 frame:0
      TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0
      RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Are there any specific issues with 12.04 that I'm missing? Otherwise has anyone else got any ideas?

Thanks in advance.

5 Answers 5

2

To achieve static IP, edit /etc/network/interfaces and add:

auto eth0
iface eth0 inet static
address 192.168.100.100
netmask 255.255.255.0
gateway 192.168.1.1 # or whatever your gateway is

Then enable the device with sudo ifup eth0 and you should be done.

0

May be you edit wrongly in dhcp config file.

No need to give static ip address in dhcp config.

Open your interface file and edit this lines:

auto eth0 or eth1 or eth2 ...
iface inet eth0 static
address 192.168.100.2
netmask 255.255.255.0
network 192.168.100.0
broadcast 192.168.100.254
gateway 192.168.100.1
0

Mikes answer worked for me except I needed to add a DNS entry:

dns-nameservers 192.168.1.1
0

Open the file /etc/vmware/vmnet8/dhcpd/dhcpd.conf and add the command similar to the following.

host VMnet8 {
  hardware ethernet 00:0c:29:bc:5b:9a;
  fixed-address 192.168.224.21;
}

Then restart your host and start the vm.

0

You may find something like this in your /etc/network/interfaces:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

Then just add the bellow code if your machine is not using CentOS

# The primary network interface
auto ens33
#iface ens33 inet dhcp
iface ens33 inet static
    # This value is an example
    address 192.168.1.10
    # This value is an example
    netmask 255.255.255.0
    # This value is an example
    network 192.168.1.0 #
    # This value is an example
    broadcast 192.168.1.255
    # This value is an example
    gateway 192.168.1.1

# This value is an example
dns-nameservers 8.8.8.8 8.8.4.4 # This value is an example

Then finally restart your networking service

service networking restart

or

/etc/init.d/networking restart

You must log in to answer this question.

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