Changing the IP address of the iBatyr Monitor server

Automatic IP address change on Ubuntu

Note

The automatic method ensures that the current address remains unchanged. The current dynamic IP address will be set to static.

To change the address:

wget docs.ibatyr.kz/dynamic-to-static-ip.sh
sudo bash dynamic-to-static-ip.sh

If you want to immediately set a specific address to the server, enter this address separated by a space after the script name, for example like this:

sudo bash dynamic-to-static-ip.sh 192.168.1.132

Manually changing IP address on Ubuntu

Warning

Relevant only for version 4.7 and higher

In Ubuntu, the Netplan utility is used to set the server’s static IP address.

1. Install Netplan

apt install netplan

All Netplan settings are performed only as user root. To do this, enter root mode using the sudo su - command and enter the standard user password:

sudo su

2. Disable Cloud-init

After installing Netplan, disable Cloud-init.

Note

Cloud-init is a tool for configuring servers during startup. On servers with static IP addresses, Cloud-init can reset manually configured network settings. To keep network settings unchanged, disable network management for Cloud-init.

Create a file:

sudo nano /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg

Add a line to the file that disables network management for Cloud-Init:

network: {config: disabled}

To prevent network settings from being overwritten, delete the configuration file that Cloud-init creates for Netplan:

sudo rm -f /etc/netplan/50-cloud-init.yaml

After this, you can create your own configuration.

3. Create a configuration

Determine which file contains the current configuration. To do this, look at the contents of the /etc/netplan folder using the ls command:

ls /etc/netplan
Illustration 1 — Changing the IP address of the iBatyr Monitor server

In this example, the configuration is in the file 01-netcfg.yaml. Launch the Nano editor with the parameter – the name of this file:

nano /etc/netplan/01-netcfg.yaml

An editor window will open.

Illustration 2 — Changing the IP address of the iBatyr Monitor server

Add the snippet to the file:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s3:
      dhcp4: no
      dhcp6: no
      addresses: [192.168.124.200/24]
      gateway4: 192.168.124.1
    nameservers:
        addresses: [192.168.124.1, 8.8.8.8, 8.8.4.4]

Where:

  • replace the address 192.168.124.200 in the first line addresses with the address of your server;

  • mask /24 corresponds to 255.255.255.0. If it matches your mask, don’t change anything. Otherwise, replace with yours;

  • address 192.168.124.1 in line gateway4 or via - to your gateway address;

  • the values of the DNS server addresses in the second line addresses - to the values of the addresses of their DNS servers;

  • There must be at least one empty line at the end of the text.

After making changes, exit edit mode using Ctrl+X. The editor will ask you to save the modified file:

Illustration 3 — Changing the IP address of the iBatyr Monitor server

Answer by pressing Y (yes). The editor will suggest a file name to save. Press Enter to agree.

Apply the configuration:

netplan apply

If the output is without errors, everything was done correctly. To be sure, reboot using the reboot command and check that you have received an IP address:

ifconfig -a
Illustration 4 — Changing the IP address of the iBatyr Monitor server