
How to Change Networking in Flatcar
Discover how to customize your networking setup in Flatcar Linux, including connecting to machines with static IP addresses, and enabling or disabling DHCP.

By default, Flatcar Linux fetches the IP via DHCP from the first ethernet port it encounters. Nevertheless, there are scenarios where network configurations may need customization, such as when establishing connections with machines using static IP addresses. This guide demonstrates how to create your own networkd units for such customizations.
Instructions
If you're not using a pre-configured instance, it's possible to modify networking settings post-installation. Here are the steps:
- Locate your networkd units: Networkd units are typically found in the
/etc/systemd/network/
directory. If you manually place files onto the filesystem, you'll need to reload networkd using the commandsudo systemctl restart systemd-networkd
. - Create a static.network file: This file will be used to set up a static IP on
enp2s0
. Create thestatic.network
file and place it in the/etc/systemd/network/
directory. - Apply the configuration: Once the file is correctly placed, apply the configuration by running the command
sudo systemctl restart systemd-networkd
.
The following YAML file provides an example configuration. This configuration fetches the IP via DHCP in the 192.168.1.0/24 range from the first port (in file 10-enp6s0.network
), sets up a second network in the 172.16.42.1/24 range with a DHCP server and static leases (in file 20-enp8s0.network
), and on one port, allows connection to a network consisting of a single machine at 192.168.1.150/32 (thereby creating a DMZ around that machine, file 30-enp7s0.network
).
- name: 10-enp6s0.network
contents: |
[Match]
Name=enp6s0
[Network]
Description=Port 1 / WAN
DHCP=ipv4
[Route]
Destination=192.168.1.0/24
Scope=link
# for testing only
# DHCP=ipv4
- name: 20-enp8s0.network
contents: |
[Match]
Name=enp8s0
[Network]
Description=Port 2 / LAN. Yes it is Port 2 and not port 3. The numbering is weird in the K300.
Address=172.16.42.1/24
DHCPServer=true
IPMasquerade=ipv4
[DHCPServer]
PoolOffset=100
PoolSize=100
EmitDNS=yes
EmitNTP=yes
# The "[DHCPServerStaticLease]" section configures a static DHCP lease to assign a fixed IPv4 address to a specific device based on its MAC address.
# This section can be specified multiple times.
[DHCPServerStaticLease]
MACAddress=00:30:de:40:f9:02
Address=172.16.42.13
- name: 30-enp7s0.network
contents: |
[Match]
Name=enp7s0
[Network]
Description=Port 3 / PLC. Yes it is Port 3 and not port 2. The numbering is weird in the K300.
Address=192.168.1.149/30
DHCPServer=false
IPMasquerade=ipv4
[Route]
Destination=192.168.1.150/32
Scope=link
For more detailed instructions and additional functionality of networkd, visit the official documentation. With these steps, you should be able to successfully configure your Flatcar Linux machine to use different networking. Remember to always double-check your configuration and test your connection to ensure everything is working as expected.