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
/etc/network/interfaces
for? And what happens if it conflicts with, for example,/etc/NetworkManager/system-connections/ethernet-ens1
? I don't know how to get a newline in the comment, but here is what I did:nmcli connection add type ethernet ifname ens1 ; nmcli connection edit ethernet-ens1 ; nmcli -p con up ifname ens1
– Erik Bennett Aug 16 '17 at 20:12nmcli
differs between Ubuntu versions. I only mention it for future explorers. -E – Erik Bennett Aug 16 '17 at 20:15nmcli
andnmtui
. – Ali Ghasempour Aug 17 '17 at 02:09