Bobcares

For every $500 you spend, we will provide you with a $500 credit on your account*

BLACK FRIDAY SPECIAL

*The maximum is $4000 in credits, Offer valid till November 30th, 2024, New Customers Only, Credit will be applied after purchase and expires after six (6) months

For every $500 you spend, we will provide you with a $500 credit on your account*

BLACK FRIDAY SPECIAL

*The maximum is $4000 in credits, Offer valid till November 30th, 2024, New Customers Only, Credit will be applied after purchase and expires after six (6) months

How to set up static IP on Ubuntu configuration via Netplan

by | Nov 28, 2024

Learn how to set up static IP on Ubuntu configuration via Netplan. Our Server Management Support team is here to help you with your questions and concerns.

How to set up static IP on Ubuntu configuration via Netplan

How to set up static IP on Ubuntu configuration via NetplanDid you know that Netplan simplifies network configuration using YAML-based syntax?

It makes it easy to set up and modify network settings. Additionally, it lets us manage network interfaces through networkd (primarily for servers) or NetworkManager (for GUI-based systems).

Today, we are going to take a close look at Netplan’s structure and how to configure a static IP address on Ubuntu.

An Overview:

Understanding Netplan Configuration

Netplan’s configuration files are located in /etc/netplan/ and typically include:

  • 01-netcfg.yaml
  • 01-network-manager-all.yaml
  • 50-cloud-init.yaml

The default renderer for Netplan is specified as networkd or NetworkManager, depending on our Ubuntu setup. To confirm or generate a new Netplan configuration file:

sudo netplan generate

How to Choose Between DHCP and Static IP Address

Netplan lets us configure:

  • DHCP: Automatically assigns an IP address from the router.
  • Static IP: Manually assigns a fixed IP address to ensure consistent connectivity.

Benefits of Configuring a Static IP Address

Configuring a static IP address offers several advantages, especially in environments that require consistent network communication:

  • A static IP ensures that the device retains the same IP address, making it easier to locate within the network.
  • Systems with static IPs can be accessed more reliably for remote administration or SSH connections.
  • Static IPs let us set up custom DNS entries, streamlining name resolution in the network.
  • Dynamic IP addresses can lead to reassignment issues; static IPs eliminate this risk, ensuring uninterrupted network services.
  • Servers hosting websites, databases, or other critical applications benefit from a stable IP for consistent client connections.
  • Static IP addressing is particularly useful in enterprise setups, IoT deployments, and when integrating firewalls or VPNs that rely on consistent IPs for authentication.

Configuring a Static IP Address with Netplan

 

  1. First, identify the Netplan configuration file with this command:

    ls /etc/netplan/

  2. Then, open the configurations file:

    sudo nano /etc/netplan/CONFIGFILENAME

  3. Next, update the configuration file to include the following changes:
    • Disable DHCP:

      dhcp4: no

    • Assign a Static IP:

      addresses: [192.168.0.123/24]

      Replace 192.168.0.123 with the desired IP.

    • Set the Gateway:

      gateway4: 192.168.1.1

    • Define DNS Servers:

      nameservers:
      addresses: [1.1.1.1, 8.8.8.8]
      Example configuration:
      network:
      version: 2
      renderer: networkd
      ethernets:
      enp0s3:
      dhcp4: no
      addresses: [192.168.0.123/24]
      gateway4: 192.168.1.1
      nameservers:
      addresses: [1.1.1.1, 8.8.8.8]

After saving the changes, we can apply the new configuration with this command:

sudo netplan apply

In case the changes don’t take effect, reboot the system:

sudo reboot

Troubleshooting Common Issues

 

  • Ensure the router allows the specified static IP.
  • Check for typos or indentation issues in the YAML file.
  • Revert to DHCP by resetting “dhcp4: yes” in the configuration file and reapplying changes.

How to Automate Static IP Configuration for Multiple Systems

Managing static IP addresses across multiple systems can be simplified with automation:

  • Tools like Ansible, Puppet, or Chef can deploy static IP configurations to multiple devices with minimal effort.
  • Create reusable Netplan YAML templates that define static IP settings and apply them to multiple systems.
  • Write scripts to automate file generation and apply configurations using netplan apply on each target machine.
  • Automate both system installation and static IP configuration during the boot process using pre-seeded scripts.
  • Store Netplan configurations in version control systems (e.g., Git) to ensure consistency and rollback options.

[Need assistance with a different issue? Our team is available 24/7.]

Conclusion

Netplan’s YAML-based syntax simplifies static IP configuration on Ubuntu. By following these steps, we can set a static IP address to ensure consistent network connectivity. With its flexibility and integration with modern Ubuntu systems, Netplan is a powerful tool for network management.

In brief, our Support Experts demonstrated how to set up static IP on Ubuntu configuration via Netplan

0 Comments

Submit a Comment

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

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF