Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to use DHCP to pick up the network configuration information including DNS, but still assign a static IP address.

On OS X, this is "Using DHCP with manual address", but I see no similar configuration option for ubuntu in the GUI, and I can't find any information about how to configure /etc/network/interfaces to do that.

share|improve this question
    
For what it's worth, I have this exact same question. It looks like perhaps the right answer for me is from @Khaled, though... has anyone gotten that to work? The syntax given is a null-op for me. – Dav Clark Aug 8 '15 at 6:15
    
Actually, it was working, I just didn't see it (per my ip addr show comment below). – Dav Clark Aug 8 '15 at 7:25
    
None of the current answers are satisfactory. In my case, I wanted to do this for a VMware guest using NAT networking (vmnet8). I was able to fix this by configuring a static address reservation in VMware's DHCP server config on the host. On OSX this file is in /Library/Application Support/VMware Fusion/vmnet8/dhcpd.conf by adding the following: host myguestvm { hardware ethernet <guest's NIC's MAC address>; fixed-address 172.16.xxx.yyy; } (You need to restart VMware or, prior to VMware v3, restart the DHCP service separately). – Tom Dec 9 '15 at 3:32

Or you can just set up IP address reservations in your DHCP server. This associates IP addresses with specific MAC addresses, so that the same network interface always gets the same IP address. Consult your DHCP server documentation for details.

share|improve this answer
1  
That's what I normally do, but apparently that's not possible with the DHCP server we're using (Cisco ASA 5505) - it doesn't support DHCP reservations. Yes, I could switch to another machine for running the DHCP server, but that is more work than what my question is asking. – fields Jan 15 '13 at 18:30

You can append the following line to your /etc/network/interfaces file:

post-up ip addr add 192.168.0.1/24 dev eth0

Of course, you can change the IP/mask and interface name to suit your needs.

share|improve this answer
    
That will still use up an ip address reservation slot from the dhcp pool though, right? – fields Jan 15 '13 at 15:31
    
This will just execute the ip utility to assign additional IP address whenever the interface becomes up. – Khaled Jan 15 '13 at 15:34
2  
That's the entirety of my question - how to assign a static IP address while still using DHCP for the other configuration information. This should be possible somehow. – fields Jan 15 '13 at 15:41
1  
Your suggestion doesn't work for me @Khaled. Has this command changed in recent years? I don't see anything about it in the man pages... – Dav Clark Aug 8 '15 at 6:16
1  
@DavClark: See man interfaces. – Khaled Aug 8 '15 at 7:16

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.