Post

Ubuntu Server Network Setup - Netplan & SSH Configuration

Ubuntu Server Network Setup - Netplan & SSH Configuration

This guide covers how to configure network interfaces using Netplan on Ubuntu Server. Ubuntu manages networks using YAML-based configuration files located in /etc/netplan/.

Prerequisites

  • Root/Sudo Privileges required
  • Text editor such as nano or vim

YAML is sensitive to indentation. You must use spaces (2 or 4 spaces) and DO NOT use tab.


1. Check Network Interface

Before configuration, identify the physical network interface name (e.g., eth0, enp3s0).

Note: Ubuntu Network Configuration Official Documentation

List Interfaces

1
ip a

Output Example:

1
2
3
4
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 ...
    inet 127.0.0.1/8 scope host lo
2: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 ...
    inet 10.102.66.200/24 brd 10.102.66.255 scope global dynamic eth0

Netplan Configuration File

Managed via 00-installer-config.yaml file in the /etc/netplan/ directory.

1
2
3
4
5
6
7
8
9
network:
  version: 2
  renderer: networkd
  ethernets:
    eth_lan0:
      dhcp4: true
      match:
        macaddress: 00:11:22:33:44:55
      set-name: eth_lan0

IP Address Configuration

Sudo privileges are required to the network settings.

DHCP Configuration (Automatic IP Assignment)

1
2
3
4
5
6
network:
  version: 2
  renderer: networkd
  ethernets:
    enp3s0:
      dhcp4: true

Static IP Configuration (Fixed IP)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: no
      addresses:
        - 10.x.x.x/24
      # 'gateway4' is deprecated. Use 'routes' instead:
      routes:
        - to: default
          via: 10.x.x.x
      nameservers:
        search: [mydomain, otherdomain]
        addresses: [10.x.x.x, 1.1.1.1]

Apply Changes

1
sudo netplan apply

You MUST execute netplan apply after modifying the configuration file for changes to take effect.


2. SSH Service Configuration

SSH (Secure Shell) is a protocol for safely transmitting commands over an unsecured network. SSH uses encryption to authenticate and encrypt connections between devices.

Tip: Cloudflare - SSH란?

Edit SSH Cofiguration File

1
sudo nano /etc/ssh/sshd_config

Change Port

You can change the default port (22) to a different port:

1
Port {####}

Apply Changes

1
sudo systemctl restart ssh
This post is licensed under CC BY 4.0 by the author.