Change IP address of ethernet device while system is running

Karl Auer kauer at biplane.com.au
Wed Dec 28 09:18:47 UTC 2016


On Wed, 2016-12-28 at 03:44 -0500, Tom H wrote:
> On Thu, Dec 8, 2016 at 6:53 AM, Christoph Pleger
> <Christoph.Pleger at cs.tu-dortmund.de> wrote:
> > on a computer running Ubuntu 16.04, I am trying to change the
> > static IP address of an ethernet device, while the system is
> > running.

Provided that NetworkManager (or similar) is not trying to change
things dynamically on the interface as well (and it should not be, if
you have an entry in /etc/network/interfaces for it), then the
following procedure will work.

Let's say you want to change the address from 10.0.1.200/24 to
192.168.100.3/24 on eth0:

   sudo ip addr add 192.168.1.200/24 dev eth0
   sudo ip addr del 10.0.1.200/24 dev eth0

Then edit /etc/network/interfaces (or whatever) at your leisure. The
change above will remain in force until you next boot. After the next
boot, the addressing in /etc/network/whatever will be in force. Don't
expect active connections on the deleted address to behave predictably
when you do the above.

If you have complicated stuff in /etc/network, or if this is a
production system, or if the next boot is a long way off, Tom H's
advice is best:

> It's best to run
> 
> # ifdown $ifname
> # vi /etc/network/interfaces.d/$ifname
> # ifup $ifname

Regards, K.

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Karl Auer (kauer at biplane.com.au)
http://www.biplane.com.au/kauer
http://twitter.com/kauer389

GPG fingerprint: E00D 64ED 9C6A 8605 21E0 0ED0 EE64 2BEE CBCB C38B
Old fingerprint: 3C41 82BE A9E7 99A1 B931 5AE7 7638 0147 2C3C 2AC4







More information about the ubuntu-users mailing list