Linux: How to setup Static IP for Ubuntu Server on the cmd interface

Overview

The interface shows how to configure static IP for Ubuntu Server on the command line interface, not on Ubuntu Server with the user interface

Here, I configure it on Ubuntu Server 18.04

This configuration can be used for Ubuntu Server version 17.10 and above

How to configure

  • Check the name of network card with the command

# networkctl status

  • We use vi, vim or nano editor to edit the file /etc/netplan/50-cloud-init.yaml
  • To set static IP, we modify the file as with the following parameters
    • 172.16.31.15/24 is static ip of server
    • 172.16.31.1 is ip default gateway of server
    • 8.8.8.8, 8.8.4.4 is ip DNS of server
  • We use one of the following commands to save the new configuration

# sudo netplan apply

# sudo systemctl restart NetworkManager.service

# sudo service network-manager restart

  • We use the command below to check configure

# ip a

  • To back dynamic IP, we just need to edit the file /etc/netplan/50-loud-init.yaml back to the original

Be the first to comment

Leave a Reply

Your email address will not be published.


*


This site uses Akismet to reduce spam. Learn how your comment data is processed.