Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

How to setup a static IP on Ubuntu Server 18.04

I've seen some people saying the file to set static ip is still /etc/network/interfaces

And I've seen other people saying that in 18.04 it's now on /etc/netplan (which people seem unhappy about)

I've tried putting this:

In my /etc/netplan/50-cloud-init.yaml and doing sudo netplan apply but that just kills the servers connection to the internet.

Pablo Bianchi's user avatar

  • 1 Is it a desktop or a server? –  user68186 Apr 29, 2018 at 5:10
  • 1 Is this a fresh 18.04 install or upgrade from another version? –  WinEunuuchs2Unix Apr 29, 2018 at 5:16
  • Sorry I should've said this in the text, its a fresh install of 18.04 server. –  final20 Apr 29, 2018 at 5:25
  • The most simple solution for me was, to specify a static IPv4 address right during installation (together with subnet, gateway, etc.). Simply fill out some wizard fields, no messing with configuration files. –  Uwe Keim Oct 9, 2018 at 10:01
  • You can also do this on routers. Steps are self-explanatory in the router config. –  EODCraft Staff Jan 12, 2019 at 10:25

11 Answers 11

All the answers telling you to directly edit /etc/netplan/50-cloud-init.yaml are wrong since CloudInit is used and will generate that file. In Ubuntu 18.04.2 it is clearly written inside the file :

So you should not edit that file but the one under /etc/cloud/cloud.cfg.d/ if you still want to use CloudInit.

Another way is to completely disable CloudInit first by creating an empty file /etc/cloud/cloud-init.disabled (see https://cloudinit.readthedocs.io/en/latest/topics/boot.html ) and then the other answers are OK. Under Ubuntu 18.04.2 I had to use dpkg-reconfigure cloud-init to let it take into account the file /etc/cloud/cloud-init.disabled . I think this is a little bit weird.

I suggest you to rename the file (not the right name since 50-cloud-init.yaml let us think it still uses CloudInit).

Then you may end up with a file name /etc/netplan/01-netcfg.yaml which contains the configuration below. Note the use of the networkd renderer instead of NetworkManager because the configuration is on a server.

Ludovic Kuty's user avatar

  • 4 It works great. This should be the best answer. 50-cloud-init.yaml as stated shouldn't be modified. –  Relic Jun 26, 2019 at 13:11
  • 3 If still using CloudInit, you need to do a sudo cloud-init clean -r to get the change to take, as per veperr's answer (at least for me on Ubuntu Server 18.04.3). –  Stuart Rossiter Aug 8, 2019 at 11:59
  • 1 ...plus the renderer line is no longer valid it seems (and is missing in the base version of the file that you edit). –  Stuart Rossiter Aug 27, 2019 at 10:26
  • Simply adding a custom file under /etc/netplan/##-*.yaml works as well. Such as: "/etc/netplan/99-custom-network.yaml". This also follows the netplan.io/examples instructions. In "conf.d" type config areas you should always opt for a custom/new file if possible instead of editing installed package files. It's why we have these "numbered file" areas. These default #'ed files can frequently get overwritten. And YES: If you have a "50-cloud-init.yaml", it should NOT be used. It is system generated as noted in comments. Why people keep posting this as an answer is anyone's guess? –  B. Shea Dec 13, 2021 at 15:59
  • 1 Yep. But, you can add it directly to /etc/netplan . Any new files under this area will persist through reboots. I gave you +1 for 1: saying not to edit cloud-init, and 2: Creating a new file in a numbered area (& not editing ANY preexisting/system ones). Note: You do not even necessarily need to disable anything so long as you are updating the same network interface. A higher numbered yaml will override all previous repeated directives (or should). So "50-" will be read in AFTER "01-". If you renamed your file "99-" you wouldn't have to disable "50-" - if that makes sense. See my answer –  B. Shea Dec 13, 2021 at 16:34

This is set a static IP instruction in Ubuntu-Server 18.04 and 20.04

Then replace your configuration, for example, the following lines:, apply changes:.

In case you run into some issues execute:

  • /24 is equivalent with 255.255.255.0
  • ens160 is your ethernet name, you can get it using $ ifconfig
  • Ubuntu 16.04 and 14.04 network-interface configuration have a different method.
  • The file is in YAML format : Use spaces, no tabs.

Benyamin Jafari's user avatar

  • not able to ping after assigning static IP address –  gjois Mar 3, 2019 at 14:55
  • OK....I'm able to ping after doing service networking restart –  gjois Mar 3, 2019 at 15:42
  • 7 I wouldn't do that since that file is generated by CloudInit –  Ludovic Kuty Mar 13, 2019 at 7:48
  • only works if your ethernet is "ens160", check your ethernet "ls /sys/class/net/" and replace "ens160" with it. –  sailfish009 Mar 17, 2020 at 3:40
  • @sailfish009 I mentioned it before in the NOTE section in my answer. –  Benyamin Jafari Mar 17, 2020 at 6:11

I've found another way using cloud-init.

  • Edit the file /etc/cloud/cloud.cfg.d/50-curtin-networking.cfg - the contents seem to be the same as they would be in /etc/netplan.

clean, reboot and re-initialize cloud-init with this command:

That's it! Your system will reboot, cloud-init will re-initialize and pickup the change in /etc/cloud/cloud.cfg.d/50-curtin-networking.cfg and apply them to /etc/netplan/50-cloud-init.yaml and all will be well. Verify with ifconfig .

zx485's user avatar

  • 1 2 things. -> 1. Better to create your own "99-myconfig.cfg" file under /etc/cloud/cloud.cfg.d/ so it's read in last and will overwrite any previous configs and will not be overwritten by possible system updates. 2. ifconfig is defunct . Use ip command now. For example ip addr will show same thing as ifconfig use to. –  B. Shea Dec 7, 2021 at 16:11

Ubuntu 18.04 uses now Netplan to configure the network interfaces, so the configuration must be done in the file /etc/netplan/50-cloud-init.yaml , the documentation advises not to mess anymore with the old file /etc/network/interfaces . I have used this configuration with my Ubuntu Server virtual machine and it works so far, just make sure the info is correct; the optional: true setting supposedly speeds up the booting time by not verifying if the interface is connected or not, this is default, also there is no need to declare values not used, for example DHCP, if they are absent they are taken as disabled, also the default renderer in Ubuntu Server is networkd so there is no need to declare it. Taking the information from your post, it should be like this:

Once you save the file, run sudo netplan --debug apply the debug flag will output more info and can help to detect any errors. Check the ethernet cable, if in virtual review the VM configuration. If using a WLAN I have read that it is a bit more tricky to setup but I haven't yet set up a machine connected to WiFi with this server version.

If you want more info about Netplan there is a website, it has some basic configuration examples.

https://netplan.io/

badger_8007's user avatar

  • 1 Wrong. DO NOT EDIT 50-cloud-init.yaml , or any existing system generated files! –  B. Shea Dec 13, 2021 at 16:40

Config file is in YAML format : Don't use TAB when configuring the file. It only works with SPACE .

HubbleT's user avatar

Writing a new answer as so many are just wrong.

Do not edit 50-cloud-init.yaml , 00-installer-config.yaml or ANY system generated files/package files.

From https://netplan.io/examples/ :

"To configure netplan, save configuration files under /etc/netplan/ with a .yaml extension (e.g. /etc/netplan/config.yaml) .."

The installer/ system did that. Now you need to override it.

Also consult man netplan-generate for the rules governing how the network configurations are read from /etc/netplan/*.yaml (and elsewhere).

To correctly update the netplan area to use a static IP over the default DHCP:

Edit/Create a new file (the prepended number+dash and .yaml extension are important):

sudo nano /etc/netplan/99-custom-network.yaml

Add your properly formatted YAML to this file. A static IP example:

(Note: My network device is ens160 - not eth0 - adjust as needed.) Save. Then do a sudo netplan apply . Make sure your network interface looks right and is working ( ip ad / ping ). Then do a reboot. Retest.

This follows the netplan.io instructions as well as the general rule of not editing any existing/installed files when possible. In /etc/netplan/ and similar conf.d/ type config areas you should always opt for a high numbered custom/new file (if possible) instead of editing any installed package files.

It's why they have numbered files in these configuration areas (in /etc/netplan/ and others). The higher the number on the file equates to when it is read in.

Therefore, something with "99-" prepended on it will generally be read in last and OVERRIDE anything that repeated before it. Therefore, if a network interface is set to DHCP in "00-installer-config.yaml", and/or "50-cloud.init.yaml", the settings for the same interface in a "99-*.yaml" file will override everything else read in previously.

Generally these installed YAML files will NOT get overwritten, but that isn't valid logic to not follow the conf.d "standard" of using custom files to override and avoid editing any installed files. It doesn't take any extra time. Drop a file in netplan. Done. So, there's no excuse as I have witnessed in comments of "well, it's worked so far..".

So, editing the default netplan *.yaml(s) will technically (usually) "work", but you should avoid using them when possible.

B. Shea's user avatar

Network configuration in 18.04 is managed via netplan and configured with cloud-init. To change your network configuration edit the 50-curtin-networking.cfg file in /etc/cloud/cloud.cfg.d/ . If this file does not exist then create it.

Find your interface name

Edit / create the cloud-init network configuration file

To set a static IP address, use the addresses key, which takes a list of (IPv4 or IPv6), addresses along with the subnet prefix length (e.g. /24). Gateway and DNS information can be provided as well:

You can find more configuration options at https://netplan.io/examples

Reload the cloud-init configuration. This will reboot your server.

Ryan's user avatar

This is the setting what make it work.

restart the server

change eth0 to your adapter, find out your adapter using ifconfig.

Digerate's user avatar

  • 1 Wrong. DO NOT EDIT 50-cloud-init.yaml, or any existing system generated files! –  B. Shea Dec 13, 2021 at 16:41

To find available ethernet interfaces use ip link show

Then edit the 50-cloud-init.yaml file using $sudo nano /etc/netplan/50-cloud-init.yaml

Add the configuration for available interfaces like eth0: and eth1:

Then use command $sudo netplan apply to apply the changes.

Anand Prakash Singh's user avatar

Then edit the 50-cloud-init.yaml file using $sudo vim /etc/netplan/50-cloud-init.yaml

$ sudo netplan apply

Community's user avatar

  • 1 I wouldn't do that since that file is generated by CloudInit. –  Ludovic Kuty Mar 13, 2019 at 7:47
  • 1 Why oh why is every guide to setting a static IP on 18.04 telling me to edit a yaml file that says it is a dynamically created file that will not persist? Another cruel joke from the Ubuntu developers that think it is ok to just break things by default... –  Bigtexun Mar 20, 2019 at 18:13
  • 1 Wrong. DO NOT EDIT 50-cloud-init.yaml, or any existing system generated files! –  B. Shea Dec 13, 2021 at 16:42
  • @B.Shea I have 20+ servers running for 4 years with regular upgrades and maintenance. Never once, 50-cloud-init.yaml has been reset or overwritten. For what I have noticed, cloud-init (as the name says) is run once, at server creation and then it won't be automatically reissued again. –  Dario Fumagalli Mar 2, 2022 at 3:34
  • 1 @DarioFumagalli Only 4 years? You're using broken logic: Just because nothing "broke" doesn't mean you are doing it the proper way. You should NEVER edit system installed config files if there is a way to avoid it. And there is clearly a way to avoid it in this case.. –  B. Shea Mar 2, 2022 at 13:07

This worked for me:

[172.23.4.2/24, ] is the additional thing I did on the yaml file.

Reference: https://serverspace.io/support/help/how-to-configure-static-ip-address-on-ubuntu-18-04/

BeastOfCaerbannog's user avatar

You must log in to answer this question.

Not the answer you're looking for browse other questions tagged networking server ip 18.04 ..

  • The Overflow Blog
  • Exploring the inclusive tech revolution sponsored post
  • Would you trust an AI bot to find the fix for vulnerabilities in your code?
  • Featured on Meta
  • Site maintenance - Saturday, February 24th, 2024, 14:00 - 22:00 UTC (9 AM - 5...
  • Upcoming privacy updates: removal of the Activity data section and Google...

Hot Network Questions

  • Assign a different color to each face using geometry nodes
  • When was Doctor Who first broadcast in the USA?
  • Spot The Difference
  • QGIS functions: aggregate and array_foreach not working for vertices
  • On a tinted (reflective) window, why do I need to look from up close to see inside?
  • Are there any good-aligned Sexuality-related Outsiders that aren't arshea?
  • How to create an alphanumerical Hash string with fixed length?
  • High School Combinatorics - I do not agree with the provided explanation
  • What is the better rendering of colossians 2: 14?
  • Were Mr. Darcy and Mr. Bennet formally equal in rank?
  • DIY system for charging battery packs from hub dynamo
  • Silverback Bottom Bracket Replacement
  • Ambiguity of personal pronouns
  • What is causing this impossibly long return time in AC Brotherhood on the PS3?
  • How do water controlling spells work on water in pipes?
  • Can I stack optocouplers in series to make a higher specification part?
  • Proof by contradiction, that a set of all binary sequences, where "1" cant be twice in a row, is uncountable
  • Advisor's Move to Another University: Should I Identify as a Visiting Student or Visiting Researcher?
  • If making your own microcontroller board, what types of pins may be used as GPIO pins?
  • How can the ECtHR judgement on encryption be reconciled with the UK's Online Safety act?
  • How do I read the range of years with a slash?
  • Is it bad practice to cite online news articles in solely because it's not a "reputable" source (i.e journal articles or even books)?
  • Publishing two papers at the same time
  • Odd use(s) of "bauen"

configure static ip address ubuntu 18 04

TechRepublic

Account information.

configure static ip address ubuntu 18 04

Share with Your Friends

How to configure a static IP address in Ubuntu Server 18.04

Your email has been sent

Image of Jack Wallen

From the office of, “If it’s not broken don’t fix it” comes this: In Ubuntu Server , there’s a brand new method of setting IP addresses. Gone are the days of manually editing the flat text /etc/network/interfaces file. In its place is netplan. That’s right, Ubuntu fans, the method you’ve known for years is now a thing of the past. Instead of a very simple text file, Ubuntu Server requires editing a .yaml file (complete with proper adherence to correct code indent for each line of the block), in order to configure your IP addressing.

Before you panic, it’s not all that challenging. In fact, it’s really just a matter of understanding the layout of these .yaml files and how networking is now restarted. I’m going to show you just that, such that you can configure a static IP address in Ubuntu Server 18.04 as easily as you could in 16.04.

The new method

Open up a terminal window on your Ubuntu 18.04 server (or log in via secure shell). Change into the /etc/netplan directory with the command cd /etc/netplan . Issue the command ls and you should see a file named 50-cloud-init.yaml . If you don’t also see a file named 01-netcfg.yaml , create it with the command sudo touch 01-netcfg.yaml . Before we edit that file, we need to know the name of our networking interface. Issue the command ip a and you should see your system network interface listed by name ( Figure A ).

configure static ip address ubuntu 18 04

Now we’re going to create a new netplan configuration file. If you don’t see the 01-netcfg.yaml file, create one with the command sudo nano 01-netcfg.yaml . Our file is going to look like that which you see in Figure B .

configure static ip address ubuntu 18 04

What’s crucial about the layout of this file is not using the exact same spacing as my example, but that you’re consistent. If you’re not consistent with your indents, the file will not work. What you see in that sample file is all you need to configure that static IP address. Do notice, you aren’t setting the address is the same fashion as you did with Ubuntu 16.04. With the old method, you set IP address and netmask like so:

address = 192.168.1.206 netmask = 255.255.255.0

With netplan, these are set with a single line:

addresses : [192.168.1.206/24]

Restarting/testing networking

With the new method, you must restart networking using netplan. So once you’ve configured your interface, issue the command:

sudo netplan apply

The above command will restart networking and apply the new configuration. You shouldn’t see any output. If networking fails to function properly, you can issue the command:

sudo netplan --debug apply

The output of the command ( Figure C ) should give you some indication as to what’s going wrong.

configure static ip address ubuntu 18 04

That’s all there is to it

There ya go. That’s all there is to configuring a static IP address in Ubuntu Server 18.04. Remember, you’ll have to do this for each interface you have on your server. Make sure to name the files something like 01-netcfg.yaml and 02-netcfg-yaml. It’s not terribly difficult, once you’re used to not working with that old-school interfaces file.

Subscribe to the Developer Insider Newsletter

From the hottest programming languages to commentary on the Linux OS, get the developer and open source news and tips you need to know. Delivered Tuesdays and Thursdays

  • How to install Ubuntu Server 18.04
  • How to enable remote desktop connections in Ubuntu 18.04
  • How to enable an automatic purge of temp files in Ubuntu 18.04
  • How to connect Ubuntu 18.04 to your Google account
  • Ubuntu 18.04 LTS: The Linux for AI, clouds, and containers

Image of Jack Wallen

Create a TechRepublic Account

Get the web's best business technology news, tutorials, reviews, trends, and analysis—in your inbox. Let's start with the basics.

* - indicates required fields

Sign in to TechRepublic

Lost your password? Request a new password

Reset Password

Please enter your email adress. You will receive an email message with instructions on how to reset your password.

Check your email for a password reset link. If you didn't receive an email don't forgot to check your spam folder, otherwise contact support .

Welcome. Tell us a little bit about you.

This will help us provide you with customized content.

Want to receive more TechRepublic news?

You're all set.

Thanks for signing up! Keep an eye out for a confirmation email from our team. To ensure any newsletters you subscribed to hit your inbox, make sure to add [email protected] to your contacts list.

Tecmint: Linux Howtos, Tutorials & Guides

How to Configure Network Static IP Address in Ubuntu 18.04

Netplan is a new command-line network configuration utility introduced in Ubuntu 17.10 to manage and configure network settings easily in Ubuntu systems. It allows you to configure a network interface using YAML abstraction. It works in conjunction with the NetworkManager and systemd-networkd networking daemons (referred to as renderers , you can choose which one of these to use) as interfaces to the kernel.

It reads network configuration described in /etc/netplan/*.yaml and you can store configurations for all your network interfaces in these files.

In this article, we will explain how to configure a network static or dynamic IP address for a network interface in Ubuntu 18.04 using Netplan utility.

List All Active Network Interfaces on Ubuntu

First, you need to identify the network interface you are going to configure. You can list all attached network interfaces on your system using the ifconfig command as shown.

Check Network Interfaces in Ubuntu

From the output of the above command, we have 3 interfaces attached to the Ubuntu system: 2 ethernet interfaces and the loop back interface . However, the enp0s8 ethernet interface has not been configured and has no static IP address.

Set Static IP Address in Ubuntu 18.04

In this example, we will configure a static IP for the enp0s8 ethernet network interface. Open the netplan configuration file using your text editor as shown.

Important : In case a YAML file is not created by the distribution installer, you can generate the required configuration for the renderers with this command.

In addition, auto generated files may have different filenames on desktop, servers, cloud instantiations etc (for example 01-network-manager-all.yaml or 01-netcfg.yaml ), but all files under /etc/netplan/*.yaml will be read by netplan.

Then add the following configuration under the ethernet section.

  • dhcp4 and dhcp6 – dhcp properties of an interface for IPv4 and IPv6 receptively.
  • addresses – sequence of static addresses to the interface.
  • gateway4 – IPv4 address for default gateway.
  • nameservers – sequence of IP addresses for nameserver.

Once you have added, your configuration file should now have the following content, as shown in the following screenshot. The first interface enp0s3 is configured to use DHCP and enp0s8 will use a static IP address.

The addresses property of an interface expects a sequence entry for example [192.168.14.2/24, “2001:1::1/64”] or [192.168.56.110/24, ] (see netplan man page for more information).

Configure Static IP in Ubuntu

Save the file and exit. Then apply the recent network changes using following netplan command.

Now verify all the available network interfaces once more time, the enp0s8 ethernet interface should now be connected to the local network, and have an IP addresses as shown in the following screenshot.

Verify Network Interfaces in Ubuntu

Set Dynamic DHCP IP Address in Ubuntu

To configure the enp0s8 ethernet interface to receive an IP address dynamically through DHCP, simply use the following configuration.

Save the file and exit. Then apply the recent network changes and verify the IP address using following commands.

From now on your system will get an IP address dynamically from a router.

You can find more information and configuration options by consulting the netplan man page.

Congratulations! You’ve successfully configured a network static IP addresses to your Ubuntu servers. If you have any queries, share them with us via the comment form below.

Previous article:

Next article:

Photo of author

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Related Posts

Create eLearning with Moodle in Ubuntu

How to Create eLearning Platform with Moodle and ONLYOFFICE

Ubuntu Disk Space Cleaner

5 GUI Tools to Free Up Space on Debian, Ubuntu and Linux Mint

Install TFTP Server on Ubuntu

How to Install and Configure TFTP Server on Ubuntu and Debian

Fix Sub-process dpkg returned an error

How to Solve “Sub-process /usr/bin/dpkg returned an error code (1)” In Ubuntu

Fix Username is not in the sudoers file in Ubuntu

How to Fix “Username is not in the sudoers file. This incident will be reported” in Ubuntu

Run Linux from Hard Disk

How to Run Any Linux Distribution Directly from Hard Disk

26 thoughts on “How to Configure Network Static IP Address in Ubuntu 18.04”

There is a .yaml file for configuration. The syntax of it is horrible! I didn’t understand at all – HOW can I write wireless networks, WHERE, and HOW MUCH spices can be there.

yaml language is very structured. Notice that each indent is two spaces. In order to use your wireless network, you need to discover what the OS thinks the name of the device is. For most OSs, you can simply type: ip a – That should return a list of all available adapters in your system.

From there you have a working example from the article above. Just plug in your wireless device name instead of eth0. Also, you haven’t stated if your wireless is acting in AP mode or as a client. Good luck!

sudo apt update not working anymore.

Ubuntu loves play with us, its like when we was kids and played the touch and go :)

First it changes /etc/network/interfaces to /etc/netplan/50-cloud-init.yaml as you can see when do:

# ifupdown has been replaced by netplan(5) on this system. See # /etc/netplan for current configuration. # To re-enable ifupdown on this system, you can run: # sudo apt install ifupdown

Second it changes /etc/netplan/50-cloud-init.yaml to /etc/cloud/cloud.cfg.d/50-curtin-networking.cfg as you can see when do:

Then even after running [ cloud-init clean -r ] sometimes changes in /etc/cloud/cloud.cfg.d/50-curtin-networking.cfg arent applied

Thanks! you save my day! Really well explained

This is great! Many thanks for the feedback.

Hello I’m trying to set up my computer with GPU to be accessed from my laptop and from my friends laptop through putty, for this the solution i thought it would work was set up a static IP and open port 22 so that we can access the GPU machine through putty from other laptop.

After i set up the static IP my internet connection in Gpu machine is not working also i don’t have an idea how to proceed further in port forwarding .

1. My questions are is my solution to set up static IP and open port 22 will work for my above requirement. 2. Any suggestions to solve my internet connectivity issue.

@Dwarakanath,

First check your static IP is reachable from other laptop by doing a ping request to IP. Secondly, make sure the opened port 22 is listening on the system using netstat command .

@Ravi save thanks for replying ping from my laptop to connect my static ip machine gets timeout, I see that you ask me to check the port 22 is listening using netstat to make it more clear I am yet to open port 22 for which any help will be highly appreciated

Your static IP must be reachable from your laptop, and to open port 22 on ufw firewall, run:

I think you have a mistake with regards to what “ netplan generate ” does, you have a notice saying “Important: In case a YAML file is not created by the distribution installer, you can generate the required configuration for the renderers with this command.”, this is incorrect. On the man page ( http://manpages.ubuntu.com/manpages/cosmic/man8/netplan-generate.8.html ) it says “netplan-generate – generate backend configuration from netplan YAML files”

“netplan generate” *reads* the YAML files it can’t create the yaml file for you, ie it won’t touch any of the yaml files in the “ /etc/netplan/ ” directory.

I have noticed when I run “ netplan generate ” it creates the configuration files in “ /run/systemd/network/ ” on Ubuntu 18.04

The man page also says: “You will not normally need to run this directly as it is run by netplan apply, netplan try, or at boot.”

So I think you should remove the reference to “netplan generate ” as it’s just a red herring. If there is nothing in “ /etc/netplan ” then that command isn’t going to help you out.

Many thanks for the heads up, we will look into this.

Those linux devs who made this decision are absolutely bunch of very strong and bad words. You have no idea what did you do to a mindset of administrator who expect that nobody, really nobody mess with sys admin networking stuff.

Specially developers. Do you have ANY idea what did you just do by switching to this netplan? This is unbelievable stupid. Unbelievable. Sys Admin really have other things to do besides watching which developer had some stupid inspiration and decide to change stable thing that work flawlessly.

Unbelievable. Have no nice word for this move. You should really go and destroy your head with hammer.

Many thanks for sharing your thoughts with us.

Interesting tutorial but at the netplan part you are going to fast for me. I don’t have that file, i do have a 50cloudminitmyaml does this mean i need to add my ipaddress in the 5-cloud file?

You can generate a file for you system, using this command:

Read it in your article, but was afraid because I got a different file by default.

After adding ens7 to

and checking with:

all seemed well, but I can no longer ssh into my box now. Why?

Can you try this >>

that should tell you if open or available, also change the yes and no to true and false.

How is it, that in 2018 the configuration of your networks is decades behind Redhat 6?? Since when have we been reduced to config file editing, when the old classic blue and red config menu’s were fantastic. I dunno, even Raspberry Pi has better tools out of the box…..

Looking to set up a static IP address in preparation for setting up a personal VPN via raspberry Pi

Cannot find not generate a netplan file at all

Configuration of ethernet looks as follows:

Just a “Rank-Pensioner” amateur who can copy & past but does not understand much about Linux!

Cheers, Ton

If there is no default netplan config file, try to generate one as shown in the article, then put your config in there. For more information, read the netplan man page.

dhcp4: yes dhcp6: yes

dhcp4: no dhcp6: no

has to be changed to dhcp4: true dhcp6: true

dhcp4: false dhcp6: false

Yes, this is correct but yes or no values also work. After i installed Ubuntu 18.04, one of the default interfaces using dhcp4 had a value of yes(see the screenshot in article).

I didn’t work for me :(

Had to go to the man page and other examples and change it to true false, it it works for you and others then all gravy, just sharing the heads up

Practically, the best option would be to use true or false.

Got something to say? Join the discussion. Cancel reply

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.

Save my name, email, and website in this browser for the next time I comment.

  • Instructions

How to configure static IP address on Ubuntu 18.04

WB

Main idea of this article

The most often case of infrastructure organization today is automated settings assign via DHCP server cause no more needed on client side. But if you don't have DHCP - no panic. You may set IP address manually after this material reading.

Firstly, you should define the network interface which settings you are want to change. To see all network cards with theirs settings just run command below:

List All Active Network Interfaces on Ubuntu

In this output we've seen that our computer has three ethernet adapters. One of them is assigned to docker, other is loopback interface. So, our aim is ens33 network adapter. Let's go.

Since version 17.10 Ubuntu uses netplan tool to manage connectivity settings. This utility based on YAML synopsis rules. All settings are stored in /etc/netplan/*.yaml files.

So we should list all files in /etc/netplan/ directory:

Set Static IP Address in Ubuntu 18.04

NOTE: If there are no files found you can re-build it to default system config:

As we see, only 50-cloud-init.yaml file is present. To change connectivity settings we will edit it via text editor.

Open the netplan configuration file

Let's find our adapter's name inside. By default, Ubuntu 18.04 is trying to get network settings from dedicated DHCP-node. Directive below is responsible for this:

Find your network interface name

Some explains:

ens33 – interface name dhcp4, dhcp6 – this sections are respective to the dhcp-properties for 4th and 6th IP-protocol versions. addresses – static addresses "pointed" to the interface. (in CIDR format) gateway4 – IPv4 address for default hope. nameservers – IP addresses for servers which resolves DNS-queries.

NOTE: You must use spaces only, no tabs.

To apply changes just run this command:

Apply the recent network changes

As we see, no error messages, everything is OK.

And finally, just see system settings again:

Check your ip configuration again

Congratulations! IP addresses config is fully consistent with YAML-file we modified.

After this instruction reading you may assign static IP addresses to your Ubuntu server.

configure static ip address ubuntu 18 04

Thanks! Please indicate the reason for the low rating so that we can improve the article

  • Cloud servers
  • VMware cloud
  • Block storage
  • Object storage
  • Private network
  • Direct connect
  • Edge Gateways
  • Developer tools
  • Marketplace
  • Application Hosting
  • Web Hosting
  • WordPress Hosting
  • Cloud for startups
  • Cloud for E-commerce
  • Big Data computing
  • Referral program
  • About Serverspace
  • Press center
  • Terms of service
  • Privacy Policy
  • Use of Cookies
  • Infrastructure
  • Data centers
  • Control panel
  • Customer stories

Create account

By signing up you agree to the Terms of Service .

How-To Geek

How to set a static ip address in ubuntu.

When static is the way forward.

Quick Links

What is a static ip address, setting a static ip in ubuntu, set a static ip in ubuntu with the gui, connection convenience, key takeaways.

After gathering your connection name, subnet mask, and default gateway, you can set a static IP address in the terminal using the nmcli command. Or, in the GNOME desktop, open your connection settings and click the + icon, then enter the info for your static IP address there.

Your home network relies on IP addresses to route data between devices, and sometimes on reconnecting to the network a device's address can change. Here's how to give an Ubuntu Linux computer a permanent IP address that survives reboots.

Everything on your network home network, whether it's using a wired connection or Wi-Fi, has an IP address . IP stands for Internet Protocol. An IP address is a sequence of four numbers separated by three dots. Each IP address that is unique within that network.

IP addresses act as numeric labels. Your router uses these labels to send data between the correct devices. Usually, your router assigns IP addresses. It knows which IP addresses are in use and which are free. When a new device connects to the network, it requests an IP address and the router allocates one of the unused IP addresses. This is called DHCP, or dynamic host configuration protocol .

When a device is restarted or powered off and on, it may receive its old IP address once more, or it might be allocated a new IP address. This is normal for DHCP and it doesn't affect the normal running of your network. But if you have a server or some other computer that you need to be able to reach by its IP address, you'll run into problems if its IP address doesn't survive power downs or reboots.

Pinning a specific IP address to a computer is called allocating a static IP address . A static IP address, as its name suggests, isn't dynamic and it doesn't change even if the computer is power-cycled .

Nmcli is the command-line network manager tool , and can be used to change your IP address, configure network devices, and --- relevant to our purposes --- set up a static IP in Ubuntu.

We're demonstrating this technique on Ubuntu 22.04 LTS, but it ought to work on any Linux distribution, including Ubuntu 23.04. The nmcli tool was released in 2004, so it should be present on just about any standard distribution.

Let's take a look at the network connections that already exist on the computer. We're using the connection command with the show argument.

nmcli connection show

Using nmcli to list network connections

This displays some information about each connection. We only have a single connection configured.

The details of a single network connection displayed by nmcli

The output is wider than the terminal window. This is the information that we're shown.

  • Name : Our network connection is called "netplan-enp0s3."
  • UUID : The universally unique identifier Linux uses to reference this connection internally.
  • Type : This is an ethernet connection.
  • Device : This connection is using the "enp0s3" network interface. It's the only network card in this computer.

We can use the ip command to discover the IP address this computer is using.

The output of the ip addr command showing the ip address of the computer

In the output we can see the "enp0s3" entry, and its current IP address, 192.168.86.117. The "/24" is a shorthand way of saying that this network uses a 255.255.255.0 subnet mask . Take a note of this number, we'll need to use it later.

We need to choose the IP address we're going to set as our static IP address. Obviously, you can't use an IP address that is already in use by another device. One safe way to proceed is to use the current IP address assigned to the Ubuntu system. We know for certain that nothing else is using that IP address.

If we want to use a different IP address, try pinging it. We're going to test whether IP address 192.168.86.128 is in use. If everything else on your network uses DHCP and you get no response to the ping command, it should be safe to use.

ping 192.168.86.128

Using ping to determine if an IP address is in use

Even if another device had previously used that IP address, it'll be given a new IP address when it next boots up. Nothing responds to the ping requests, so we're clear to go ahead and configure 192.168.86.128 as our new static IP.

We also need to know the IP address of your default gateway , which will usually be your broadband router. We can find this using the ip command and the route option, which we can abbreviate to "r."

Using the ip command to find the IP address of the default gateway

The entry that starts with "default" is the route to the default gateway. Its IP address is 192.168.86.1. Now we can start to issue commands to set up our static IP address.

The first command is a long one.

sudo nmcli con add con-name "static-ip" ifname enp0s3 type ethernet ip4 192.168.86.128/24 gw4 192.168.86.1

Creating a new connection with the nmcli command

Taken in small chunks, it's not as bad as it looks. We're using sudo . The nmcli arguments are:

  • con : Short for "connection."
  • add : We're going to add a connection.
  • con-name "static-ip" : The name of our new connection will be "static-ip."
  • ifname enp0s3 : The connection will use network interface "enp0s3."
  • type ethernet : We're creating an ethernet connection.
  • ip4 192.168.86.128/24 : The IP address and subnet mask in classless inter-domain routing notation . This is where you need to use the number you took note of earlier.
  • gw4 192.168.86.1 : The IP address of the gateway we want this connection to use.

To make our connection a functioning connection, we need to provide a few more details. Our connection exists now, so we're not adding anything, we're modifying settings, so we use the mod argument. The setting we're changing is the IPv4 DNS settings. 8.8.8.8 is the IP address of Google's primary public DNS server , and 8.8.4.4 is Google's fallback DNS server.

Note that there is a "v" in "ipv4." In the previous command the syntax was "ip4" without a "v." The "v" needs to be used when you're modifying settings, but not when adding connections.

nmcli con mod "static-ip" ipv4.dns "8.8.8.8,8.8.4.4"

Using the nmcli command to set the DNS servers for a connection

To make our IP address static, we need to change the method which the IP address obtains its value. The default is "auto" which is the setting for DHCP. We need to set it to "manual."

nmcli con mod "static-ip" ipv4.method manual

Using the nmcli command to set an IP address to static

And now we can start or "bring up" our new connection.

nmcli con up "static-ip" ifname enp0s3

Using the nmcli command to start a network connection

We didn't get any error messages which is great. Lets use nmcli to look at our connections once more.

nmcli con show

The details of two network connections displayed by nmcli

Here's the output:

Our static-ip connection is active and using device "enp0s3." The existing connection "netplan-enp0s3" is no longer associated with a physical network interface because we've pinched "enp0s3" from it.

Click the icons at the far-right end of the system bar to show the system menu, then click on the "Wired Connected" menu option. If you're using a wireless connection, instead click the name of your Wi-Fi network.

The available connections are displayed. A dot indicates which is in use. Click the "Wired Settings" or "Wi-Fi Settings" menu option. The details of the active connection are displayed.

If you followed our previous instructions the new connection will be the active connection. We can see our new "static-ip" connection has the IP address, default gateway, and DNS servers that we set for it.

The system menu with the

To create a new connection using the "Settings" application, click the " + " icon on the "Networks" page, above the list of wired connections.

The wired connection section in the Network tab of the Settings app

A dialog appears. We need to provide a name for our new static IP connection.

Giving a name to a new connection profile in the

We're calling our new connection "static-2." Click the "IPv4" tab.

Supplying the IPv4 connection details to a new connection profile in the

Select the "Manual" radio button, and complete the "Address", "Netmask", and "Gateway" fields. Also complete the DNS field, and then click the green "Apply" button. Note the comma between the DNS entries.

Our new connection is listed in the "Wired" connections pane.

A newly-added connection in the wired connection section of the Network tab of the Settings app

You can swap between the available connections by clicking directly on their names.

If you want to modify a connection after you create it, click the cog icon. In this case, we'll enter the settings for the "static-ip" connection.

The wired connection section in the Network tab of the Settings app

A dialog box opens. Click on the "IPv4" tab.

The IPv4 tab of the connection settings dialog

Because we set our new IP address to be static, the "Manual" radio button is selected. You could change this back to DHCP by selecting the "Automatic (DHCP)" radio button, and clicking the green "Apply" button.

Using the nmcli command or the GNOME desktop and apps, you can hop between network connections very easily and very quickly.

It's more convenient to have a selection of connection profiles and move between them as you need to, rather than to have one that you keep editing. If something goes horribly wrong with the connection you're editing or adding, you can always fall back on one of the existing connections.

Server Gigabit Guide

configure static ip address ubuntu 18 04

  • How to Configure Static IP Address on Ubuntu 18.04
  • Linux Server
  • 1. Configuring Static IP address using DHCP
  • 3. Configuring Static IP address on Ubuntu Server
  • 4. Configuring Static IP address on Ubuntu Desktop

In this article, we will clarify how to set up a static IP address on Ubuntu 18.04.

The IP addresses allocated to your DHCP service router. In various cases, such as setting up a port forwarding or running a media server on your network, it might be appropriate to create a static IP address on your Ubuntu machine.

Configuring Static IP address using DHCP

The easiest and most recommended way to assign a static IP address to a device on your LAN is to set up a static DHCP on your router. The feature found on most routers is Static DHCP or DHCP Reservation . It causes the DHCP server to automatically assign the same IP address to a specific network device each time the device requests an address from the DHCP server. This works by assigning a static IP to the specific MAC address of the computer. The steps to configure a DHCP reservation vary from router to router and it is best to review the vendor’s documentation.

Starting with 17.10 release, Netplan is the default network management tool on Ubuntu, replacing the configuration file  /etc/network/interfaces  that had previously been used to configure the network on Ubuntu.

Netplan uses configuration files with YAML syntax. To configure a network interface with Netplan you simply create a YAML description for that interface and Netplan generates the required configuration files for your chosen renderer tool.

Netplan currently supports two renderers NetworkManager and Systemd-networkd.  NetworkManager  is  mostly  used  on  desktop  machines,  while  System-network  is  used  without  a  GUI  on  servers.

Configuring Static IP address on Ubuntu Server

The newer versions of Ubuntu uses ‘Predictable Network Interface Names’ that start with  en[letter][number] . by default. The first step is to identify the name of the ethernet interface you want to configure. You can use the ip link command as shown below:

The command will print a list of all the available network interfaces. In this case, the name of the interface is  ens3 :

Netplan configuration files are stored in the  /etc/netplan  directory and have the extension  .yaml . You’ll probably find one or two YAML files in this directory. 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.

Open the YAML configuration file with your text editor:

Let’s  explain  the  code  in  a  short  time  before  changing  the  configuration. Each Netplan Yaml file starts with the  network  key that has at least two required elements. The first required element is the version of network configuration format and the second one is the device type. Device types values can be  ethernets ,  bonds ,  bridges , and  vlans .

The configuration above also includes the  renderer  type. Out of the box, if you installed Ubuntu in server mode the renderer is configured to use  networkd  as the back end.

Under the device’s type ( in this case  ethernets ) we can specify one or more network interfaces. In this example we have only one interface  ens3  that is configured to obtain IP addressing from a DHCP server  dhcp4: yes .

To assign a static IP address to  ens3  interface edit the file as follows:

  • Firstly, Set DHCP to no dhcp4: yes
  • Further, Specify the static IP address 192.168.121.199/24 . Under  addresses:  you can add one or more IPv4 or IPv6 IP addresses that will be assigned to the network interface.
  • Specify the gateway gateway4: 192.168.121.1
  • Lastly, specify the nameservers addresses: [8.8.8.8, 1.1.1.1]  Under nameservers ,

Make  sure  you  follow  the  YAML  code  indent  requirements  when  editing  Yaml  files  as  it  may  not  work  if  the  configuration  includes  a  syntax  error.

After saved and closed  the file and applied   the  changes with:

Verify the changes by typing:

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

Configuring Static IP address on Ubuntu Desktop

Setting up a static IP address on Ubuntu Desktop computers requires no technical knowledge.

1.Firstly,  search for “network” and click on the Network icon in the Activities screen,. This will open the GNOME Network configuration settings. Click on the cog icon.

ubuntu 18.04-static IP Address-GNOME Network configuration settings

2. This will open the Network interface settings dialog box.

ubuntu-IPv4 method-static IP address-Netmask-gateway

3. In “IPV4” Method” section select “Manual”, and enter your static IP address, Netmask and Gateway.  Click  on  the  “Apply”  button  once  completed.

ubuntu-Network interface settings

After you have set up a static IP Address, open your terminal either by using the Ctrl+Alt+T  keyboard shortcut or by clicking on the terminal icon and verify the changes by typing:

The output will show the interface IP address:

In conclusion,, You have learned how to assign a static IP address on your Ubuntu 18.04 machine. If you have any question, please leave a comment below

Please refer to the following articles How to set up private nameserver for Linux server

Learn Ubuntu

Static IP in Ubuntu

Set static IP in Ubuntu using Terminal

Pratham Patel

Table of Contents

Normally, the router's DHCP server handles assigning the IP address to every device on the network, including your computer.

The DHCP server may also give you a new IP address occasionally. This could cause a problem if you have a home lab or server setup that works on a fixed IP address.

You need to set a static IP address on your Ubuntu system to avoid problems.

Please enable JavaScript

Step 1: Identify the correct network interface

The first step is always to know the name of your network interface.

"But why?" you might ask. That is because since Ubuntu 20.04, the network interfaces are named using predictable network interface names . This means your one and only ethernet interface will not be named 'eth0'.

Ubuntu Server and Ubuntu Desktop use different renderers for 'netplan', they are 'systemd-networkd' and 'NetworkManager', respectively. So let's go over their differences.

Ubuntu Server

To see available network interfaces on Ubuntu Server, run the following command:

Doing so will show a similar result:

The output enumerates network interfaces with numbers.

From this, I can see that the ethernet interface is 'enp1s0'.

Ubuntu Desktop

The advantage (at least in my opinion) of having Ubuntu Desktop is having NetworkManager as the renderer for netplan .

It has a pretty CLI output :)

Run the following command to view the available network interfaces:

That will give you the device name, type, state and connection status.

Here is what it looks like on my computer:

This is more readable at first glance. I can make out that my ethernet interface is named 'enp1s0'.

configure static ip address ubuntu 18 04

Step 2: See current IP address

Now that you know which interface needs to be addressed, let us edit a file .

Before I change my IP address/set a static one, let us first see what my current IP address is .

Nice! But let's change it to '192.168.122.128' for demonstration purposes.

Step 3: See the gateway

A gateway is a device that connects different networks (basically what your all-in-one router is). To know the address of your gateway, run the following command:

The gateway address will be on the line that begins with "default via".

Below is the output of running the ip command on my computer:

On the line that starts with "default via", I can see that my gateway address '192.168.122.1'

Make a note of your gateway address.

Step 4: Set static IP address

Now that you have detail like interface name and gateway address, it is time to edit a config file.

Step 4-A: Disable cloud-init if present

The easiest way to know if cloud-init is present or not is to check if there is a package with that name.

Run the following command to check:

If you get an outupt, you have 'cloud-init' installed.

Now, to disable could-init, create a new file inside the /etc/cloud/cloud.cfg.d directory. The name does not matter, so I will call it '99-disable-cloud-init.cfg'.

Add the following line to it:

Please reboot your Ubuntu system now so that cloud-init does not interfere when we set our static IP address in the next step. :)

Back to Step 4

Once the 'cloud-init' related configuration is complete, we must now edit the netplan configuration to add our static IP address.

Go to the /etc/netplan directory. It is better if there is one file (easier to know which one to edit), but in some cases, there might also be more than one file with the extension '.yml' or '.yaml'.

When in doubt, grep for the name of your network interface. Use the following command if you are not comfortable with grep:

Since the name of network interface for my ethernet is 'enp1s0', I will run the following command:

running this command shows that the file I am looking for is '00-installer-config.yaml'. So let us take a look at it.

You might have noticed a line that says 'ethernet' and our network interface name under that. Under this is where we configure our 'enp1s0' network interface.

Since we do not want DHCP assigned IP address, let us change that field from true to no .

Add a field called addresses . Write the IP address you wish to assign your computer along with the network prefix. So I will write 192.168.122.128/24 in the addresses field.

Finally, we also need to specify DNS nameservers. For that, create a new field called nameservers and under that, create a field called addresses which contains the IP address for your DNS servers . I used Cloudflare's DNS servers but you can use whatever you want.

This is what my '00-installer-config.yaml' file looks like after editing it to my liking.

To apply the settings, run the following command:

This will take only a few seconds, and the IP address will be updated once it is done.

You can check the IP address using the hostname -I command.

Perfect! The IP address has now changed successfully.

configure static ip address ubuntu 18 04

I know that it feels complicated but this is the proper procedure when you are trying to assign static IP via the command line in Ubuntu.

Let me know if you are stuck at some point or encounter any technical issues.

You might also like

How to Open and Edit bashrc file in Ubuntu

How to Open and Edit bashrc file in Ubuntu

Sagar Sharma

How to Quit the Terminal in Ubuntu

How to Find SSH Keys in Ubuntu

How to Find SSH Keys in Ubuntu

Setting a Static IP in Ubuntu – Linux IP Address Tutorial

In most network configurations, the router DHCP server assigns the IP address dynamically by default. If you want to ensure that your system IP stays the same every time, you can force it to use a static IP.

That's what we will learn in this article. We will explore two ways to set a static IP in Ubuntu.

Static IP addresses find their use in the following situations:

  • Configuring port forwarding.
  • Configuring your system as a server such as an FTP server, web server, or a media server.

Pre-requisites:

To follow this tutorial you will need the following:

  • Ubuntu installation, preferably with a GUI.
  • sudo rights as we will be modifying system configuration files.

How to Set a Static IP Using the Command Line

In this section, we will explore all the steps in detail needed to configure a static IP.

Step 1: Launch the terminal

You can launch the terminal using the shortcut Ctrl+ Shift+t .

Step 2: Note information about the current network

We will need our current network details such as the current assigned IP, subnet mask, and the network adapter name so that we can apply the necessary changes in the configurations.

Use the command below to find details of the available adapters and the respective IP information.

The output will look something like this:

image-14

For my network, the current adapter is eth0 . It could be different for your system

  • Note the current network adapter name

As my current adapter is eth0 , the below details are relevant.

It is worth noting that the current IP 172.23.199.129 is dynamically assigned. It has 20 bits reserved for the netmask. The broadcast address is 172.23.207.255 .

  • Note the subnet

We can find the subnet mask details using the command below:

Select the output against your adapter and read it carefully.

image-15

Based on the class and subnet mask, the usable host IP range for my network is: 172.23.192.1 - 172.23.207.254 .

Subnetting is a vast topic. For more info on subnetting and your usable IP ranges, check out this article .

Step 3: Make configuration changes

Netplan is the default network management tool for the latest Ubuntu versions. Configuration files for Netplan are written using YAML and end with the extension .yaml .

Note: Be careful about spaces in the configuration file as they are part of the syntax. Without proper indentation, the file won't be read properly.

  • Go to the netplan directory located at /etc/netplan .

ls into the /etc/netplan directory.

If you do not see any files, you can create one. The name could be anything, but by convention, it should start with a number like 01- and end with .yaml . The number sets the priority if you have more than one configuration file.

I'll create a file named 01-network-manager-all.yaml .

Let's add these lines to the file. We'll build the file step by step.

The top-level node in a Netplan configuration file is a network: mapping that contains version: 2 (means that it is using network definition version 2).

Next, we'll add a renderer, that controls the overall network. The renderer is systemd-networkd by default, but we'll set it to NetworkManager .

Now, our file looks like this:

Next, we'll add ethernets and refer to the network adapter name we looked for earlier in step#2. Other device types supported are modems: , wifis: , or bridges: .

As we are setting a static IP and we do not want to dynamically assign an IP to this network adapter, we'll set dhcp4 to no .

Now we'll specify the specific static IP we noted in step #2 depending on our subnet and the usable IP range. It was 172.23.207.254 .

Next, we'll specify the gateway, which is the router or network device that assigns the IP addresses. Mine is on 192.168.1.1 .

Next, we'll define nameservers . This is where you define a DNS server or a second DNS server. Here the first value is   8.8.8.8 which is Google's primary DNS server and the second value is 8.8.8.4 which is Google's secondary DNS server. These values can vary depending on your requirements.

Step 4: Apply and test the changes

We can test the changes first before permanently applying them using this command:

If there are no errors, it will ask if you want to apply these settings.

Now, finally, test the changes with the command ip a and you'll see that the static IP has been applied.

image-17

How to Set a Static IP Using the GUI

It is very easy to set a static IP through the Ubuntu GUI/ Desktop. Here are the steps:

  • Search for settings .
  • Click on either Network or Wi-Fi tab, depending on the interface you would like to modify.
  • To open the interface settings, click on the gear icon next to the interface name.
  • Select “Manual” in the IPV4 tab and enter your static IP address, Netmask and Gateway.
  • Click on the Apply button.

image-16

  • Verify by using the command ip a

image-18

In this article, we covered two methods to set the static IP in Ubuntu. I hope you found the article useful.

What’s your favorite thing you learned from this tutorial? Let me know on Twitter !

You can read my other posts here .

I am a DevOps Consultant and writer at FreeCodeCamp. I aim to provide easy and to-the-point content for Techies!

If you read this far, thank the author to show them you care. Say Thanks

Learn to code for free. freeCodeCamp's open source curriculum has helped more than 40,000 people get jobs as developers. Get started

ITzGeek

Netplan – How To Configure Static IP Address in Ubuntu 18.04 using Netplan

configure static ip address ubuntu 18 04

The first task for anyone after the installation of Ubuntu will be setting up an IP address to a system. In some cases, these tasks are taken care using DHCP (Dynamic Network Configuration Protocol) which handles assigning IP Address to Desktop and Servers.

But, if you look at the bigger infrastructure, they use static IP to avoid network problems due non-availability of DHCP server .

READ : How to configure DHCP server on CentOS 7 / Ubuntu 18.04 / 16.04 / Debian 9

Here, we will see how to configure static IP Address in Ubuntu 18.04 with netplan – new network configuration tool .

Also, at later of the article, we will take a look at how to use ifupdown ( /etc/network/interfaces / Network Manager ) for assigning static IP Address in Ubuntu 18.04 .

Prerequisites

Switch to the root user.

Find the available network cards on your system

You can run any one of the below commands in the terminal to get a list of network interfaces available on your system.

Choose the desired network interface

The output of the ifconfig command:

inet 192.168.1.6 netmask 255.255.255.0 broadcast 192.168.1.255

At this time, the system interface ( enp0s3) takes IP Address from DHCP server.

My laptop WiFi interface has not been connected to WiFi router. Hence, there is no IP address assigned to it.

For this demo, we will configure a static IP for enp0s3 / wlx7c8bca0d69b6 .

IP Address = 192.168.1.100 Netmask = 255.255.255.0 GATEWAY=192.168.1.1 DNS Server 1 = 192.168.1.1 DNS Server 2 = 8.8.8.8 Domain Name = itzgeek.local

Configure Static IP Address using Netplan

Netplan is a new network configuration utility that was introduced in Ubuntu 17.10 that reads the YAML file and generates all the confirguration for renderer tool ( NetworkManager or networkd ).

Netplan reads network configuration from /etc/netplan/*.yaml .

First, remove the ifupdown package so that we can use netplan to configure network interfaces.

In Ubuntu 18.04 server, cloud-init manages the network configuration. So, you would need to disable it by editing the below file.

Put the below line into the configuration file.

Move any files present in /etc/netplan directory to other location.

Now, we will create a netplan configuration for the network interface. I recommend you to use vim apt install vim editor for auto syntax.

Use the below configuration file.

To use NetworkManager, you would need to install the Network Manager sudo apt install network-manager and then use renderer: NetworkManager in the netplan configuration file.

wlx7c8bca0d69b6 – Wifi interface device name Raj – My Wifi SSID MyPass – Wifi Password

Generate the required configuration for the renderers.

Apply all configuration and restart renderers.

Verify Static IP Address

Verify the static IP using the below commands.

Configure Static IP Address in Ubuntu 18.04 using Netplan - Verify Static IP Address

Also, verify the DNS servers entries.

Configure Static IP Address in Ubuntu 18.04 using Netplan - DNS Information

Configure Static IP Address using ifupdown / Network Manager

Install the below packages using apt command to support the old method of configuring static IP address to systems.

Edit the interfaces file.

Update the file with below information.

# Interface Name #

# IP Address #

# Netmask #

# Gateway #

# DNS Servers #

Restart the networking using the following command.

For assigning an IP address to Wifi interface, use the Gnome Network Manager.

Click on your Wifi router name and then enter the router’s password to connect. On successful connection, your laptop would automatically receive an IP address from Wifi router which has built-in DHCP service.

If you want to assign static, click on the gear icon in WiFi settings page.

Configure Static IP Address in Ubuntu 18.04 - Configure WIFI

Go to IPv4 tab and enter the IP address details shown like below. Finally, click Apply .

Configure Static IP Address in Ubuntu 18.04 - Manual IP Address to WiFi

That’s All.

How To Install MySQL 8.0 on Ubuntu 18.04 LTS (Bionic Beaver)

How To Install And Set Up KVM On Ubuntu 18.04 LTS / Ubuntu 17.10

How to Set a Static IP Address On Ubuntu 22.04

How To Install PHP 8.1 on Ubuntu 20.04 / Ubuntu 18.04

How To Install Nvidia Drivers On Ubuntu 20.04 / Ubuntu 18.04

Install Zoom Client On Ubuntu 20.04/18.04 & Linux Mint 20/19

How To Install Jenkins on Ubuntu 20.04 / Ubuntu 18.04

How To Backup and Restore Ubuntu & Linux Mint With Timeshift

  • CentOS 8 / RHEL 8
  • CentOS 7 / RHEL 7
  • CentOS 6 / RHEL 6
  • LinuxMint 20
  • Linux Mint 19
  • Linux Mint 18
  • Rocky Linux 8
  • Ubuntu 22.04
  • Ubuntu 20.04
  • Ubuntu 18.04
  • MySQL / MariaDB
  • Other Tools

TecAdmin

How to Configure Static IP Addresses on Ubuntu 18.04 Server Edition

What is netplan.

Ubuntu systems are now using netplan for the network configuration. Netplan enables easily configuring networking on a system via YAML files. Netplan processes the YAML and generates the required configurations for either NetworkManager or systemd-network the system’s renderer.

This new tool replaces the static interfaces (/etc/network/interfaces) file that had previously been used to configure Ubuntu network interfaces. Now you must use /etc/netplan/*.yaml to configure Ubuntu interfaces.

The new interfaces configuration file now lives in the /etc/netplan directory. There are two renderers. NetworkManager and networkd. Use NetworkManager renderer for desktop computers manage through GUI and networkd is used for server to manage from the console.

The Desktop users can easily add or modify IP address using GUI interface. Read this tutorial to configure IP address on Ubuntu 18.04 Desktop.

Setup Static IP on Ubuntu 18.04

First of all, check the network interface name on your system using ifconfig command. In my case, the network interface name is “enp0s3”.

Now edit the following file.

Add below content to file with your address and gateway details:

Save the file and apply the new settings to networkd by executing command:

Your system is configured with an updated IP address. To view current IP of system use one of the below commands:

Related Posts

A comprehensive guide to creating and running jar files in java, ansible beginner’s guide, a complete guide to deploy angular app for production on linux servers.

configure static ip address ubuntu 18 04

Excellent tutorial! It´s very important to maintain proper indentation when configuring the .yaml files. Thanks!

Leave A Reply Cancel Reply

Save my name, email, and website in this browser for the next time I comment.

Type above and press Enter to search. Press Esc to cancel.

How to Configure static IP address in Ubuntu Server 18.04 LTS

When you install Ubuntu Server 18.04, it will grab a dynamically assigned IP address from your DHCP server, But you cannot run a server with dynamic IP addresses. So it's important to assign a permanent static IP address in place right away.

When it comes to Ubuntu network interface configuration, the way in which you set a static IP has completely changed. The previous LTS version Ubuntu 16.04 used /etc/network/interfaces file to configure static IP addresses, but Ubuntu 18.04 use new method known as netplan.

In this tutorial we will learn how to configure network interfaces in Ubuntu server 18.04 Bionic Beaver with netplan. We will look at how to set static IP addresses, default gateway and DNS name servers.

  • Identify  available network interface with ip command.
  • Netplan and YAML format interface configuration file.
  • Assigning static IP addresses (IPv4).
  • Configure static IPv6 Addresses on Ubuntu Server.
  • Assign multiple IP addresses to a single network interface.
  • Configure Multiple network interfaces.

Identify  available network interface with ip command

Before configure static IP address, you need to identify the available network interfaces on your Ubuntu server 18.04 and what is the device ID assigned to a particular network interface.

If you run ip link show command it will list all available network interfaces on your server.

Identify  available network interface with ip command

To view current IP configuration, run the ip addr command:

The output will display the currently assign IP configuration for all network interfaces.

ubuntu network interfaces

Netplan and YAML format interface configuration file

the way in which you set a static IP has completely changed. Ubuntu 18.04 uses a new method called netplan. In netplan the interface configuration file resides in the /etc/netplan directory and configuration file have .yaml extension. YAML syntax is very easy to understand and you don't need to be an expert on yaml format to edit the interface file. You only need to know what is needed for the network configuration.

If you list the content of the   /etc/netplan directory, you will see the interface configuration file with yaml extension.

In netplan the interface configuration file resides in the /etc/netplan directory and configuration file have .yaml extension

In my Ubuntu server name of the file is 50-cloud-init.yaml, but it could be saved with a different name depends on the Install Type.

On my Ubuntu server content of the file looks like following:

By just looking at the last line: "dhcp4: yes", we can say that the  ethernet interface enp0s3 has been configured to lease IP address from the DHCP Server. So this the configuration you need to have if you are planning to assign dynamic IP addresses from a DHCP server.

Assigning static IP addresses (IPv4)

Here is the sample netplan configuration file with static IP  Assignment (IPV4), In this configuration, interface enp0s3 has been configured with IP 192.168.1.100 and the default gateway of 192.168.1.1.

In order to apply the configuration, run the netplan command:

Then, run the ip add command to make sure that the changes being applied:

How it works..

In the above example, we configured enp0s3 ethernet interface to use static the IP address 192.168.1.100.

The first line:"version: 2" indicate this configuration block use netplan version 2 format.

The next line: "renderer: networkd" tells that this interface is managed by the systemd-networkd service.

An alternative option to networkd is NetworkManager, if the interface is managed by the NetworkManager. If you looked at the netplan config file of the Ubuntu 18.04 desktop, the renderer option is set to NetworkManager, because in a graphical desktop environment interfaces are managed by the NetworkManager.

Next, we start the interface configuration:

Here, enp0s3 is the name of the interface, you can run ip link show command to list network interfaces on your Ubuntu server.

Next, we set the static IP to 192.168.1.100 with the netmask of 24:

The address option can be also defined in following format:

Next, we set the default gateway to 192.168.1.1:

We used the option gateway4 because this is IPv4 gateway, For IPv6 gateway we need to use gateway6 option.

Next, we set the DNS servers to 8.8.8.8 and 4.4.4.4.

To apply new interface configurations, we run the netplan command :

The command will Apply current netplan config to running system. We no longer need to do network restart to apply changes.

Configure static IPv6 Addresses on Ubuntu Server

The same netplan format use to assign IPv6 address, only difference is , we need to use the gateway6 option instead of gateway4 .

Assign multiple IP addresses to a single network interface

It is very common to have a single network interface configured with more that one IP address. Following is the sample Ubuntu netplan config file with two IPv4 address assigned to one network interface.

The address option can be also written in following format:

A single network interface can be configured with both IPv4 and IPv6 addresses as shown in the following netplan file:

Configure Multiple network interfaces

It is very common to install more that one network interface on a single server. Here's an example netplan file, configured with  static addresses for two network cards:

Note that only the primary interface has been configured with a default gateway, In this case it is enp0s3. It is not practical to have more than one default gateway,  the default gateway is the address you send traffic when you have no other route for it.

Let's look at another netplan example where both static and DHCP addresses being used:

In the preceding example, the wifi interface  wlp3s0 has been configured to lease IP address from the DHCP server.

In this tutorial we learned how to configure static IP address on Ubuntu 18.04 Bionic Beaver, where the old /etc/network/interfaces file is no longer in used. Ubuntu 18 now uses the new method called netplan to manage networking.

With Netplan, configuration files for the network interfaces reside in the /etc/netplan directory, in YAML data format, while the netplan command uses to restart networking after configuration changes.

How to Configure a Static IP Address on Ubuntu 18.04 LTS

configure static ip address ubuntu 18 04

On ubuntu 18.04 LTS , the network configuration is now managed by NetPlan by default. The network configuration files are saved in /etc/netplan/ directory with a .yaml extension. When you install the Ubuntu 18.04 server version, the default NetPlan yaml file is located at /etc/netplan/50-cloud-init.yaml , by default it uses DHCP method to get ip address configuration for the interface.

What is NetPlan?

Netplan is a utility for easily configuring networking on a linux system. You simply create a YAML description of the required network interfaces and what each should be configured to do.

In this quick tutorial, we are going to show you how to setup a static IP address on ubuntu 18.04 LTS using NetPlan tool

– First, use the below command to print a list of all the available network interfaces. In this case, the name of the interface is enp3s0 :

In this example we are going to configure a static IP address , where the IP is 192.168.1.151 , subnet mask 24 (255.255.255.0), default gateway is 192.168.1.254 and nameservers 192.168.1.254 and 8.8.8.8 on the network interface enp3s0 .

You have learned how to assign a static IP address on your Ubuntu 18.04 machine using the Command Line. You might want to check the following guides:

  • How to Setup Skype on Ubuntu 18.04 LTS Bionic Beaver
  • Install Sublime Text 3 on Ubuntu 18.04 LTS Bionic Beaver
  • Build / Install Python 3.7 on Ubuntu 18.04 LTS Bionic Beaver
  • How to Install Google Chrome Web Browser on Ubuntu 18.04

We hope this tutorial was enough Helpful. If you need more information, or have any questions, just comment below and we will be glad to assist you!

Buy Me A Coffee

Lotfi Waderni

I'm a technical writer with a background in Linux and windows server administration.

How to install PgAdmin 4 in Server Mode as a Web Application using WSGI on Ubuntu 18.04 LTS / Ubuntu 16.04 LTS

How to collect and forward iis logs to graylog 2 server using nxlog, you may also like, how to install pgadmin 4 in server..., how to install netdata to monitor your..., how to install and configure zabbix proxy..., how to use a survey to provide..., leave a comment cancel reply.

GraspingTech

Configure Ubuntu Server 18.04 to use a static IP address

Since Ubuntu 17.10 Artful, Netplan has been introduced as the new network configuration utility. This tutorial will show you how to change the IP address from DHCP to static using Netplan.

Table of Contents

Introduction

There will be a file placed in the  /etc/netplan  folder that’s used to configure the network. You might come across two different filenames depending on what installation media you’ve used. These are:

Ubuntu Server 18.04 server ISO

Ubuntu Server 18.04 cloud image

As you can see by the name above, the cloud image uses  cloud-init  to configure the network, so we can’t just edit this file because changes might be overwritten. We’ll have to disable network configuration by  cloud-init .

How to disable network configuration by cloud-init

Create a new file called:

Add the following to the file:

Rename the netplan config file to the same as the one in the server ISO.

How to change the IP address from DHCP to static on Ubuntu Server 18.04

Open the netplan config file:

You should see a file that looks similar to this:Advertisements

It’s the  ethernets  section of the file we want to change below the name of your ethernet adapter. On my system it’s  enp0s3 . First we want to change  dhcp4  to false and then add the static IP config below this. Here’s an example below:

Now apply the config with the following command:

That’s it

Now the server will keep the assigned IP address whenever it’s restarted.

David Miller is a seasoned tech aficionado with a profound expertise in NGINX and Ubuntu. With a career spanning over a decade, David has honed his skills in optimizing web servers and enhancing server performance to perfection. His deep-rooted passion for open-source technologies has led him to become a go-to resource in the field. Whether it’s crafting intricate NGINX configurations or troubleshooting complex Ubuntu server issues, David’s problem-solving prowess shines through.

configure static ip address ubuntu 18 04

  • Knowledge Base
  • Customer Login

Dedicated Servers

Robust, secure and industrial-grade dedicated servers.

Storage Dedicated Servers

Affordable, customizable, reliable

High Performance Servers

High availability hosting utilizing high grade servers.

Secure, single-tenant and agile virtualized environment.

Co-location

Safe home for your servers in our high-class data centre.

Backup and Restore

Reliable, cost effective, backup and disaster recovery.

DDos Protection

7 layer DDoS mitigation system that protects your network.

Managed Services

Outsource your IT tasks to our skilled technical team.

Find a good domain for your business.

Powerful email hosting platform at your fingertips.

Web Hosting

Reliable and scalable web hosting solution.

It’s not about what we say, it’s about what we do. Learn more about Casbay’s background and confidently join our growing community.

Our vision, history and photo gallery.

Our Data Centre

Tier III certified data centre.

Our Clients

Explore our existing client base.

Our partners that grow with us in our journey.

The latest news and media releases.

Casbay Knowledge Base

Search our articles or browse by category below.

configure static ip address ubuntu 18 04

How to Configure Static IP Address on Ubuntu 18.04

In this tutorial, we’ll explain how to set up a static IP address on Ubuntu 18.04.

Do you know that:

Your router DHCP server would assign the IP addresses dynamically? In different situations such as configuring port forwarding or running a media server on your network, it may be necessary to set a static IP address on your Ubuntu computer.

Configuring Static IP address using DHCP

The easiest way to assign a static IP address to a device on your LAN is by setting up a Static DHCP on your router. Static DHCP or DHCP reservation is a feature that we find on most routers which makes the DHCP server automatically assign the same IP address to a specific network device, every time the device requests an address from the DHCP server. This works by assigning a static IP to the device’s unique MAC address. However, the steps for configuring a DHCP reservation vary from router to router and it’s advisable to consult the vendor’s documentation.

Starting with the 17.10 release, Netplan is the default network management tool on Ubuntu, replacing the configuration file /etc/network/interfaces that had previously been used to configure the network on Ubuntu.

Netplan uses configuration files with YAML syntax. To configure a network interface with Netplan you simply create a YAML description for that interface and Netplan generates the required configuration files for the renderer tool that you choose.

Moreover, Netplan currently supports two renderers NetworkManager and Systemd-networkd. We use NetworkManager mostly on desktop machines. For System-network, we use it when a GUI is absent on servers.

Configuring Static IP address on Ubuntu Server

To configure a static IP address, you will need a VPS or Dedicated Server that runs on Ubuntu. The newer versions of Ubuntu uses ‘Predictable Network Interface Names’ that start with en[letter][number] . by default. The first step is to identify the name of the ethernet interface you want to configure. You can use the following IP link command:

The command will print a list of all the available network interfaces. In this case, the name of the interface is  ens3 :

The location of the Netplan configuration files is in the /etc/netplan  directory and have the extension  .yaml . You’ll probably find one or two YAML files in this directory. 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.

Next, open the YAML configuration file with your text editor:

Before changing the configuration

Let’s explain the code in a short time before changing the configuration.

Each Netplan Yaml file starts with the network  key that has at least two required elements. The first required element is the version of network configuration format and the second one is the device type. Device types values can be  ethernets ,  bonds ,  bridges , and  vlans .

Furthermore, the configuration above also includes the renderer  type. Out of the box, if you installed Ubuntu in server mode the renderer is configured to use  networkd  as the back end.

Under the device’s type ( in this case  ethernets ) we can specify one or more network interfaces. In this example, we have only one interface ens3  that is configured to obtain IP addressing from a DHCP server  dhcp4: yes .

To assign a static IP address to  ens3 the interface edit the file as follows:

  • Set DHCP to no  dhcp4: yes
  • Specify the static IP address  192.168.121.199/24 . Under  addresses:  you can add one or more IPv4 or IPv6 IP addresses that will be assigned to the network interface.
  • Specify the gateway  gateway4: 192.168.121.1
  • Under  nameservers , specify the nameservers  addresses: [8.8.8.8, 1.1.1.1]

Make  sure  you  follow  the  YAML  code  indent  requirements  when  editing  Yaml  files  as  it  may not  work if  the c onfiguration  includes  a  syntax  error.

Once you save and closed the  file, and  the  changes  are  applied  with:

Then verify the changes by typing:

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

Configuring Static IP address on Ubuntu Desktop

Setting up a static IP address on Ubuntu Desktop computers requires no technical knowledge.

1.In the Activities screen, search for “network” and click on the Network icon. This will open the GNOME Network configuration settings. Click on the cog icon.

configure static ip address ubuntu 18 04

3. In “IPV4” Method” section select “Manual”, and enter your static IP address, Netmask and Gateway.  Click  on  the  “Apply”  button  once  completed.

configure static ip address ubuntu 18 04

Now that you have set up a static IP Address, open your terminal either by using the  Ctrl+Alt+T  keyboard shortcut or by clicking on the terminal icon and verify the changes by typing:

The output will show the interface IP address:

You have learned how to assign a static IP address on your Ubuntu 18.04 machine.

If you have any questions, please leave a comment below.

Looking for more guide articles on Ubuntu? Kindly visit our Knowledge Base .

configure static ip address ubuntu 18 04

  • [email protected]
  • Cloud Server
  • VPS Hosting
  • Windows VPS
  • Dedicated Server
  • Cloud calculator
  • Encryption Project
  • Data Center
  • Terms of Service
  • Acceptance Use Policy
  • Privacy Policy
  • Money Back Guarantee
  • Payment Info
  • Support Ticket
  • Knowledgebase

configure static ip address ubuntu 18 04

Copyright © 2010 – 2023  Casbay LLC. All Rights Reserved.

DeviceTests.com Logo

Configuring Static IP with NetPlan: A Guide for Ubuntu 18.04 Users

Carlos Bradley

In this guide, we’ll walk you through the process of configuring a static IP address with NetPlan on Ubuntu 18.04. This process is essential for network management and can be particularly useful for server configurations.

To configure a static IP with NetPlan on Ubuntu 18.04, you need to create a NetPlan configuration file, specify the network settings including the IP address, gateway, and DNS server IP, and then apply the configuration. This allows for easy network management and is particularly useful for server configurations.

What is NetPlan?

NetPlan is a utility for easily configuring networking on a Linux system. It reads network configuration described in YAML format and applies it to the system, simplifying the process of configuring a network.

Prerequisites

Before we get started, make sure you have the following:

  • A Ubuntu 18.04 system
  • Access to a terminal window/command line
  • The network interface name (you can find this by running ip addr show )
  • The static IP address, gateway, and DNS server IP you wish to configure

Step 1: Creating a NetPlan Configuration File

To set up a static IP with NetPlan, we first need to create a NetPlan configuration file. Open a terminal window and type the following command:

This command opens a new file named 50-your-config.yaml in the nano text editor. The sudo command is used to run the operation with root privileges.

Step 2: Configuring the Network

In the newly opened file, add the following content:

Replace eth0 with your network interface name, and replace the xxx in the IP addresses with your actual values. Here’s what each line does:

  • version: 2 : This line specifies the NetPlan syntax version. The current version is 2.
  • renderer: networkd : This line sets networkd as the network renderer. Networkd is a system service that manages networks. It’s fast and efficient, making it a good choice for servers.
  • addresses: [75.151.xxx.226/30] : This line sets the static IP address and subnet mask for the network interface. The /30 after the IP address is the CIDR notation for the subnet mask.
  • gateway4: 75.151.xxx.230 : This line sets the gateway for the network interface.
  • nameservers: addresses: [75.151.xxx.230] : This line sets the DNS server IP for the network interface.

Step 3: Applying the Configuration

After you’ve entered the configuration, save the file and exit the text editor. Then, apply the NetPlan configuration by running the following command:

This command applies the network configuration you’ve set in the YAML file.

Troubleshooting

If you encounter any issues, you can check the syntax of the configuration file by running sudo netplan --debug apply . This command prints detailed output about what NetPlan is doing, which can help you identify any issues.

Additionally, you can use an online IP subnet calculator to determine the appropriate subnet and CIDR notation for your network.

Configuring a static IP with NetPlan on Ubuntu 18.04 is a straightforward process. By creating a YAML configuration file and applying it with NetPlan, you can easily set up your network configuration. Remember to replace the placeholders in the examples with your actual network details. Happy networking!

Configuring a static IP address allows you to assign a fixed IP to your device on a network. This can be useful for server configurations or when you need to consistently access your device using a specific IP address.

You can find the network interface name by running the command ip addr show in the terminal. Look for the interface with an IP address assigned to it, which is usually named something like eth0 or enp0s3 .

The renderer: networkd line specifies the network renderer to be used by NetPlan. In this case, we are using networkd , which is a system service that efficiently manages networks and is suitable for server configurations.

To apply the NetPlan configuration, you can run the command sudo netplan apply in the terminal. This command applies the network configuration specified in the NetPlan configuration file.

If you encounter issues with the NetPlan configuration, you can check the syntax of the configuration file by running sudo netplan --debug apply . This command will provide detailed output that can help you identify and troubleshoot any issues.

Related Posts

Ubuntu 2

How To Fix 502 Bad Gateway Error in Nginx After Upgrading to Ubuntu 22.04.1 LTS

Ubuntu 21

Fixing Chrome Not Working After Upgrading to Ubuntu 22.04

Ubuntu 15

How To Determine Your Hard Drive’s Format

Ubuntu 1

How To Install AMD GPU Drivers on Ubuntu 22.04 LTS

Ubuntu 12

Can I Disable updatedb.mlocate on Ubuntu Server?

Ubuntu 9

Fixing “sudo: ./abc.sh: command not found” Error in Bash Scripts

About the author, carlos bradley, leave a comment cancel reply.

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

Save my name, email, and website in this browser for the next time I comment.

Carlos Bradley is a developer by day and an author by night. All of the computer tests on DeviceTests.com have been developed by Carlos.

Ubuntu 6

How To Fix HDMI Sound Not Working in Ubuntu 20.04

Ubuntu 2

How To Upgrade Docker-Compose on Ubuntu 20.04

Ubuntu 3

How To Update a Specific Repository with apt-get

XDA Developers

How to set a static internal IP in Ubuntu

Quick links, how to set static internal ip in ubuntu using the gui, how to set static internal ip in ubuntu using the terminal and text editor.

There comes a time when you might have to configure Ubuntu or any other Linux distribution with a static IP address. While you can't change your external static IP address, since it's the one your internet service provider provides, you can change your internal one. This is the IP address used on your network inside your home or office.

Though many tasks on Ubuntu usually require you to visit the terminal app and deal with lines of text, changing your internal IP is easy. You can do this through the settings app and the Graphical User Interface (GUI). Of course, if you want, you can also swap things out by going through the terminal. Here's how.

Without any technical know-how or knowledge, you can set a static IP in Ubuntu through the settings app. Just note, you will have to use the terminal once to find a range of IP addresses that you can assign. Once you do that, you just tap the Windows Key or the Superkey on your device and search for Settings . Once the app is open, proceed with the steps below.

  • If you're connected to the internet via Wi-Fi, choose Wi-Fi . If you're connected via Ethernet, select Network.
  • Once the interface is open, click the settings icon next to the network you're connected to.
  • From the list of tabs at the top, choose IPv4.
  • Under ipv4 method, be sure to choose Manual.
  • Under Addresses, enter the IP address, the Netmask, and the Gateway you want to use. For finding IP addresses that'll work on your network, you can proceed with the steps below.
  • Open a terminal session. With Ctrl, Alt, and T. Install net-tools with the command sudo apt install net-tools.
  • In this case, we have an inet of 192.168.1.176 and a netmask of 255.255.255.0. We can enter those numbers and can calculate the usable range using this website .
  • When you've calculated the usable range of addresses, choose a valid IP address that falls within this range. Then, you can click Apply at the top.

Any changes you apply will automatically go into effect. If you want, you can also use the terminal to confirm your IP address. Launch it with Ctrl, Alt, and T on your keyboard. Once launched, enter the command ip addr or ip a . You should see an interface IP address listed.

If you're a bit more technical and want to set a static IP in Ubuntu using the terminal, that is possible. You'll have to edit some lines of text and go through a few extra steps, but here's how:

  • Display information about your network. Use the command nmcli connection show. You'll see a network name, a UUID, a Type, and a Device. If this package isn't installed (though it should be, as it comes preinstalled with Ubuntu), then run sudo apt-get install network-manager
  • Note down the range of IP addresses you'll be able to use. Use the command ip addr to find out your machine's current IP address. This tutorial assumes that your network adapter is called enp0s3. If it isn't, then look for the correct one and also change the interface names in the subsequent commands. In the above example, we have an inet of 10.0.2.15, with the /24 denoting that the network uses a 255.255.255.0 subnet mask. In most cases, your usable network range will be whatever is in the first three places of the internal IP address, and then any unused number on your network between 1 and 255 in the last section. For example, we can use 10.0.2.16. If you're unsure, you can enter the subnet mask and your internal IP address into this website to calculate the usable range.
  • Note the IP address of your default gateway with the command ip r. In our example, it's 10.2.2.2.
  • Next, we'll add a new static connection option. Run the following command, making sure to change the numbers after "ip4" and "gw4" depending on your network conditions. These are the IP address you want to change your machine to and the current default gateway, respectively. sudo nmcli con add con-name "static" ifname enp0s3 type ethernet ip4 10.0.2.13/24 gw4 10.0.2.2 In our case, we do the following.
  • Set your DNS, manual DHCP (so, a static IP), and enable the connection. You can do that by running the following commands in succession. nmcli con mod "static" ipv4.dns "1.1.1.1,8.8.8.8" You can swap out the DNS servers above for whatever you want, they are in order of primary and secondary. nmcli con mod "static" ipv4.method manual; nmcli con up "static" ifname enp0s3 Once done, you can run nmcli con show to see if the new connection is enabled. If the output above looks like yours, then you're ready to go!

Setting complete

That's all you need to set up a static IP in Ubuntu. It doesn't take much effort. Remember, we're always writing about Linux, so you can check out our guide to the best Linux laptops should you need one.

How to set a static internal IP in Ubuntu

IMAGES

  1. How to Configure Network Static IP Address in Ubuntu 18.04

    configure static ip address ubuntu 18 04

  2. Netplan

    configure static ip address ubuntu 18 04

  3. How To Configure Static IP address On Ubuntu 18.04

    configure static ip address ubuntu 18 04

  4. How to Configure Static IP Address on Ubuntu 18.04

    configure static ip address ubuntu 18 04

  5. How To Configure IP Address In Ubuntu 18.04 LTS

    configure static ip address ubuntu 18 04

  6. How to Configure Static IP on Ubuntu 18.04 (Desktop)

    configure static ip address ubuntu 18 04

VIDEO

  1. Configure Static IP address on Windows Server Machine

  2. How to Configure Static IP Address on Ubuntu 22 04

  3. How to assign Static IP Address in Ubuntu 17.04

  4. CSS NCII TUTORIAL PART1

  5. How to Set Static IP in Ubuntu Server 20.04 & Create New User |Hindi|

  6. How To Configure Static IP on Ubuntu 22.04 (Jammy Jellyfish)

COMMENTS

  1. How to Configure Static IP Address on Ubuntu 18.04

    In this tutorial, we'll explain how to set up a static IP address on Ubuntu 18.04. Generally, IP addresses are assigned dynamically by your router DHCP server. Setting a static IP address on your Ubuntu machine may be required in different situations, such as configuring port forwarding or running a media server on your network.

  2. How to setup a static IP on Ubuntu Server 18.04

    1 Is this a fresh 18.04 install or upgrade from another version? - WinEunuuchs2Unix Apr 29, 2018 at 5:16 Sorry I should've said this in the text, its a fresh install of 18.04 server. - final20 Apr 29, 2018 at 5:25 The most simple solution for me was, to specify a static IPv4 address right during installation (together with subnet, gateway, etc.).

  3. How to configure a static IP address in Ubuntu Server 18.04

    Open up a terminal window on your Ubuntu 18.04 server (or log in via secure shell). Change into the /etc/netplan directory with the command cd /etc/netplan. Issue the command ls and you...

  4. How to Configure Network Static IP Address in Ubuntu 18.04

    In this article, we will explain how to configure a network static or dynamic IP address for a network interface in Ubuntu 18.04 using Netplan utility. List All Active Network Interfaces on Ubuntu First, you need to identify the network interface you are going to configure.

  5. How to configure static IP address on Ubuntu 18.04

    Instructions How to configure static IP address on Ubuntu 18.04 William Bell June 3, 2020 Updated June 7, 2023 How to configure static IP address on Ubuntu 18.04 Ubuntu Main idea of this article The most often case of infrastructure organization today is automated settings assign via DHCP server cause no more needed on client side.

  6. Netplan static IP on Ubuntu configuration

    To configure a static IP address on your Ubuntu server you need to find and modify a relevant netplan network configuration file.

  7. How To Configure IP Address In Ubuntu 18.04 LTS

    Gateway : 192.168.225.1 Netmask : 255.255.255. DNS servers : 8.8.8.8 and 8.8.4.4. After configuring all network settings, here is how the contents of 50-cloud-init.yaml file looks like. Configure static ip in Ubuntu 18.04

  8. How to Set a Static IP Address in Ubuntu

    Quick Links What Is a Static IP Address? Setting a Static IP in Ubuntu Set a Static IP in Ubuntu with the GUI Connection Convenience Key Takeaways After gathering your connection name, subnet mask, and default gateway, you can set a static IP address in the terminal using the nmcli command.

  9. Setting a Static IP Address in Ubuntu 18.04

    Finally, we are in the right menu on Ubuntu 18.04 to set a static IP address. There are several things you will need to do on this screen. First, you need to change the DHCP mode from automatic to manual ( 1. ). Once in manual mode, you will need to define the address ( 2. ), netmask ( 3. ), and gateway ( 4. ).

  10. How to Configure Static IP Address on Ubuntu 18.04 (Desktop)

    Step 2 - Setup Static IP on Ubuntu 18.04. Under the IPv4 Method select the "Manual" option. Now go to the Addresses section and set your IP Address, Netmask, and Gateway. You can also set remote DNS IP addresses. If you don't know what to set here use 8.8.8.8 and 8.8.4.4 as shown in below screenshot.

  11. How to Configure Static IP Address on Ubuntu 18.04

    n this article, we will clarify how to set up a static IP address on Ubuntu 18.04. The IP addresses are allocated to your DHCP service router.

  12. Configure Static IP Address on Ubuntu 22.04|20.04|18.04

    Method 2: Use Netplan YAML network configuration. On Ubuntu 22.04|20.04|18.04, you can use Netplan which is a YAML network configuration tool to set static IP address. This configuration assumes your network interface is called eth0. This may vary depending on your working environment. Create a network configuration file.

  13. Set static IP in Ubuntu using Command Line

    Dec 5, 2022 Table of Contents Normally, the router's DHCP server handles assigning the IP address to every device on the network, including your computer. The DHCP server may also give you a new IP address occasionally. This could cause a problem if you have a home lab or server setup that works on a fixed IP address.

  14. Setting a Static IP in Ubuntu

    Step 1: Launch the terminal You can launch the terminal using the shortcut Ctrl+ Shift+t. Step 2: Note information about the current network We will need our current network details such as the current assigned IP, subnet mask, and the network adapter name so that we can apply the necessary changes in the configurations.

  15. How To Configure Static IP Address in Ubuntu 18.04 using Netplan

    If you want to assign static, click on the gear icon in WiFi settings page. Configure Static IP Address in Ubuntu 18.04 - Configure WIFI. Go to IPv4 tab and enter the IP address details shown like below. Finally, click Apply. Configure Static IP Address in Ubuntu 18.04 - Manual IP Address to WiFi.

  16. How to Configure Static IP Addresses on Ubuntu 18.04 Server Edition

    The Desktop users can easily add or modify IP address using GUI interface. Read this tutorial to configure IP address on Ubuntu 18.04 Desktop. Setup Static IP on Ubuntu 18.04. First of all, check the network interface name on your system using ifconfig command. In my case, the network interface name is "enp0s3". Now edit the following file.

  17. How to Configure static IP address in Ubuntu Server 18.04 LTS

    When it comes to Ubuntu network interface configuration, the way in which you set a static IP has completely changed. The previous LTS version Ubuntu 16.04 used /etc/network/interface file to configure static IP addresses, but Ubuntu 18.04 use new method known as netplan.

  18. How to Configure a Static IP Address on Ubuntu 18.04 LTS

    In this quick tutorial, we are going to show you how to setup a static IP address on ubuntu 18.04 LTS using NetPlan tool. - First, use the below command to print a list of all the available network interfaces. In this case, the name of the interface is enp3s0:

  19. Configure Ubuntu Server 18.04 to use a static IP address

    Configure Ubuntu Server 18.04 to use a static IP address. 0 Comments Since Ubuntu 17.10 Artful, Netplan has been introduced as the new network configuration utility. This tutorial will show you how to change the IP address from DHCP to static using Netplan. ... How to change the IP address from DHCP to static on Ubuntu Server 18.04. Open the ...

  20. How to Configure Static IP Address on Ubuntu 20.04

    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 ip link 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 ens3:

  21. How to Configure Static IP Address on Ubuntu 18.04

    Click on the cog icon. Select Network icon. 2. This will open the Network interface settings dialog box. Network interface settings dialog box. 3. In "IPV4" Method" section select "Manual", and enter your static IP address, Netmask and Gateway. Click on the "Apply" button once completed.

  22. Configuring Static IP with NetPlan: A Guide for Ubuntu 18.04 Users

    A Ubuntu 18.04 system; Access to a terminal window/command line; The network interface name (you can find this by running ip addr show) The static IP address, gateway, and DNS server IP you wish to configure; Step 1: Creating a NetPlan Configuration File. To set up a static IP with NetPlan, we first need to create a NetPlan configuration file.

  23. How to set a static internal IP in Ubuntu

    If you're connected to the internet via Wi-Fi, choose Wi-Fi.If you're connected via Ethernet, select Network.; Once the interface is open, click the settings icon next to the network you're ...

  24. Setting a Static IP Address in Ubuntu 24.04 via the Command Line

    Here's an example configuration to set a static IP address: network: version: 2 renderer: networkd ethernets: enp0s3: dhcp4: no addresses: - 192.168.1.10/24 routes: - to: default via: 192.168.1.1 nameservers: addresses: [8.8.8.8, 8.8.4.4] ... Setting a static IP address on Ubuntu 24.04 involves identifying the correct network interface ...