Learning and Sharing
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
No Result
View All Result

How to Configure a Static IP for an Ubuntu Server VM in VMware

October 27, 2022
in Blog, Linux, VMware
0
ADVERTISEMENT

Table of Contents

Typically, in most network configurations, the IP address is assigned dynamically by the router DHCP server. Setting a static IP address may be required in different situations, such as configuring port forwarding or running a web server behind a NAT.

This post explains how to set up a static IP address on Ubuntu Server 20.04.

Netplan

Ubuntu 17.10 and later uses Netplan as the default network management tool. The previous Ubuntu versions were using ifconfig and its configuration file /etc/network/interfaces to configure the network.

Netplan configuration files are written in YAML syntax with a .yaml file extension. To configure a network interface with Netplan, you need to create a YAML description for the interface, and Netplan will generate the required configuration files for the chosen renderer tool.

Netplan supports two renderers, NetworkManager and Systemd-networkd. 

NetworkManager is mostly used on Ubuntu Desktop machines, while the Systemd-networkd is used on servers without a GUI.

Configuring Static IP address on Ubuntu 20 Server

On Ubuntu Server 20.04, the system identifies network interfaces using predictable network interface names.

1. The first step toward setting up a static IP address is identifying the name of the ethernet interface you want to configure. To do so, use the command, as shown below:
ip link

The command prints a list of all the available network interfaces. In this example, the name of the interface is ens33.

# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state ...
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc...

2. Netplan configuration files are stored in the /etc/netplan directory. You’ll probably find one or more yaml files in this directory. The name of the file may differ from setup to setup. Usually, the file is named either 01-netcfg.yaml, 50-cloud-init.yaml, or nn_interfacename.yaml, but in your system it may be different.

# ls /etc/netplan
00-installer-config.yaml

3. To assign a static IP address on the network interface, open the yaml configuration file with your text editor.

sudo nano /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
  ethernets:
    ens33:
      dhcp4: true
  version: 2

4. To assign a static IP address to ens33 interface, edit the file as follows:

Note When editing yaml files, make sure you follow the yaml code indent standards. If the syntax is not correct, the changes will not be applied.
  • Set DHCP to dhcp4: no.
  • Specify the static IP address. Under addresses: you can add one or more IPv4 or IPv6 IP addresses that will be assigned to the network interface.
  • Specify the gateway4.
  • Under nameservers, set the IP addresses of the nameservers.
# This is the network config written by 'subiquity'
network:
  version: 2
  renderer: networkd
  ethernets:
    ens33:
      dhcp4: no
      addresses:
        - 192.168.0.10/24
      gateway4: 192.168.0.1
      nameservers:
          addresses: [8.8.8.8, 1.1.1.1]

5. Once done, save the file and apply the changes by running the following command:

sudo netplan apply

6. Verify the changes by typing:

ifconfig
# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.10  netmask 255.255.255.0  broadcast 192.168.255.255
        inet6 fe80::20c:29ff:fe47:751e  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:47:75:1e  txqueuelen 1000  (Ethernet)
        RX packets 51777  bytes 62997759 (62.9 MB)
        RX errors 0  dropped 22  overruns 0  frame 0
        TX packets 4511  bytes 359631 (359.6 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

That’s it! You have assigned a static IP to your Ubuntu server.

ADVERTISEMENT
5/5 - (1 vote)
Previous Post

How to Download and Install PHP 7.4 on Ubuntu 20.04 LTS

Next Post

Script: How to Install LEMP & WordPress on Ubuntu 20.04 LTS

Related Posts

Running Hyper-V and VMware Workstation on The Same Machine

August 15, 2024

How to Uninstall All Autodesk Products At Once Silently

July 29, 2024
Ftr5

How to Uninstall the Autodesk Genuine Service on Windows

July 29, 2024
Ftr19

How to Fix Windows Cannot Read the ProductKey From the Unattend Answer File in VirtualBox

July 26, 2024
Ftr25

How to Update Windows Terminal in Windows 10/11

July 26, 2024

How to Disable The Beep Sound in WSL Terminal on Windows

July 26, 2024

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How To Turn On uBlock Origin Extension in Chrome (2025)
  • Images Hidden Due To Mature Content Settings In CivitAI
  • Azure OpenAI vs Azure AI Hub, How to Choose the Right One for Your Needs

Categories

Stay in Touch

Discord Server

Join the Discord server with the site members for all questions and discussions.

Telegram Community

Jump in Telegram server. Ask questions and discuss everything with the site members.

Youtube Channel

Watch more videos, learning and sharing with Leo ❤❤❤. Sharing to be better.

Newsletter

Join the movement and receive our weekly Tech related newsletter. It’s Free.

General

Microsoft Windows

Microsoft Office

VMware

VirtualBox

Technology

PowerShell

Microsoft 365

Microsoft Teams

Email Servers

Copyright 2025 © All rights Reserved. Design by Leo with ❤

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory