Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 03-17-2012, 11:23 PM   #1
LQ Newbie
Registered: Mar 2012
Posts: 1

Rep: Reputation: Disabled
How to change DHCP IP to static IP with

I have just rented a Root Server with Ubuntu 10.04 LTS minimum installation. has a specific way of assigning IPs through DHCP to dedicated servers and I would happily live with DHCP, but I want to utilize Virtualmin, for which static IP is recommended as it stated reads on

While obtaining an IP address, the DNS servers provided by your DHCP server are used in place of what's currently setup on your server.

For a server, we'd suggest using static IP's where possible. That would prevent your DNS servers from being overwritten, as well as removing any chance of your server obtaining the wrong IP address.
I've been struggling to turn 1and1's DHCP IP to static IP for already two days, exhausted and gladly will offer some bounty to anyone who solves this Gordian Knot.

Given data:

Server IP: (1and1 gives only one free IP with the server, so no other IPs)

cat /etc/hosts localhost.localdomain localhost u16150189
(I don't change anything here for now, since my goal to get DHCP IP changed to static one.)

cat /etc/network/interfaces

# The loopback network interface
auto lo eth0
iface lo inet loopback

iface eth0 inet dhcp

# auto eth0
# iface eth0 inet static
# address
# netmask
# broadcast
# network
# gateway
eth0      Link encap:Ethernet  HWaddr 00:25:90:57:f1:4a  
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::225:90ff:fe57:f14a/64 Scope:Link
          RX packets:3541 errors:0 dropped:0 overruns:0 frame:0
          TX packets:571 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:292548 (292.5 KB)  TX bytes:70346 (70.3 KB)
          Interrupt:17 Memory:fe9e0000-fea00000 

lo        Link encap:Local Loopback  
          inet addr:  Mask:
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:28 errors:0 dropped:0 overruns:0 frame:0
          TX packets:28 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:2704 (2.7 KB)  TX bytes:2704 (2.7 KB)
netstat -nr
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface         UG        0 0          0 eth0 UH        0 0          0 eth0

After commenting out dhcp, opening static interface

# The loopback network interface
auto lo eth0
iface lo inet loopback

# iface eth0 inet dhcp

auto eth0
iface eth0 inet static
and running
/etc/init.d/networking restart
I loose SSH connection and the networks never comes back.

Luckily 1and1 provides console through which I can access my server and change the settings.

What else I should do to get this done? Anyone can help me with this for some bounty, please?
Old 03-26-2012, 06:41 PM   #2
LQ Newbie
Registered: Mar 2012
Posts: 1

Rep: Reputation: Disabled
Hi there,

I've just spent all afternoon into looking into a similar problem, I think the problem is because they're using a gateway that's on a different subnet and when setting statically it can't talk to the gateway (kind of guessing), however after a load of fiddling around I've found the solution:

PHP Code:
route add -host dev eth0
route add 
default gw dev eth0 
That should get you going apparently to set it up as a permanent thing whenever you restart networking you should add the following to the bottom of /etc/network/interfaces :

PHP Code:
up route add -host dev eth0
up route add 
default gw dev eth0 
However I've not managed to get that to work yet, but I am messing around with virtual interfaces and bridges so you might have more luck.

Hope this helps!
Old 03-28-2012, 04:33 AM   #3
Registered: May 2011
Location: Nottingham, UK
Distribution: Debian
Posts: 178

Rep: Reputation: 34
If they have layer 2 security configured (ARP inspection, DHCP snooping etc.) it might not be possible to avoid DHCP. Another concern would be, if they do change your IP assignment to something in a different subnet and you have it staticaly configured, you might lose connectivity altogether.
I would stick to the DHCP provided IP, just make resolv.conf unwritable with 'chattr +i /etc/resolv.conf' so DHCP can't change your DNS servers. That's what I am doing anyway


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't change from dhcp to static ip address. Darrell22 Linux - Networking 7 01-17-2010 11:00 PM
Change from DHCP to Static IP? walterbyrd Red Hat 1 06-23-2008 11:43 PM
How do I change from DHCP to static IP? walterbyrd Debian 3 05-11-2006 07:58 PM
FC2 Overriding static if in favor of dhcp system set for static pkraus109 Linux - Networking 8 09-21-2004 12:13 PM
Change DHCP to Static in RH9 jimbo Linux - Networking 6 03-30-2004 08:33 PM

All times are GMT -5. The time now is 08:43 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration