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
root@lightwave02 [ /etc/systemd/network ]# cat 10-dhcp-en.network [Match] Name=* [Network] DHCP=yes root@lightwave02 [ /etc/systemd/network ]#
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] Name=eno1 [Network] Address=192.168.161.21/24 Gateway=192.168.161.2 DNS=192.168.161.9
[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
systemctl restart systemd-networkd
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.
[Match] Name=en* [Network] DHCP=yes˚
To configure static routes, in the file
10-static-en.network add any additional static routing information under the
[Route] Gateway=192.168.161.10 Destination=172.16.10.0/24
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
[Match] Name=eno* [Network] Bond=bond0
20-bond.netdev defines the behavior of the
[NetDev] Name=bond0 Kind=bond [Bond] Mode=balance-rr MIIMonitorSec=10s
[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
[Match] Name=bond0 [Network] Address=192.168.161.22/24 Gateway=192.168.161.2 DNS=192.168.161.6
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.