netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* iproute equivalent of replacing address with ifconfig?
@ 2015-05-18 14:03 Michael Tokarev
  2015-05-18 17:46 ` Cong Wang
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Tokarev @ 2015-05-18 14:03 UTC (permalink / raw)
  To: Network Development

Hello.

I'm trying to find a more or less easy way to set an address of
an "interface" (I understand an interface can have N addresses).
Traditionally it was done by a comand

 ifconfig $iface 1.2.3.4 mask 5.6.7.8

What it does is effectively _replaces_ currently set address
to a new one, or just sets a new address if it is already set.
And it does that more or less atomically, at least in one go,
so that if the network has been configured before it remains
working after the command if it is successful.

ip addr command however does not have the ability to "replace"
an address, there are two commands for that, del and add.
So in order to change address, one have to delete and add,
a two-step process.  Adding an address before deleting might
not work as the new address should not conflict with old
address in any way, or else addition fails.

What I'm thinking about is, for example, a system running
out of a remote nfs root, with a dhcp client running.
Initially address has been configure by the boot loader
and is provided to the kernel/initramfs in terms of ip=
boot option.  When the system is booted, it starts dhcpc
which has to (re)configure the interface.  With ifconfig
it works just fine, but with ip addr it doesn't, since once
the old address is deleted, nfs root simple stops working,
and there's no way anymore to run anything at all.

Trying to see which addresses are already configured for
the interface, what has changed compared to the new address
etc, and working around various combinations and conflicts
in shell is not really an option, it quickly becomes
unmanageable.

What's the closest equivalent of `ifconfig $iface $address'
command to set-or-replace a (named) IP address?

Thanks,

/mjt

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: iproute equivalent of replacing address with ifconfig?
  2015-05-18 14:03 iproute equivalent of replacing address with ifconfig? Michael Tokarev
@ 2015-05-18 17:46 ` Cong Wang
  2015-05-18 18:13   ` Michael Tokarev
  2015-05-18 18:24   ` Vadim Kochan
  0 siblings, 2 replies; 4+ messages in thread
From: Cong Wang @ 2015-05-18 17:46 UTC (permalink / raw)
  To: Michael Tokarev; +Cc: Network Development

On Mon, May 18, 2015 at 7:03 AM, Michael Tokarev <mjt@tls.msk.ru> wrote:
>
> ip addr command however does not have the ability to "replace"
> an address, there are two commands for that, del and add.
> So in order to change address, one have to delete and add,
> a two-step process.  Adding an address before deleting might
> not work as the new address should not conflict with old
> address in any way, or else addition fails.

Are you sure?

$ ip addr help
Usage: ip addr {add|change|replace} IFADDR dev STRING [ LIFETIME ]
                                                      [ CONFFLAG-LIST ]
[...]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: iproute equivalent of replacing address with ifconfig?
  2015-05-18 17:46 ` Cong Wang
@ 2015-05-18 18:13   ` Michael Tokarev
  2015-05-18 18:24   ` Vadim Kochan
  1 sibling, 0 replies; 4+ messages in thread
From: Michael Tokarev @ 2015-05-18 18:13 UTC (permalink / raw)
  To: Cong Wang; +Cc: Network Development

18.05.2015 20:46, Cong Wang wrote:
> On Mon, May 18, 2015 at 7:03 AM, Michael Tokarev <mjt@tls.msk.ru> wrote:
>>
>> ip addr command however does not have the ability to "replace"
>> an address, there are two commands for that, del and add.
>> So in order to change address, one have to delete and add,
>> a two-step process.  Adding an address before deleting might
>> not work as the new address should not conflict with old
>> address in any way, or else addition fails.
> 
> Are you sure?
> 
> $ ip addr help
> Usage: ip addr {add|change|replace} IFADDR dev STRING [ LIFETIME ]
>                                                       [ CONFFLAG-LIST ]

Hm.  I looked into the manpage, where neither change nor replace are
documented.  Wonder what these do, what's the difference etc...

Thanks!

/mjt

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: iproute equivalent of replacing address with ifconfig?
  2015-05-18 17:46 ` Cong Wang
  2015-05-18 18:13   ` Michael Tokarev
@ 2015-05-18 18:24   ` Vadim Kochan
  1 sibling, 0 replies; 4+ messages in thread
From: Vadim Kochan @ 2015-05-18 18:24 UTC (permalink / raw)
  To: Cong Wang; +Cc: Michael Tokarev, Network Development

On Mon, May 18, 2015 at 10:46:58AM -0700, Cong Wang wrote:
> On Mon, May 18, 2015 at 7:03 AM, Michael Tokarev <mjt@tls.msk.ru> wrote:
> >
> > ip addr command however does not have the ability to "replace"
> > an address, there are two commands for that, del and add.
> > So in order to change address, one have to delete and add,
> > a two-step process.  Adding an address before deleting might
> > not work as the new address should not conflict with old
> > address in any way, or else addition fails.
> 
> Are you sure?
> 
> $ ip addr help
> Usage: ip addr {add|change|replace} IFADDR dev STRING [ LIFETIME ]
>                                                       [ CONFFLAG-LIST ]
Ha, but man page does not have it :)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-05-18 18:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-18 14:03 iproute equivalent of replacing address with ifconfig? Michael Tokarev
2015-05-18 17:46 ` Cong Wang
2015-05-18 18:13   ` Michael Tokarev
2015-05-18 18:24   ` Vadim Kochan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).