Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Need to configure an static IP address, I'm doing tests with WordPress in a Virtual Machine with Linux (on VMWare Player) and I want a static IP on that VM and internet connection. I tried configurin the file /etc/network/interfaces like this:

auto eth0
iface eth0 inet static
address 192.168.100.145
netmask 255.255.255.0

I need to set up a gateway too? And how I need to do this? My laptop is always changing from networks like home or school

What I need to configure VMware? NAT or Bridged? I discard Host-only because I need internet connection too.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Since you change your network connection often, it makes little sens to use a static IP configuration. You see, when you change configuration in /etc/network/interfaces, you certainly need to specify the network and the gateway, besides mask and your own address (plus, if you wish, broadcast and dns-nameservers). The first three specs (gateway, network, mask) change from LAN to LAN, so it is possible that your chosen IP address belongs to a completely different network: in this case, you would be left incommunicado.

Also, it is possible that your chosen address is already taken, which would cause a number of difficult-to-diagnose malfunctions (just try it once, for pure fun, you'll see it).

As for syntax, a correct, simple configuration is:

 auto eth0
 iface eth0 inet static
    address 192.168.15.25 
    netmask 255.255.255.0
    gateway 192.168.15.1
    dns-nameservers 8.8.4.4 8.8.8.8

to which you may add pre-up/post-up/pre-down/post-down to specify actions to be executed before/after connection/disconnection.

If however you insist on retaining your xxx.xxx.xxx.145 address, you will have to learn how to listen to a network without having a proper IP address, to discover whether a 145 address has been given to someone already.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.