Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[nmcli] replace ip address in edit mode
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
pablo_supertux
Advocate
Advocate


Joined: 25 Jan 2004
Posts: 2931
Location: Somewhere between reality and Middle-Earth and in Freiburg (Germany)

PostPosted: Mon Jun 27, 2022 2:20 pm    Post subject: [nmcli] replace ip address in edit mode Reply with quote

I have an interface that has the IP address 192.168.10.1/24. I wanted to change it to 192.168.10.10/24

Code:

nmcli connection edit eth1-static

nmcli> print ipv4.addresses
ipv4.addresses: 192.168.10.1/24

nmcli> set ipv4.addresses 192.168.10.10/24
nmcli> print ipv4.addresses
ipv4.addresses: 192.168.10.1/24, 192.168.10.10/24



My problem ist that the set command just appended the new address to ipv4.addresses. I cannot find a way to remove entries from the list, I can only add new elements to the list. And even calling set ipv4.address 192.168.10.10/24 the IP is added to the list instead of replacing it.

How can you do that in the edit mode? I'm aware that I can do that with nmcli conn mod eth1-static ipv4.addresses "192.168.10.10/24" but like I said, this is not the case in the edit mode.
_________________
A! Elbereth Gilthoniel!
silivren penna míriel
o menel aglar elenath,
Gilthoniel, A! Elbereth!
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3879

PostPosted: Mon Jun 27, 2022 3:52 pm    Post subject: Reply with quote

Try
Code:

nmcli con mod eth1-static ip4 192.168.10.10/24
or if not working
nmcli con mod eth1-static ipv4.address 192.168.10.10/24
#### INITIALLY IP IS ASSIGNED BY IP4 AND AND WHEN MOD-ING BY IPV4.ADDRESS SAME GOES WITH IP(V)6

If you still get two addresses try
Code:

nmcli con mod eth1-static -ipv4.address <ip-to-remove/24>

In the unlikely case that there is a chaos going on try
Code:

nmcli con del eth1-static  #### CAUTION YOU WILL BRIEFLY LOOSE CONNECTIVITY
nmcli con add type ethernet con-name eth1-static ifname <physical-iface-name> ip4  192.168.10.10/24 gw4 <router-ip-no-cidr>
nmcli con mod  eth1-static ipv4.dns <dns-ip-no-cidr> ipv4.method manual
nmcli con up eth1-static

Quote:

How can you do that in the edit mode? I'm aware that I can do that with nmcli conn mod eth1-static ipv4.addresses "192.168.10.10/24" but like I said, this is not the case in the edit mode.


Just saw this.
Why use edit mode then?
Maybe
Code:

nmcli>remove ipv4.addresses <ip-to-remove/24>
nmcli>save

See
Quote:

nmcli> ?
------------------------------------------------------------------------------
---[ Main menu ]---
goto [[setting] | [prop]] :: go to a setting or property
remove [setting][.[prop]] | [prop] :: remove setting or reset property value
set [[setting].[prop] [value]] :: set property value
describe [[setting].[prop]] :: describe property
print [all | [setting][.[prop]]] :: print the connection
verify [all | fix] :: verify the connection
save [persistent|temporary] :: save the connection
activate [[ifname]] [/[ap]|[nsp]] :: activate the connection
back :: go one level up (back)
help/? [[command]] :: print this help
nmcli [conf-option] [value] :: nmcli configuration
quit :: exit nmcli
------------------------------------------------------------------------------
nmcli>

Again why choose a more complicated approach over a simpler one?
_________________
:)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum