-
Notifications
You must be signed in to change notification settings - Fork 10
How to Configure Networking on Photon OS with network config manager
network-config-manager is the Photon OS network configuration tool in all Photon OS 4 versions onwards. network-config-manager is based on a YAML-based configuration system that makes the configuration process very simple.
In this tutorial, you will learn how to configure networks in Photon OS using network-config-manager. We will look at both static and dynamic IP configurations. I will be using Photon 4.0 to describe the process in this article.
You can find the new configuration files at /etc/network-config-manager/*.yaml. Photon OS server generates network-config-manager configuration file for system-networkd named 01-dhcp.yaml.
Now let’s move towards network configuration. Follow the steps below to configure static or dynamic IP addressing in Photon OS:
- First find the name of the active network interfaces that you want to configure. To do so run the following command:
❯ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:5f:d1:39 brd ff:ff:ff:ff:ff:ff
altname enp2s1
inet 192.168.1.4/24 metric 1024 brd 192.168.1.255 scope global dynamic ens33
valid_lft 82465sec preferred_lft 82465sec
inet6 fe80::20c:29ff:fe5f:d139/64 scope link
valid_lft forever preferred_lft forever
Note the interface name that you want to configure using network-config-manager.
- The network-config-manager default configuration file is under the directory /etc/network-config-manager. You can find that using the following command:
❯ ls /etc/network-config-manager/
- To view the content of network-config-manager network configuration file, run the following command:
❯ cat /etc/network-config-manager/*.yaml
- Now you will need to open the configuration file in any editor: As I am using Nano editor to edit the configuration file, so I will run:
❯ sudo vim /etc/network-config-manager/01-network.yaml
- Update the configuration file as per your networking needs. For static IP addressing, add the IP address, Gateway, DNS information while for dynamic IP addressing, there is no need to add this information as it will get this information from DHCP server. Use the following syntax to edit the configuration file.
network:
Version: 2
Renderer: networkd
ethernets:
DEVICE_NAME:
dhcp4: yes/no
nameservers:
addresses: [NAMESERVER_1, NAMESERVER_2]
addresses: [IP_ADDRESS/NETMASK]
routes:
- to: destination
via: gateway
Where
DEVICE_NAME: Name of the interface. dhcp4: yes or no depending upon dynamic or static IP addressing Addresses: IP address of the device in prefix notation. Do not use netmask. routes: to: destination via: gateway IP address to connect to an outside network nameservers: Address of DNS name servers
Note that YAML files are rather strict in the indentation. Make use of spaces for indentation, not tabs. Otherwise, you will encounter an error.
To manually configure an IP address, use the above configuration file syntax and add the IP address, Gateway, and DNS server information. Here you can see my configuration file for static IP addressing:
network:
ethernets:
eth0:
dhcp4: false
addresses: [192.168.1.202/24]
nameservers:
addresses: [8.8.8.8,8.8.4.4,192.168.1.1]
routes:
- to: 172.16.0.0/24
via: 192.168.1.100
To obtain IP addressing from the DHCP server, use the same above configuration file syntax. But do not add the IP address, Gateway, and DNS server information.
Here you can see my configuration file for dynamic IP addressing:
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: true
Apply configuration Now apply the new configurations by running the following command as sudo:
$ sudo nmctl apply
Verify IP address Now to verify if the new configurations are successfully applied, run the following command to verify the IP address:
❯ nmctl status eth0
Flags: UP BROADCAST RUNNING NOARP LOWERUP
Kind: dummy
Type: ether
Driver: dummy
Link File: /usr/lib/systemd/network/99-default.link
Network File: /etc/systemd/network/10-test99.network
State: routable (configured)
Address State: routable
IPv4 Address State: routable
IPv6 Address State: degraded
Online State: online
Required for Online: yes
Activation Policy: up
HW Address: 56:d3:b9:4f:03:38 ((null))
MTU: 1500 (min: 0 max: 0)
QDISC: noqueue
Queues (Tx/Rx): 1/1
Tx Queue Length: 1000
IPv6 Address Generation Mode: eui64
GSO Max Size: 65536 GSO Max Segments: 65535
Address: fe80::54d3:b9ff:fe4f:338/64
192.168.1.202/24
DNS: 8.8.4.4 192.168.1.1 8.8.8.8
DHCP6 Client DUID: DUID-EN/Vendor:0000ab11d258482fc7eee651000
See routes
❯ ip r show dev eth0
172.16.0.0/24 via 192.168.1.100 proto static