Photon instances are usually meant to be configured automatically with Cloud-config, this includes hostname, network settings, additional packages, etc. However there are some corner cases where you may need to manually configure an static IP address, like a Lightwave domain controller or a DNS server.
Static addressing configuration
By default in Photon OS DHCP comes enabled for all present network interfaces. This is more than enough for testing however for more permanent services like a Lightwave server is desirable to use static IP addresses.
If you are used to work with Red Hat or any of its variants your first move will be to look at
/etc/sysconfig/network-scripts/ however there is nothing there, actually the path does not even exists. In Photon the network subsystem is controlled by
Drop a unit file in
/etc/systemd/network to configure static IP address for a certain interface. Remove the unit file used for DHCP, name the file
10-static-en.network and include the following content.
[Match] section defines the network interfaces the configruation will be applied to, in this case
eno1, and the
[Network] section the configuration itself.
To apply the new settings restart
If you need to configure static IP for one interface and leave DHCP for the rest create two unit files:
In the first one include a configuration similar to the one described before and for the second one use the following DHCP unit file.
To configure static routes, in the file
10-static-en.network add any additional static routing information under the
networkd unit file we can create and configure a
bond interface to provide load balancing and redundancy to the network connectivity within our Photon OS instance.
First remove any DHCP related unit file. And create three new files:
10-en.network will indicate
networkd to put our
eno interfaces under
20-bond.netdev defines the behavior of the
[NetDev] defines the name and kind of the network device and
[Bond] defines de mode, by default
MIIMonitorSec the interval of seconds for the link monitoring operation.
30-bond-static.network stores the IP configuration for
I recommend to review
systemd-networkd official documentation to get more details about the different options available. Stay tuned for more Photon content in future posts. And of course comments are welcome.