As more virtual appliances from VMware come with Photon OS, I would like to share a few simple workarounds to assign a static IP address and other network parameters to the virtual machines based on this operating system.
In Photon OS, the process systemd-networkd is responsible for the network configuration. You can check its status by executing the following command:
[ ~ ]# systemctl status systemd-networkd -l
It should give you an output similar to one in the picture below.
By default, systemd-networkd receives its settings from the configuration file 10-dhcp-en.network located in /etc/systemd/network/ folder. It has the following format:
I would recommend renaming this file to 10-static-en.network. So it will be easy to troubleshoot network issues in the future.
The file syntax is similar to what is used in Arch Linux. With few additional lines in the file, the network configuration can be set to our requirements. They are as follows:
- In section [Network]
- Address – the IP address and subnet mask in the format of XXX.XXX.XXX.XXX/YY
- Gateway – an IP address of the default gateway
- DNS – IP addresses of one or more DNS servers (space-separated values)
- Domains – domain name(s) in FQDN format (space-separated values)
- NTP – IP addresses or FQDNs of NTP sources (space-separated values).
An example of the static network configuration is shown below.
The hostname of the system can be added to /etc/hostname file in FQDN format.
All changes should apply after rebooting the virtual machine. To test the results, we can use the following commands:
- ip a – shows the IP addresses of the network interfaces
- ip route – shows the routing table,
- systemctl status systemd-timesyncd -l – shows time synchronisation status.