3

How do I assign static IP addresses to interfaces in Ubuntu (17.04) without rebooting the machine? This is pretty straightforward on a Unix machine, but I'm having trouble on this one.

Please don't mark this as duplicate (just yet). I've read a number of other posts, but the instructions don't seem to work.

I'm configuring a bunch of routers and switches and I need to be able to:

  • Permanently (survives a reboot/crash) change the the IP of an interface
  • Permanently (survives a reboot/crash) change the interface back to DHCP (or BOOTP, or whatever)
  • Make these changes without X (and with, from an xterm).

I've already tried editing /etc/network/interfaces and running /etc/init.d/networking restart as mentioned here. This failed to change anything until I rebooted.

The machine was originally set up with DHCP. I'd like to be able to go back and forth quickly. The machine has several interfaces, and because it's used to configure other people's networks, I need to be able to switch them with as little fuss as possible.

If I boot it with a static IP, what do I need to do the get a DHCP address?

If I boot with DHCP and switch to static, will I have to kill off dhclient? What about other DHCP controlled interfaces?

Thanks.
-E

2 Answers2

3

Network manager is service manager networking on your Linux , This service contain some interfaces to work with it . nmcli is one of the richest interface to manager networking .

If you want set static IP to your Linux via nmcli try following command :

$ nmcli connection modify eth0 ipv4.address x.x.x.x/y

With above command you permanently add IP to your interface . ( replace eth0 with your interface name ) .

Than run following comand :

$ nmcli connection up eth0

To active your connection without rebooting .

Ali Ghasempour
  • 449
  • 3
  • 7
0

I found NetworkManager to be too unpredictable for my use. The answers, in my case were to be found in the interfaces(5) man page. More discussion on NetworkManager may be found here. This is not an indictment of NetworkManager, but rather a note that it didn't work for me. Everytime I would unplug the interface from the switch and move it to a different port, NetworkManager would go to work reconfiguring the interface on my machine.