photon OS
Linux

Setting a Static IP Address on Photon OS

In today’s world, where everything is connected through networks, having a stable and secure network connection is paramount. An IP address is essential for any device that needs to connect to a network, as it enables communication between devices. However, some networks may require a static IP address instead of a dynamic one.

In this article, we will explain how to set up a static IP address on Photon OS, an open-source operating system for cloud-native applications.

photon OS
photon OS

Determine the Current IP Configuration

In Photon OS, to know the current IP configuration, you can run the following command in the terminal :

# ip addr show

This command will display the current IP address, subnet mask, and default gateway.

Edit the Network Configuration File

Once you have determined the current IP configuration, the next step is to edit the network configuration file. This file contains all the network settings for Photon OS and can be edited using any text editor, such vi :

vi /etc/systemd/network/30-static.network

In this file, you will need to specify the IP address, subnet mask, default gateway, and DNS server. The file should look something like this :

[Match]
Name=eth0

[Network]
Address=192.168.2.50/24
Gateway=192.168.2.1
DNS=8.8.8.8
DNS=8.8.4.4

In this example, we have set the IP address to 192.168.2.50, with a subnet mask of 255.255.255.0/24. We have also specified the default gateway and two DNS servers provided by Google.

It is important to note that the IP address, subnet mask, default gateway, and DNS server should be changed to match your network configuration.

Restart the Network Service

After editing the network configuration file, the next step is to restart the network service to apply the changes. This can be done by running the following command in the terminal :

# systemctl restart systemd-networkd.service

This command will restart the network service, and the device should now be configured with a static IP address.

Verify the IP Configuration

To verify that the device is configured with the static IP address, run the following command in the terminal :

# ip addr show

This command will display the updated IP address, subnet mask, and default gateway.

To read this article in French, click here.

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *