ip address add | del

The ip address add and del commands, add new addresses or delete old ones.
address can be abbreviated to a or addr

ip address add - Add new protocol address.
ip address delete - Delete protocol address

The device name is a required argument. The rest are optional. If no arguments are given, the first address is added/deleted.

Syntax
      ip address { add | del } IFADDR dev STRING

Key
   dev NAME
      The name of the device to add the address to.

   local ADDRESS (default)
      The address of the interface. The format of the address depends on the protocol.
      It is a dotted quad for IP and a sequence of hexadecimal halfwords separated by colons for IPv6.
      The ADDRESS may be followed by a slash and a decimal number which encodes the network prefix length.

   peer ADDRESS
      The address of the remote endpoint for pointopoint interfaces.
      Again, the ADDRESS may be followed by a slash and a decimal number, encoding the network prefix
      length. If a peer address is specified, the local address cannot have a prefix length.
      The network prefix is associated with the peer rather than with the local address.

   broadcast ADDRESS
      The broadcast address on the interface.
      It is possible to use the special symbols '+' and '-' instead of the broadcast address.
      In this case, the broadcast address is derived by setting/resetting the host bits of the interface prefix.

   label NAME
      Each address may be tagged with a label string.
      In order to preserve compatibility with Linux-2.0 net aliases, this string must coincide
      with the name of the device or must be prefixed with the device name followed by colon.

   scope SCOPE_VALUE
      The scope of the area where this address is valid.
      The available scopes are listed in file /etc/iproute2/rt_scopes.
      Predefined scope values are: 

         global - The address is globally valid.
         site   - (IPv6 only) the address is site local, i.e. it is valid inside this site.
         link   - The address is link local, i.e. it is valid only on this device.
         host   - The address is valid only inside this host.

The address is a protocol (IP or IPv6) address attached to a network device. Each device must have at least one address to use the corresponding protocol. It is possible to have several different addresses attached to one device. These addresses are not discriminated, so that the term alias is not quite appropriate for them and we do not use it in this document.

Examples:

List and show all ip address associated on on all network interfaces:

$ ip address
or just
$ ip a

Remove and flush all IP v4 addresses on all the Ethernet interfaces:

$ ip -4 address flush label "eth*"

Assign the IP address 192.168.1.200/255.255.255.0 to device eth0:

$ ip address add 192.168.1.200/255.255.255.0 dev eth0

Delete the IP address 192.168.1.200/255.255.255.0 from device eth0:

$ ip address del 192.168.1.200/255.255.255.0 dev eth0

“It is remarkable how easily and insensibly we fall into a particular route, and make a beaten track for ourselves” ~ Henry David Thoreau

Related linux commands

ip - Routing, devices and tunnels.
ifconfig - Configure a network interface.
Equivalent Windows command: ROUTE - Manipulate network routing tables.


 
Copyright © 1999-2024 SS64.com
Some rights reserved