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


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
    • is static ip of server
    • is ip default gateway of server
    •, 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.