Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions labs/network-bond-misconfig/cloud-init.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#cloud-config
runcmd:
- |
# Load dummy module and create an interface named 'ens4'
modprobe dummy || true
ip link add ens4 type dummy || true
ip link set ens4 up

# Create a Netplan config that refers to 'eth1' instead of 'ens4'
cat <<EOF > /etc/netplan/60-internal-nic.yaml
network:
version: 2
renderer: networkd
ethernets:
eth1:
dhcp4: false
addresses: [10.10.10.10/24]
EOF

# Try to apply (it will likely complain about missing eth1)
netplan apply || true
24 changes: 24 additions & 0 deletions labs/network-bond-misconfig/lab.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
id: network-interface-name-mismatch
name: Network Interface Name Mismatch
category: networking
difficulty: intermediate
vm:
name: nic-name-lab
image: ubuntu-24.04-base.qcow2
memory: 1024
cpu: 1
disk: 10G
cloud_init: cloud-init.yaml
verify_script: verify.sh

description:
summary: "The second network interface is down because the configuration refers to a non-existent device name."
story: "This server was recently migrated to a new hypervisor. While the primary interface works, the secondary interface (intended for internal traffic) is down. It seems the configuration is looking for 'eth1', but the system has named the hardware differently. You need to find the correct device name and update the configuration."
objectives:
- Identify the available network interfaces and their states
- Locate the incorrect interface name in the Netplan configuration
- Update the configuration to use the correct device name and bring the interface up
tags:
- networking
- linux
- netplan
11 changes: 11 additions & 0 deletions labs/network-bond-misconfig/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
### Scenario
This server was recently migrated to a new virtual environment. While the primary network interface is working fine, the secondary interface, which is supposed to be used for internal database traffic, is not coming up. The previous admin left a Netplan configuration that they claimed should work.

### Objective
Diagnose why the secondary network interface is down, identify any naming mismatches in the configuration, and restore connectivity on the correct interface with the assigned IP `10.10.10.10`.

### Useful Commands
- `ip addr`
- `ip link show`
- `cat /etc/netplan/60-internal-nic.yaml`
- `sudo netplan apply`
45 changes: 45 additions & 0 deletions labs/network-bond-misconfig/solution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
### The Issue
Modern Linux distributions (especially those using `systemd-networkd` or `Predictable Network Interface Names`) often name network interfaces based on their hardware location (e.g., `ens3`, `enp0s3`) rather than simple indices like `eth0`, `eth1`.

In this case, the Netplan configuration was attempting to configure an interface named `eth1`, but the actual hardware was detected and named `ens4` by the operating system. Because of this mismatch, Netplan could not apply the settings to the correct device, leaving the secondary interface unconfigured.

### Step-by-Step Fix

1. **List all network interfaces**:
```bash
ip addr show
```
OR
```bash
ip link show
```
Identify an interface that is `DOWN` or doesn't have an IP, likely named `ens4`.

2. **Inspect the Netplan configuration**:
```bash
cat /etc/netplan/60-internal-nic.yaml
```
Notice that the configuration block is under `eth1:`.

3. **Correct the interface name**:
Edit the file and change `eth1` to `ens4`.
```yaml
network:
version: 2
renderer: networkd
ethernets:
ens4:
dhcp4: false
addresses: [10.10.10.10/24]
```

4. **Apply the configuration**:
```bash
sudo netplan apply
```

5. **Verify the fix**:
Check if `ens4` now has the correct IP address.
```bash
ip addr show ens4
```
7 changes: 7 additions & 0 deletions labs/network-bond-misconfig/solution.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# Update Netplan configuration to use ens4 instead of eth1
sed -i 's/eth1:/ens4:/' /etc/netplan/60-internal-nic.yaml

# Apply the new configuration
netplan apply
16 changes: 16 additions & 0 deletions labs/network-bond-misconfig/verify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# Check if ens4 exists and has the correct IP
if ip addr show ens4 2>/dev/null | grep -q "10.10.10.10"; then
# Also verify it's in Netplan and eth1 is gone
if grep -q "ens4:" /etc/netplan/60-internal-nic.yaml && ! grep -q "eth1:" /etc/netplan/60-internal-nic.yaml; then
echo "SUCCESS: Secondary interface is correctly configured and up."
exit 0
else
echo "FAILURE: Netplan configuration still refers to eth1 or doesn't have ens4."
exit 1
fi
else
echo "FAILURE: ens4 does not have the expected IP address 10.10.10.10."
exit 1
fi
Loading