.. _network-interfaces:

Network interfaces
------------------

.. _21.4-PB3|EKB-17143:
.. _24.1|VOSS-1305:

.. index:: network;network interfaces
.. index:: network;network name
.. index:: network;network <interface-name>
.. index:: network;network routes
.. index:: network;network static_host
.. index:: network;network -4 del
.. index:: network;network -6 del
.. index:: cluster;cluster del



.. important::

   From Automate release 24.1 onwards, network addresses are in CIDR (Classless Inter-Domain Routing)
   format, for example: ``192.168.100.3/27`` or ``e00d::fafe:23/112``. The use of a netmask in the
   ``255.255.255.0`` format is no longer supported.


The command **network interfaces** will display the available network interfaces
and their configuration.  

The hostname can be set or changed with **network name <hostname>**.

.. note::

   The maximum character length for the hostname is 56.

A network interface can be configured or changed as follows: 

**network <interface-name> <cidrIP> <netmask> <gateway>**

For example: 

* IPv4:

  **network eth0 172.29.89.100/24 172.29.89.1**

* IPV6:

  **network ens160 a00d::eafe:3/112 a00d::eafe:25**

The gateway can be configured using:

**network <interface-name> gateway <gateway>**

The network interface with IP, netmask and gateway can be configured with:

**network <interface-name> <cidrAddress> <gateway>**

The IP address can be changed without affecting the netmask and gateway using:

**network <interface-name> ip <ip>**

or

**network <interface-name> ip <ip>/<netmask>**

For example IPv4: **network eth0 ip 172.29.89.100**.


Deleting a IPv4 interface: **network -4 del ens160**
Deleting a IPv6 interface: **network -6 del ens160**


.. rubric:: How to change a Network Interface

The steps below apply to the network interface change on both single node and multi-node topologies.

.. note::

   * During this process, the application or database primary might be migrated automatically to a new node. 
   * Ensure you are working on the correct node when running the below commands by checking with the `cluster primary` command. 
   * A single node system will have all commands run on it unless otherwise stated.

1. If the node to be changed is a database or unified node, then record the currently assigned database weight `database weight list`.
2. On the current application primary run: `cluster del <IP>` where IP is the IP address of the node being changed.
3. On the node being changed, run `network list` and note the interface name that will be changed.
4. On the node being changed, run the `network <interface> ip <newIPAddress>` command to change the IP.
5. Reboot the node being changed.
6. If not a single node (standalone): 

   Log in as the platform user to the node with the new IP address and run `cluster prepnode`.

7. On the current application primary run `cluster add <newIPAddress>`
8. On the current primary database or unified node (not standalone / single node), 
   run `database weight add <NewIPAddress> <weight>` to restore the database weight
   previously assigned to the changed node.
9. On the current primary application node, run `cluster provision`.
10. On the current application primary node, ensure services are restored by running:
    `cluster check` and `cluster run all app status`. 
11. If any services are not running, try and restart them using: `app start <service>`.




.. rubric:: Network Routes

Network routes can be displayed with **network routes**.  

* To add a route to a subnet (using ``<netmask>``):

  * via a specified gateway: **network routes <network-ip>/<netmask> <gateway>**
  * via a specific gateway and interface: **network routes <network-ip>/<netmask> <gateway> dev <interface-name>**
* To a host without specifying the gateway: **network routes <host-ip> dev <interface-name>**.
* Network routes can be deleted with **network routes del <network-address>**.


.. rubric:: Network Static Hosts

Static hosts can be maintained in ``/etc/hosts`` by using the following commands:

* Add: **network static_host add <host> <ip>**
* Delete: **network static_host del <host>**
* List: **network static_host list**

Example:

::

   $ network static_host list
       static_hosts: 
           lab.solutions.com: 10.121.1.42

