Issue
I need to change my connection, from staic assigned to DHCP using nmcli (invoked from a Python script). I've tried like this:
nmcli con mod "CONNECTION NAME" ipv4.method auto
nmcli con down "CONNECTION NAME"
nmcli con up "CONNECTION NAME"
But after the connection has gone up again, my old IP address is still there and if I show info for the connection I see something like that
....
ipv4.addresses: 192.168.1.10/24 <-THIS IS THE BAD ONE
....
IP4.ADDRESS[1]: 192.168.1.10/24 <-THIS IS THE BAD ONE
IP4.ADDRESS[2]: 10.0.2.15/24
....
How can I solve this?
Ubuntu version 16.04
Python version 3.5.2
Solution
Not having a linux system in front of me, but if I remeber correctly, you can try to reset the IP addresses before the down/up:
nmcli con mod "CONNECTION NAME" ipv4.address ""
nmcli con mod "CONNECTION NAME" ipv4.method auto
nmcli con down "CONNECTION NAME"
nmcli con up "CONNECTION NAME"
Answered By - nirebu Answer Checked By - Katrina (WPSolving Volunteer)