• PRO Courses Guides New Tech Help Pro Expert Videos About wikiHow Pro Upgrade Sign In
  • EDIT Edit this Article
  • EXPLORE Tech Help Pro About Us Random Article Quizzes Request a New Article Community Dashboard This Or That Game Popular Categories Arts and Entertainment Artwork Books Movies Computers and Electronics Computers Phone Skills Technology Hacks Health Men's Health Mental Health Women's Health Relationships Dating Love Relationship Issues Hobbies and Crafts Crafts Drawing Games Education & Communication Communication Skills Personal Development Studying Personal Care and Style Fashion Hair Care Personal Hygiene Youth Personal Care School Stuff Dating All Categories Arts and Entertainment Finance and Business Home and Garden Relationship Quizzes Cars & Other Vehicles Food and Entertaining Personal Care and Style Sports and Fitness Computers and Electronics Health Pets and Animals Travel Education & Communication Hobbies and Crafts Philosophy and Religion Work World Family Life Holidays and Traditions Relationships Youth
  • Browse Articles
  • Learn Something New
  • Quizzes Hot
  • This Or That Game New
  • Train Your Brain
  • Explore More
  • Support wikiHow
  • About wikiHow
  • Log in / Sign up
  • Computers and Electronics
  • Operating Systems

How to Assign an IP Address on a Linux Computer

Last Updated: July 28, 2022 Tested

Debian, Ubuntu, & Linux Mint

Red hat, centos, & fedora.

This article was co-authored by wikiHow staff writer, Jack Lloyd . Jack Lloyd is a Technology Writer and Editor for wikiHow. He has over two years of experience writing and editing technology-related articles. He is technology enthusiast and an English teacher. The wikiHow Tech Team also followed the article's instructions and verified that they work. This article has been viewed 724,043 times. Learn more...

This wikiHow teaches you how to assign a new IP address to your computer when using Linux. Doing so can prevent connection issues for the item in question.

Step 1 Verify your Linux version.

  • Press Ctrl + Alt + T or Ctrl + Alt + F1 (if you're on a Mac, substitute the ⌘ Command key for Ctrl .
  • Click the text box at the top or bottom of the screen if possible.
  • Open the Menu window and find the "Terminal" application, then click on it.

Step 3 Switch to root.

  • A "root" account is the Linux equivalent of an Administrator account on a Windows or Mac computer.

Step 4 Bring up a list of your current Internet items.

  • The top item should be your current router or Ethernet connection. This item's name is "eth0" (Ethernet) or "wifi0" (Wi-Fi) in Linux.

Step 5 Find the item to which you want to assign an IP address.

  • In most cases, this is the "eth0" or "wifi0" item.

Step 6 Change the item's IP address.

  • To assign an IP of "192.168.2.100" to your ethernet connection ("eth0"), for example, you'd enter sudo ifconfig eth0 192.168.0.100 netmask 255.255.255.0 here.

Step 7 Assign a default gateway.

  • If you have a different DNS server address that you would rather use, enter that in the place of 8.8.8.8 .

Step 9 Check your item's new IP address.

  • 5 Find the network connection that you want to change. This will normally be the Ethernet or Wi-Fi connection, which has an IP address currently listed on the right side of the window.

Step 6 Switch to the network scripts directory.

  • For a network named "eno12345678", for example, you'd enter vi ifcfg-eno12345678 here.

Step 9 Edit the network's information.

  • BOOTPROTO - Change dhcp to none
  • Any IPV6 entry - Delete any IPV6 entries entirely by moving the cursor to the I on the left and pressing Del .
  • ONBOOT - Change no to yes

Step 10 Enter a new IP category.

  • For example: to use "192.168.2.23" as your IP address, you'd type in IPADDR=192.168.2.23 and press ↵ Enter .
  • Type in PREFIX=24 and press ↵ Enter . You can also enter NETMASK=255.255.255.0 here.
  • Type in GATEWAY=192.168.2.1 and press ↵ Enter . Substitute your preferred gateway address if different.

Step 12 Save and exit the file.

Expert Q&A

Video . by using this service, some information may be shared with youtube..

  • Some very specific Linux distributions will require you to go through a different process to assign an IP address. To see your specific distribution's specifications, check online. Thanks Helpful 0 Not Helpful 0

how to assign ip address manually in linux

  • Don't forget to switch back to the regular (non-root) user account when you're done. Thanks Helpful 1 Not Helpful 1

You Might Also Like

Set up a Network in Ubuntu

  • ↑ https://danielmiessler.com/study/set_ip/
  • ↑ https://www.youtube.com/watch?v=oQd5eG9BZXE&t=

About This Article

Jack Lloyd

  • Send fan mail to authors

Reader Success Stories

Buddy HaDagi

Buddy HaDagi

Jan 27, 2017

Is this article up to date?

Buddy HaDagi

Dmitry Ugay

Oct 10, 2017

Am I a Narcissist or an Empath Quiz

Featured Articles

Ask Better Questions

Trending Articles

Everything You Need to Know to Rock the Corporate Goth Aesthetic

Watch Articles

Cook Fresh Cauliflower

  • Terms of Use
  • Privacy Policy
  • Do Not Sell or Share My Info
  • Not Selling Info

wikiHow Tech Help Pro:

Level up your tech skills and stay ahead of the curve

It's FOSS

How to Assign Static IP Address on Ubuntu Linux

Dimitrios

Brief: In this tutorial, you’ll learn how to assign static IP address on Ubuntu and other Linux distributions. Both command line and GUI methods have been discussed.

IP addresses on Linux Systems in most cases are assigned by Dynamic Host Configuration Protocol (DHCP) servers. IP addresses assigned this way are dynamic which means that the IP address might change when you restart your Ubuntu system . It’s not necessary but it may happen.

Dynamic IP is not an issue for normal desktop Linux users in most cases . It could become an issue if you have employed some special kind of networking between your computers.

For example, you can share your keyboard and mouse between Ubuntu and Raspberry Pi . The configuration uses IP addresses of both system. If the IP address changes dynamically, then your setup won’t work.

Another use case is with servers or remotely administered desktops. It is easier to set static addresses on those systems for connection stability and consistency between the users and applications.

In this tutorial, I’ll show you how to set up static IP address on Ubuntu based Linux distributions. Let me show you the command line way first and then I’ll show the graphical way of doing it on desktop.

Method 1: Assign static IP in Ubuntu using command line

Static IP set up Ubuntu

Note for desktop users : Use static IP only when you need it. Automatic IP saves you a lot of headache in handling network configuration.

Step 1: Get the name of network interface and the default gateway

The first thing you need to know is the name of the network interface for which you have to set up the static IP.

You can either use ip command or the network manager CLI like this:

In my case, it shows my Ethernet (wired) network is called enp0s25:

Next, you should note the default gateway IP using the Linux command ip route :

As you can guess, the default gateway is 192.168.31.1 for me.

Step 2: Locate Netplan configuration

Ubuntu 18.04 LTS and later versions use Netplan for managing the network configuration. Netplan configuration are driven by .yaml files located in /etc/netplan directory.

By default, you should see a .yaml file named something like 01-network-manager-all.yaml, 50-cloud-init.yaml, 01-netcfg.yaml.

Whatever maybe the name, its content should look like this:

You need to edit this file for using static IP.

Step 3: Edit Netplan configuration for assigning static IP

Just for the sake of it, make a backup of your yaml file.

Please make sure to use the correct yaml file name in the commands from here onward.

Use nano editor with sudo to open the yaml file like this:

Please note that yaml files use spaces for indentation . If you use tab or incorrect indention, your changes won’t be saved.

You should edit the file and make it look like this by providing the actual details of your IP address, gateway, interface name etc.

In the above file, I have set the static IP to 192.168.31.16.

Save the file and apply the changes with this command:

You can verify it by displaying your ip address in the terminal with ‘ip a’ command.

If you don’t want to use the static IP address anymore, you can revert easily.

If you have backed up the original yaml file, you can delete the new one and use the backup one.

Otherwise, you can change the yaml file again and make it look like this:

Method 2: Switch to static IP address in Ubuntu graphically

If you are on desktop, using the graphical method is easier and faster.

Go to the settings and look for network settings. Click the gear symbol adjacent to your network connection.

Assign Static IP address in Ubuntu Linux

Next, you should go to the IPv4 tab. Under the IPv4 Method section, click on Manual.

In the Addresses section, enter the IP static IP address you want, netmask is usually 24 and you already know your gateway IP with the ip route command.

You may also change the DNS server if you want. You can keep Routes section to Automatic.

Assigning static IP in Ubuntu Linux

Once everything is done, click on Apply button. See, how easy it is to set a static IP address graphically.

If you haven’t read my previous article on how to change MAC Address , you may want to read in conjunction with this one.

More networking related articles will be rolling out, let me know your thoughts at the comments below and stay connected to our social media.

Dimitrios is an MSc Mechanical Engineer but a Linux enthusiast in heart. His machines are powered by Arch Linux but curiosity drives him to constantly test other distros. Challenge is part of his per

Meet DebianDog - Puppy sized Debian Linux

Reduce computer eye strain with this nifty tool in linux, install open source dj software mixxx version 2.0 in ubuntu, install adobe lightroom alternative rawtherapee in ubuntu linux, complete guide to installing linux on chromebook, become a better linux user.

With the FOSS Weekly Newsletter, you learn useful Linux tips, discover applications, explore new distros and stay updated with the latest from Linux world

It's FOSS

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to It's FOSS.

Your link has expired.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.

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

How to configure IP address in Linux

An IP address is the software address of the computer. Two computers can communicate only if they have IP addresses. There are two ways to configure an IP address on Linux: temporary and permanent. A temporary IP address works only in the current login session. Linux stores it in the RAM and removes it when you log out from the current session. A permanent IP address works until a service or you manually update or change it. Linux stores it in a configuration file.

Setting a temporary IP address

To set a temporary IP address, we use the 'ip addr' command. This command adds the new IP address to the specified interface. It does not remove or update the existing IP address. It appends the current IP configuration.

Without any argument, it displays the IP configurations of all network devices.

To view the IP configuration of a particular device, specify the name of the interface as an argument after the show option. The following command displays the IP configuration of the ens160 interface.

To use this command to add a temporary IP address, we need to use the 'add' and 'dev' options with the command.

Specify the IP address with the subnet mask after the add option and the name of the interface after the dev option.

The following command adds the IP address 192.168.1.10/24 to the ens160 interface.

To verify the new IP address, you can check the IP configuration of the device again.

The following image shows the above exercise.

ip addr command

To learn more about the 'ip addr' command, you can check the following tutorial.

Linux ip address Command Usages and Examples

Setting a permanent IP address

There are four methods to configure a permanent IP address. These methods are: -

  • Changing the configuration file
  • Using the nmcli command
  • Using the nmtui utility
  • Using the nn-connection-editor tool

Let's discuss each method in detail.

Changing IP addresses in configuration files

Linux uses a configuration file for each interface to store its configuration. It stores all configuration files in /etc/sysconfig/network-scripts directory. For the naming convention of interface configuration files, it uses the 'ifcfg' prefix. After this prefix, it uses the name of the network card. For example, if the interface's name is ens160 , it will store its configuration in the ifcfg- ens160 file.

network configuration file

To configure a new IP address or change existing IP addresses, we use the IPADDR directive in this file. You can use any text editor to edit or update this file.

The following image shows how to change the existing IP address by editing the configuration file.

changing configuration files

Linux reads this file only when the interface starts. It does not actively monitor this file. If you change this file, you need to restart the interface to force Linux to reread the configuration file.

To force Linux to reread this file, you can use the ifdown and ifup commands. Specify the interface name as the argument with these commands.

restart interface to update the ip address

Using the nmcli command to configure IP addresses

If you do not want to edit the configuration file directly, you can use NetworkManager's tools. NetworkManager is the default network management service on Linux. It provides three tools for network configuration management. These tools are nmcli, nmtui, and nm-connection-editor.

NetworkManager uses the term 'connection' to refer to a network configuration file. It allows us to create multiple connections (configuration files) for the same interface. Multiple connections allow us to connect different networks without changing the IP configuration. For example, if you use your laptop at home and office, you can create two connections for your wireless interface: one for the home and another for the office. NetworkManager will automatically select the connection based on your location. If you use the laptop at the home, it will use the home connection, or if you use the laptop at the office, it will use the office connection.

To learn more about the NetworkManager, you can check the following tutorial.

Understanding Linux Network Manager Fundamental

Use the following command to list all connections (configuration files) of the interface.

The modify option allows us to modify all parameters of the connection. We can use this option to update the IP address. The following command sets the IP address to 192.168.1.100/24 .

After updating the IP address, use the following commands to restart the connection.

Now, check the IP address again.

using nmcli command to configure ip address

To learn more about the nmcli command, you check the following tutorial.

The nmcli command on Linux Examples and Usages

Using the nmtui utility to update IP addresses

The nmtui is a curses-based utility. It allows us to manage interfaces. The following command starts it.

nmtui command

Select the "Edit a connection" option and press the Enter key.

edit a connection

Select the NIC from the left pane, select the Edit option from the right pane, and press the Enter key.

select nic

Select the Automatic option from the IPv4 configuration option and press the Enter key.

automatic ip dhcp option

To obtain IP configuration from the DHCP Server, select the Automatic option. To set the IP configuration manually, use the Manual option.

dhcp option

Select the Show option and press the Enter key. Use the Tab key to switch between options.

show option

Set the IP address/subnet mask, Gateway IP address, and DNS Server IP address.

set ip adddress

Select the OK option and press the Enter key to accept the change.

confirm change

Select the Quit option and press the Enter key.

quit nmtui

When we exit the nmtui utility, it automatically applies the changes and updates the associated network configuration files. In the above example, since we assigned IP configuration to the eno16777736 interface, the nmtui utility updates the file /etc/sysconfig/network-scripts/ ifcfg-eno16777736 .

An interface restart is required to apply the new configuration. To restart the interface, use the ifdown-[ NIC ] and ifup-[ NIC ] commands.

verifing ip address update

To learn more about the nmtui utility, you check the following tutorial.

The nmtui Command and Utility on Linux

Using the nm-connection-editor graphical utility

The nm-connection-editor is a desktop tool. It works only on desktop. Open a terminal, and run the following command to start it.

From the opened window, select the appropriate NIC and click the Edit option

nm-connection-editor

Now use the following steps to add/update/edit IP configuration on the selected interface.

  • Switch to the IPv4 Settings.
  • Select the Manual option from the Method drop-down menu.
  • Click the Add button and configure IP addresses in respective fields.
  • Click the Save button.
  • Click the Close button on the main screen.

edit a connection

Restart the interface and verify the new IP configuration.

verify update

To learn more about the nm-connection-editor tool, you check the following tutorial.

The nm-connection-editor command on Linux

That's all for this tutorial. In this tutorial, we learned how to configure new IP addresses and manage existing IP addresses on Linux.

By ComputerNetworkingNotes Updated on 2023-10-06 02:00:02 IST

ComputerNetworkingNotes Linux Tutorials How to configure IP address in Linux

We do not accept any kind of Guest Post. Except Guest post submission, for any other query (such as adverting opportunity, product advertisement, feedback, suggestion, error reporting and technical issue) or simply just say to hello mail us [email protected]

how to assign ip address manually in linux

How-To Geek

How to use the ip command on linux.

It is time to break up with ifconfig.

Quick Links

How the ip command works, using ip with addresses, display only ipv4 or ipv6 addresses, display information for a single interface, adding an ip address, deleting an ip address, using ip with network interfaces, starting and stopping links, using ip with routes, display information for a single route, adding a route, taken route, not taken root, key takeaways.

  • The ip command has replaced the older ifconfig command in modern versions of Linux.
  • The ip command allows you to configure IP addresses, network interfaces, and routing rules on the fly without rebooting.
  • Run "ip addr" in the Terminal to get your PC's local IP address.

You can configure IP addresses, network interfaces, and routing rules on the fly with the Linux ip command. We'll show you how you can use this modern replacement of the classic (and now deprecated) ifconfig .

With the ip command, you can adjust the way a Linux computer handles IP addresses, network interfaces controllers (NICs), and routing rules . The changes also take immediate effect — you don't have to reboot. The ip command can do a lot more than this, but we'll focus on the most common uses in this article.

The ip command has many subcommands, each of which works on a type of object, such as IP addresses and routes. There are, in turn, many options for each of these objects. It's this richness of functionality that gives the ip command the granularity you need to perform what can be delicate tasks. This isn't ax work — it calls for a set of scalpels.

We'll look at the following objects:

  • Address : IP addresses and ranges.
  • Link : Network interfaces, such as wired connections and Wi-Fi adapters.
  • Route : The rules that manage the routing of traffic sent to addresses via interfaces ( links ).

Obviously, you first have to know the settings you're dealing with. To discover which IP addresses your computer has, you use the ip command with the object address . The default action is show , which lists the IP addresses. You can also omit show and abbreviate address as "addr" or even "a."

The following commands are all equivalent:

ip address show

ip addr show

ip address show in a terminal window

We see two IP addresses, along with a lot of other information. IP addresses are associated with network interface controllers (NICs). The ip command tries to be helpful and provides a bunch of information about the interface, too.

The first IP address is the (internal) loopback address used to communicate within the computer. The second is the actual (external) IP address the computer has on the local area network (LAN).

Let's break down all the information we received:

  • lo : The network interface name as a string.
  • <LOOPBACK,UP,LOWER_UP>: This is a loopback interface. It's UP , meaning it's operational. The physical networking layer (layer one) is also up.
  • mtu 65536: The maximum transfer unit. This is the size of the largest chunk of data this interface can transmit.
  • qdisc noqueue: A qdisc is a queuing mechanism. It schedules the transmission of packets. There are different queuing techniques called disciplines. The noqueue discipline means "send instantly, don't queue." This is the default qdisc discipline for virtual devices, such as the loopback address.
  • state UNKNOWN: This can be DOWN (the network interface is not operational), UNKNOWN (the network interface is operational but nothing is connected), or UP (the network is operational and there is a connection).
  • group default: Interfaces can be grouped logically. The default is to place them all in a group called "default."
  • qlen 1000: The maximum length of the transmission queue.
  • link/loopback: The media access control (MAC) address of the interface.
  • inet 127.0.0.1/8: The IP version 4 address. The part of the address after the forward-slash ( / ) is Classless Inter-Domain Routing notation (CIDR) representing the subnet mask. It indicates how many leading contiguous bits are set to one in the subnet mask. The value of eight means eight bits. Eight bits set to one represents 255 in binary, so the subnet mask is 255.0.0.0.
  • scope host: The IP address scope. This IP address is only valid inside the computer (the "host").
  • lo: The interface with which this IP address is associated.
  • valid_lft: Valid lifetime. For an IP version 4 IP address allocated by Dynamic Host Configuration Protocol (DHCP), this is the length of time the IP address is considered valid and able to make and accept connection requests.
  • preferred_lft: Preferred lifetime. For an IP version 4 IP address allocated by DHCP, this is the amount of time the IP address can be used with no restrictions. This should never be larger than the valid_lft value.
  • inet6 : The IP version 6 address, scope , valid_lft , and preferred_lft .

The physical interface is more interesting, as we'll show below:

  • enp0s3: The network interface name as a string. The "en" stands for ethernet, "p0" is the bus number of the ethernet card, and "s3" is the slot number.
  • <BROADCAST,MULTICAST,UP,LOWER_UP>: This interface supports broad- and multicasting , and the interface is UP (operational and connected). The hardware layer of the network (layer one) is also UP .
  • mtu 1500: The maximum transfer unit this interface supports.
  • qdisc fq_codel: The scheduler is using a discipline called "Fair Queuing, Controlled Delay." It's designed to provide a fair share of the bandwidth to all the traffic flows that use the queue.
  • state UP: The interface is operational and connected.
  • group default: This interface is in the "default" interface group.
  • link/ether: The MAC address of the interface.
  • inet 192.168.4.26/24: The IP version 4 address. The "/24" tells us there are 24 contiguous leading bits set to one in the subnet mask. That's three groups of eight bits. An eight-bit binary number equates to 255; therefore, the subnet mask is 255.255.255.0.
  • brd 192.168.4.255: The broadcast address for this subnet.
  • scope global: The IP address is valid everywhere on this network.
  • dynamic: The IP address is lost when the interface goes down.
  • noprefixroute: Do not create a route in the route table when this IP address is added. Someone has to add a route manually if he wants to use one with this IP address. Likewise, if this IP address is deleted, don't look for a route to delete.
  • enp0s3: The interface with which this IP address is associated.
  • valid_lft: Valid lifetime. The time the IP address will be considered valid; 86,240 seconds is 23 hours and 57 minutes.
  • preferred_lft: Preferred lifetime. The time the IP address will operate without any restrictions.
  • inet6: The IP version 6 address, scope , valid_lft , and preferred_lft .

If you want to limit the output to the IP version 4 addresses, you can use the -4 option, as follows:

ip -4 addr in a terminal window

If you want to limit the output to the IP version 6 addresses, you can use the -6 option, as follows:

ip -6 addr in a terminal window

If you want to see the IP address information for a single interface, you can use the show and dev options, and name the interface, as shown below:

ip addr show dev lo

ip addr show dev enp0s3

ip addr show dev lo in a terminal window

You can also use the -4 or -6 flag to further refine the output so you only see that in which you're interested.

If you want to see the IP version 4 information related to the addresses on interface enp0s3 , type the following command:

ip -4 addr show dev enp0s3

ip -4 addr show dev enp0s3 in a terminal window

You can use the add and dev options to add an IP address to an interface. You just have to tell the ip command which IP address to add, and to which interface to add it.

We're going to add the IP address 192.168.4.44 to the enp0s3 interface. We also have to provide the CIDR notation for the subnet mask.

We type the following:

sudo ip addr add 192.168.4.44/24 dev enp0s3

sudo ip addr add 192.168.4.44/24 dev enp0s3 in a terminal window

We type the following to take another look at the IP version 4 IP addresses on this interface:

ip -4 addr show dev enp0s3 in a terminal window

The new IP address is present on this network interface. We jump on another computer and use the following command to see if we can ping the new IP address :

ping 192.168.4.44

ping 192.168.4.44  in a terminal window

The IP address responds and sends back acknowledgments to the pings. Our new IP address is up and running after one simple ip command.

To delete an IP address, the command is almost the same as the one to add one, except you replace add with del , as shown below:

sudo ip addr del 192.168.4.44/24 dev enp0s3

sudo ip addr del 192.168.4.44/24 dev enp0s3 in a terminal window

If we type the following to check, we see the new IP address has been deleted:

ip -4 addr show dev enp0s3 in a terminal window

You use the link object to inspect and work with network interfaces. Type the following command to see the interfaces installed on your computer:

ip link show

ip link show: in a terminal window

To see a single network interface, just add its name to the command, as shown below:

ip link show enp0s3

ip link show enp0s3 in a terminal window

You can use the set option with either up or down to stop or start a network interface option. You also have to use sudo , as shown below:

sudo ip link set enp0s3 down

sudo ip link set enp0s3 down in a terminal window

We type the following to take a look at the network interface:

ip link show enp0s3 in a terminal window

The state of the network interface is DOWN . We can use the up option to restart a network interface, as shown below:

sudo ip link set enp0s3 up

sudo ip link set enp0s3 up in a terminal window

We type the following to do another quick check on the state of the network interface:

ip link show enp0s3 in a terminal window

The network interface was restarted, and the state is shown as UP .

With the route object, you can inspect and manipulate routes. Routes define to where network traffic to different IP addresses is forwarded, and through which network interface.

If the destination computer or device shares a network with the sending computer, the sending computer can forward the packet directly to it.

However, if the destination device is not directly connected, the sending computer forwards the packet to the default router. The router then decides where to send the packet.

To see the routes defined on your computer, type the following command:

ip route in a terminal window

Let's take a look at the info we received:

  • default: The default rule. This route is used if none of the other rules match what's being sent.
  • via 192.168.4.1: Routes the packets via the device at 192.168.4.1. This is the IP address of the default router on this network.
  • dev enp0s3: Use this network interface to send the packets to the router.
  • proto dhcp: The routing protocol identifier. DHCP means the routes will be determined dynamically.
  • metric 100: An indication of the preference of the route compared to others. Routes with lower metrics are preferentially used over those with higher metrics. You can use this to give preference to a wired network interface over a Wi-Fi one.

The second route governs traffic to the IP range of 169.254.0.0/16. This is a zero-configuration network , which means it tries to self-configure for intranet communication. However, you can't use it to send packets outside the immediate network.

The principle behind zero-configuration networks is they don't rely on DHCP and other services being present and active. They only need to see TCP/IP in order to self-identify to each of the other devices on the network.

Let's take a look:

  • 169.254.0.0/16: The range of IP addresses this routing rule governs. If the computer communicates on this IP range, this rule cuts in.
  • dev enp0s3: The network interface the traffic governed by this route will use.
  • scope link : The scope is link , which means the scope is limited to the network to which this computer is directly connected.
  • metric 1000 : This is a high metric and isn't a preferred route.

The third route governs traffic to the IP address range of 192.168.4.0/24. This is the IP address range of the local network to which this computer is connected. It's for communication across, but within, that network.

Let's break it down:

  • 192.168.4.1/24: The range of IP addresses this routing rule governs. If the computer communicates within this IP range, this rule triggers and controls the packet routing.
  • dev enp0s3: The interface through which this route will send packets.
  • proto kernel: The route created by the kernel during auto-configuration.
  • scope link: The scope is link , which means the scope is limited to the immediate network to which this computer is connected.
  • src 192.168.4.26: The IP address from which packets sent by this route originate.
  • metric 100: This low metric indicates a preferred route.

If you want to focus on the details of a particular route, you can add the list option and IP address range of the route to the command as follows:

ip route list 192.168.4.0/24

ip route list 192.168.4.0/24 in a terminal window

We just added a new network interface card to this computer. We type the following and see it's showing up as enp0s8 :

ip link show in a terminal window

We'll add a new route to the computer to use this new interface. First, we type the following to associate an IP address with the interface:

sudo ip addr add 192.168.121.1/24 dev enp0s8

sudo ip addr add 192.168.121.1/24 dev enp0s8 in a terminal window

A default route using the existing IP address is added to the new interface. We use the delete option, as shown below, to delete the route and provide its details:

sudo ip route delete default via 192.168.4.1 dev enp0s8

sudo ip route delete default via 192.168.4.1 dev enp0s8 in a terminal window

We'll now use the add option to add our new route. The new interface will handle network traffic in the 192.168.121.0/24 IP address range. We'll give it a metric of 100; because it will be the only route handling this traffic, the metric is pretty much academic.

sudo ip route add 192.168.121.0/24 dev enp0s8 metric 100

sudo ip route add 192.168.121.0/24 dev enp0s8 metric 100 in a terminal window

Now, we type the following to see what it gives us:

ip route in a terminal window

Our new route is now in place. However, we still have the 192.168.4.0/24 route that points to interface enp0s8 — we type the following to remove it:

sudo ip route delete 192.168.4.0/24 dev enp0s8

sudo ip route delete 192.168.4.0/24 dev enp0s8 in a terminal window

We should now have a new route that points all traffic destined for IP range 192.168.121.0/24 through interface enp0s8 . It should also be the only route that uses our new interface.

We type the following to confirm:

ip route in a terminal window

The great thing about these commands is they're not permanent. If you want to clear them, just reboot your system. This means you can experiment with them until they work the way you want. And it's a very good thing if you make a terrible mess of your system — a simple reboot will restore order.

On the other hand, if you want the changes to be permanent, you have to do some more work. Exactly what varies depending on the distribution family, but they all involve changing config files.

This way, though, you can test-drive commands before you make anything permanent.

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 do I set a static IP in Ubuntu 20.04.3 LTS?

I'm trying to set up a lab computer as a ssh server following this guide . One of the steps is setting up a static IP address. So, I was glad to find this answer . Following it, I created /etc/netplan/50-cloud-init.yaml file, pasted

where my_ethernet_num == enp9s0 . Buuuut, after this ip a showed no ip address for the Ethernet:

and sudo lshw -C network yielded *-network DISABLED . Then I tried to use that guide (section 'Static IP Address Assignment'). I created /etc/netplan/99_config.yaml , pasted the necessary code, run sudo netplan apply . Nothing changed except that I STOPPED SEEING wired connections in network settings... I tried the answer from here , and the 'Wired' section returned. But I can't change anything (for example, I can't pick 'Manual' option).

Screenshot

So, the questions are: how can I return the ability of changing it (in order to follow one more guide ), or is there any other solution that will succeed in setting static ip address?...

--EDIT from 12/05/2021--

Here are all of my .yaml files showed by ls -al /etc/netplan :

01-network-manager-all.yaml:

50-cloud-init.yaml:

99_config.yaml:

  • network-manager

Serg's user avatar

  • 1 Probably you should delete/revert all changes that you have made, to get back to the original configuration. Then just use "Manual" option from the GUI. No need to mess with configuration files manually. –  raj Nov 29, 2021 at 12:44
  • @raj, thank you for your comment! If I only knew how to revert all the changes... By the way, after rebooting, I suddenly found out that I can make changes to the settings! So, I'll try the the GUI option and write about results :) –  TopCoder2000 Nov 29, 2021 at 13:31
  • Why does your .yaml use enp0s3, when your interface is enp9s0? Are you using a Server or Desktop installation? –  heynnema Nov 29, 2021 at 23:37
  • @heynnema, because it was in the answer for 'How do I set a static IP in Ubuntu?' . As we can see, enp0s25 is used in the question, but then enp0s3 is used in the answer, so I thought that it always must be enp0s25. > Are you using a Server or Desktop installation? I would like to use a Desktop installation, but I don't know concretely which one I was using... Is there any difference? I tried to follow Desktop installation but I could get confused. –  TopCoder2000 Dec 1, 2021 at 19:31
  • @TopCoder2000 Your network can't possibly be working with enp0s3 in the .yaml file. It needs to be enp9s0. But if you're using a Desktop installation, then your .yaml is all wrong anyway. A Desktop installation has a GUI, a Server installation is CLI only. Also, your self-accepted answer doesn't really make a lot of sense. –  heynnema Dec 1, 2021 at 19:37

Pick ONE of the following two configurations...

Server installation with static IP...

Delete /etc/netplan/01-network-manager-all.yaml

Delete /etc/netplan/50-cloud-init.yaml

Edit /etc/netplan/99_config.yaml to look EXACTLY like this...

Note : regarding 192.168.0.116, make sure this address is outside of the DHCP range set in your router, and is not already used elsewhere.

Note : For DNS nameservers, settle on servers from one source... Google, Cloudflare, OpenDNS, etc. (3 max).

sudo netplan generate

sudo netplan apply

Desktop installation with static IP...

Delete /etc/netplan/99_config.yaml

Edit /etc/netplan/01-network-manager-all.yaml to look EXACTLY like this...

Note : Use the NetworkManager GUI to setup your static IP for "Wired Connection".

Note : See https://netplan.io/examples/ for examples and design info about netplan.

heynnema's user avatar

  • Thank you for your answer and netplan examples! Now ip a shows correct output. But how do I setup a static IP with NetworkManager GUI? –  TopCoder2000 Dec 6, 2021 at 18:28
  • @TopCoder2000 Firstly, you can't use both parts of my answer at the same time. It's part 1 or part 2. If you're using part 2, then my answer says "Use the NetworkManager GUI to setup your static IP for "Wired Connection"" . See the IPv4 tab. Click on the manual button. Fill in the address, mask, gateway, and DNS servers, and turn off DNS Auto. –  heynnema Dec 6, 2021 at 18:44
  • yes, I remember! I'll accept it as soon as I don't have any questions :) Yes, I'm using the second option. But you also wrote yesterday that 'Static IPs should be set to be outside of the DHCP range set in the router'. But how do I know that set? For example, the second answer from here says that we have to check DHCP server configuration... –  TopCoder2000 Dec 7, 2021 at 6:51
  • @TopCoder2000 You must log into the admin page of your router and find the DHCP server settings. For your computer's static IP, you'll need to pick an address outside of the DHCP server's range of addresses. –  heynnema Dec 7, 2021 at 15:01
  • Ah, good! Thanks! –  TopCoder2000 Dec 9, 2021 at 7:07

You must log in to answer this question.

Not the answer you're looking for browse other questions tagged networking 20.04 network-manager ethernet ..

  • The Overflow Blog
  • The creator of PyTorch Lightning on the AI hype cycle
  • Exploring the inclusive tech revolution sponsored post
  • 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

  • Could a deadly fire start within a spacesuit?
  • p-values from CIs?
  • A short story from the 1960s where Martian (?) authorities wear purple togas
  • Is Intentional Bankruptcy Illegal?
  • How to find unspoofed MAC address of NIC
  • Finite group where all the elements are commutators
  • Nations' names for themselves with foreign etymologies
  • What is the origin of the "No Symbol"?
  • Tu-144 vs Concorde: which one of the two carried passengers first?
  • Sci-fi book with humanoid aliens disabling modern starships, dross, and a picture of Tobruk being destroyed
  • Claim in article about why insects are attracted to light
  • Which airport has the longest minimum connection time?
  • Found significant flaw in my arXiv version paper: what should I do?
  • LM3914 Bar/Dot display driver
  • Can legal action reasonably be taken against someone unsavory for endorsing your product/company?
  • How to foster a positive relationship with my supervisor while balancing experience disparities in a PhD program?
  • Is 龘 a contender for "character with the most strokes"?
  • Motivation and physical interpretation of the Laplace transform
  • Can I reseal a pipe thread that's leaking?
  • Why does my hot water arrive at point of use slowly after water heater replacement?
  • Are contactless cards more secure than "insert required" cards?
  • How to find out what my MacBook Air was doing for 3 hours in my backpack (hot and at 8% battery) when I thought it was sleeping?
  • Entering Greece from Bulgaria on dirt roads
  • In the U.S. academia, why do many institutes never send rejection letters for postdoc positions (to save the hassling of inquiries from applicants)?

how to assign ip address manually in linux

Tecmint: Linux Howtos, Tutorials & Guides

A Beginner’s Guide to Configuring IPv4 and IPv6 Addresses in Linux

As a systems administrator, you will occasionally be tasked with configuring or setting up the IP addresses of your servers to keep up with changing network requirements. As such, having fundamental skills in assigning IP addresses and configuring hostname resolution is crucial in ensuring that servers conform with the network topology.

Table of Contents

What is an IP Address?

An IP address, which stands for Internet Protocol , is a unique numerical identifier or address that identifies a device in a TCP/IP network. This could be a local area network ( LAN ) or the internet.

The IP address allows communication between devices in a network such as servers, routers, switches, and any other network device connected to the network.

Difference Between IPv4 vs IPv6

An IP address can be broadly categorized into two: IPv4 and IPv6 .

IPv4 Address

An IPv4 (IP version 4) address is a 32-bit number that is split into four octets, with each octet separated by a period or a decimal point. This is usually referred to as dotted-decimal format.

Each octet is made up of 8 bits which collectively represent a byte. An IPv4 address can further be divided into two sections. The first part represents the network section, while the remaining part defines the host section.

Network Section

The network section of an IP address identifies the class the IP address belongs. There are 3 distinct classes of IP addresses used in computer networks: Class A , Class B , and Class C .

What is IPv4 Class A

In Class A type of network, the first 8 bits (octet) define the network, while the remaining 24 bits are reserved for the hosts in the network.

  • The Public IP addresses range from 1.0.0.0 to 127.0.0.0.
  • The Private IP addresses range from 10.0.0.0 to 10.255.255.255.

Addresses 127.0.0.0 to 127.255.255.255 are reserved for loopback and other diagnostic purposes, and hence are not allocated to hosts in a network.

The default subnet mask of class A is 255.0.0.0 with the first 8 bits used to identify the network. The remaining 24 bits are designated for hosts. This class is used in networks that command a large number of hosts. It yields a maximum of 16,777,214 hosts and 126 networks.

What is IPv4 Class B

In Class B , the first two octets, or 16 bits are used to define the network ID.

  • The Public IP addresses range from 128.0.0.0 to 191.255.0.0.
  • The private IP range is from 172.16.0.0 to 172.31.255.255.

The default subnet mask is 255.255.0.0 where the first 16 bits define the network ID. This class of IP is typically used for medium-large networks and yields 65,534 hosts per network with a total of 16,382 networks.

What is IPv4 Class C

This class of IP is mostly used for small networks such as a home network or a small office or business.

In a Class C network, the first two network bits are set to 1 while the third is set to 0, i.e. 1 1 0. The remaining 21 bits of the first three octets define the network ID, and the last octet defines the number of hosts.

As such, Class C IP address produces the highest number of networks amounting to 2,097,150 , and the least number of hosts per network which is 254 hosts.

  • The public IP addresses range from 192.0.0.0 to 223.255.255.0.
  • The private IP range is from 192.168.0.0 to 192.168.255.255.

The subnet mast is 255.255.255.0.

Host Portion

The remaining section of the IP address is the host portion, which is the section that determines the number of hosts in a network. This part uniquely identifies a host in a network. All hosts in the same network share the same network portion.

For example, the following host IP addresses belong to the same network.

IPv6 Address

An IPv6 address is an alphanumeric address that is 128 bits long, arranged in eight groups, each of which contains 16 bits.

Like an IPv4 address, it is split into two parts: the network and host component. The network part makes up the first 64 bits and is used for routing purposes. The remaining 64 bits identified the address on the nodes.

Below is an example of a full IPv6 address.

This can be further shortened as follows.

IPv6 was developed as a solution to the imminent exhaustion of addresses in IPv4. As you know by now, IPv6 contains 128 bits which is four times more than the number of bits in IPv4 (32 bits). These extra bits provide more addressing space which will supplement the address provided by IPV4.

Although IPv6 is set to take over from IPv4 addressing in the near future, many organizations and ISPs still use and largely rely on IPv4 addresses.

In fact, you’ll hardly ever need to configure an IPv6 on your device to provide connectivity. The fact is, it will take a while before IPv6 replaces or phases out IPv4.

Dynamic (DHCP) and Static IP Configuration

IP allocation on client machines or any end-point devices connected to a network is done either using the DHCP protocol or manual configuration where IP addresses are statically allocated.

DHCP IP Address

DHCP ( Dynamic Host Configuration Protocol ) is a client-server protocol that dynamically allocates IP addresses to client systems on a network. The DHCP server, which in most cases is a router, contains a pool of addresses that it leases out to client devices on a network for a certain period of time. Thus, it simplifies and makes the configuration of IP addresses more efficient. Once the lease time lapses, the client acquires a new IP address.

Most systems, by default, are configured to obtain an IP automatically using the DHCP protocol. This eliminates the possibility of IP conflicts in a network where two devices share the same IP address.

The drawback of DHCP is that the IP addresses change once the lease expires. If a server is set to acquire an IP via DHCP, this will lead to connectivity issues once the IP address changes. And this is where static IP configuration comes in.

Static IP Address

In static IP configuration, IP addresses are manually configured on a client system, especially servers. Unlike dynamically allocated addresses, statically configured IP addresses remain the same and do not change.

However, the static configuration requires a lot of work from network admins. They have to manually log in and configure the static IP along with other details such as subnet mask, DNS servers, and gateway IP. In addition, they need to keep track of all the client systems with static IP addresses.

In this tutorial, we will focus on how to statically configure IP addresses on various systems.

How to Configure IPv4 Networking in Linux

In this section, we will shift focus and see how to configure an IPv4 address on Linux. We will look at how you can do this on Debian , Ubuntu , and later on RHEL and Red Hat distributions .

Configure IPv4 Address on Debian

To get started, it’s always a good idea to check your current IP configuration of the Linux system.

This displays the IP addresses and status of your network interfaces. From the output, we have two interfaces.

Find IP Address in Linux

The first one is the lo interface which is a loopback address reserved for testing purposes only and is always designated the address 127.0.0.1 . The loopback address is not associated with any physical network interface.

The second interface is enp0s3 (this might be different in your case). This is the active network interface that maps to the physical network card on the server.

Its IPv4 address is denoted by the inet parameter, and in this case is 192.168.2.113 , which is assigned via the DHCP protocol.

In Debian, the network configuration is contained in the /etc/network/interfaces file. You can view it using the nano or vim editor .

Debian Network Configuration

To configure a static IPv4 address, remove or comment the allow-hotplug and dhcp lines, Then add the following configuration.

In this configuration, 192.168.2.150 will be our new IPv4 address with a netmask or network subnet of 255.255.255.0. The default gateway, which also happens to be the router’s IP, is 192.168.2.1 while the DNS nameservers are 192.168.2.1 and 8.8.8.8 .

Set Static IP Address in Debian

Save the changes and exit the file.

To apply the changes, restart the networking service.

Then confirm no errors were encountered

Start Network in Debian

To confirm that the server has acquired the new IP, run the following command:

The output below confirms that we have successfully configured the static IPv4 address.

Find IP Address in Debian

Configure IPv4 Address on Ubuntu

In Ubuntu 18.04 and later versions, Netplan is the default network configuration tool, which enables easy configuration of network settings via YAML files. According to Canonical, netplan processes the YAML files and generates network configurations for systemd-network or NetworkManager .

The network configuration file for modern Ubuntu distributions is located in the /etc/netplan directory. For the desktop system, the configuration file in this directory is 01-network-manager-all.yaml . For servers, the file is /etc/netplan/01-netcfg.yaml .

Once again, let’s check our current IP address which is auto-assigned by DHCP.

Our current IP is 192.168.2.106 . We will set this to 192.168.2.180 .

Check IP Address in Ubuntu

To assign an IPv4 address, we will open the network configuration file.

By default, the following lines automatically set the system to use DHCP for IP assignment.

Ubuntu Network Configuration

Add the following lines to assign a static IP.

Set Static IP Address in Ubuntu

Let us break down the parameters used:

  • enp0s3 – is the name of the network interface.
  • addresses – This configures the IPv4 address on the interface. This is followed by the CIDR, in this case,/24 which implies a network subnet of 255.255.255.0.
  • nameservers – This specifies the DNS servers to be used. In this case, we are using 8.8.8.8 and 8.8.4.4 which are Google’s name servers.
  • routes – This sets the gateway on your system.

Remember to replace the interface name and IP configuration to match your network environment.

Save the changes and exit.

To apply the changes made, run the following command:

Once again, verify if the changes have been reflected as shown.

Find IP Address in Ubuntu

Configure IPv4 Address on RHEL

In Red Hat distributions , the nmcli (NetworkManager Command Line Interface) command-line tool is one of the most preferred ways of configuring an IPv4 address. It does so using the NetworkManager service.

To view the network interface name attached to your system, execute the command:

To display the active connection, run the command:

Find Network Interface in RHEL

In RHEL 9 and other Red Hat distributions based on RHEL, the network configuration file resides in the /etc/sysconfig/network-scripts directory. In our case, the configuration file is ifcfg-enp0s3 .

We will assign a static IPv4 address on the interface ‘ enp0s3 ‘ as shown:

To do so, we will run the following commands:

Set Static IP Address in RHEL

The commands save the changes inside the associated network configuration file. You can view the file using your preferred text editor

RHEL Network Configuration

To confirm the new IP address, run the following command

You can also run the nmcli command without any command-line options and the active interface will be displayed at the top.

Find IP Address in RHEL

How to Configure Hostname in Linux

A well-configured system should be able to resolve its hostname or domain name to the IP address configured. Usually, the hostname and IP address mapping is done in the /etc/hosts file.

To configure hostname resolution, add a host’s entry to the /etc/hosts file. This entry includes the host’s IP address and the hostname as shown.

Be sure to update the /etc/hosts file on every Linux system that you intend to connect to the system on the same local network.

Once done, you can successfully ping the hostname of the Linux machine.

Ping Hostname in Linux

In this tutorial, we have covered IPv4 and IPv6 IP addresses and explored how you can configure IPv4 networking and hostname resolution on Linux.

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

Compile Kernel in Debian

How to Install and Compile Kernel in Debian

Proxmox Create Container

How to Create Containers in Proxmox

Best Debian-based Linux Distributions

The 12 Best Debian-based Linux Distributions

Create VM on Proxmox

How to Create a Virtual Machine in Proxmox

Install TFTP Server on Ubuntu

How to Install and Configure TFTP Server on Ubuntu and Debian

Install Proxmox VE Debian

How to Install Proxmox (Server Virtualization) on Debian 12

8 thoughts on “A Beginner’s Guide to Configuring IPv4 and IPv6 Addresses in Linux”

Ah, it is working like this:

I only have to put into an init script.

I face the following situation: The Internet provider has switched to IPv6.

This means the first 4 blocks, e.g., a02:560:4c19:cd00……. are changing time by time.

The Internet router is able to configure “port forwarding” for IPv6. Indeed, it is not port forwarding, but routing to an IPv6 address in my network.

Unfortunately, the Internet router is not able to route the dynamic part of the IPv6 address of my internal server. I can only configure a fix postfix of the IPv6 address:

let it be: …….. 2001:db8:1234:abcd

While the prefix is changing by the internet provider, the postfix I set it to fix.

To make a service from my internal address available to the internet, I must configure the IPv6 address of my server with the dynamic prefix of the router and the fix postfix configured for routing.

Is it possible to configure it?

Clear, it is a bug in my internet router.

Another way, maybe I will try at the weekend, while the server is getting up, I can call via IPv4 DNS to get the current IPv6 address, put it into the configuration, and restart the network stack.

Title says “Configuring IPv4 and IPv6 Addresses”.

What happened to the “ configure IPv6 section ?”

The pool of IPv4 addresses has already been exhausted so we will have to use IPv6 from now on. I may “hardly ever need to configure an IPv6” but, nevertheless, there WILL be times that I will have to configure IPv6.

It would be handy to know how to do the configuration ahead of time unless IPv6 is self-configuring.

@Dragonmouth,

To assign an IPv6 address temporarily to the network interface, run the following command:

Replace <IPv6_ADDRESS> with the desired IPv6 address, <PREFIX_LENGTH> with the appropriate prefix length and <INTERFACE_NAME> should be replaced with the actual interface name.

For example:

To assign an IPv6 address permanently to the network interface, use the following instructions:

1. Open the configuration file for the desired network interface.

The file name will usually be in the format ifcfg-<INTERFACE_NAME> . For example, if the interface name is eth0 , the file would be ifcfg-eth0 .

Add the following lines to the configuration file.

Restart the network service to apply the changes.

You can confirm your IP address by running ip command.

How to configure IPv6 static IP address using Netplan?

To configure an IPv6 address using Netplan, you can follow these steps:

1. Open the Netplan configuration file using a text editor.

Add the following network configuration to configure an IPv6 address.

In the above example, the interface eth0 is configured with the static IPv6 address 2001:db8:1234:abcd::1 with a prefix length of /64 . The IPv6 gateway is set to 2001:db8:1234:abcd::a .

2. Apply the changes by running the following command:

Thank you, it may help users with old Ubuntu versions.

In newer versions, gateway6 is deprecated.

I don’t think the gateway6 parameter is deprecated in the netplan configuration. Any source you have please share…

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.

How to assign static IP address on Ubuntu Linux

Here are the steps to assign an IP address to an Ubuntu Server using the Settings app and Terminal commands.

Avatar for Mauro Huc

On Ubuntu (version 22.04, 21.04, or older releases), it’s possible to assign a static IP address through the Settings interface or the Terminal using commands, and in this guide, you will learn how.

Once you complete the installation of the Ubuntu Server (or client version), the device will receive a network configuration assigned automatically by the Dynamic Host Configuration Protocol (DHCP) server available in the local network. Although this configuration is enough to access the network and internet, it’s a good idea to assign a static network configuration as you probably are setting up the system to serve different services, such as file and print sharing and others.

The reason is that a dynamic configuration can change at any time, and a static network configuration is permanent, meaning that devices in the network will be able to always reach the server with the address.

This guide will teach you the steps to configure a static IP address for your Ubuntu Server installation. You can also use these instructions for the client version of the Linux distro.

Set static IP address configuration on Ubuntu Linux (GUI)

Set static ip address configuration on ubuntu linux (command).

To assign a static IP address on Ubuntu (server or client) through the Settings app, use these steps:

Open Settings .

Click on Network .

Click the Settings button for the “Wired” network interface.

Ubuntu network open settings

Click the IPv4 tab.

Select the Manual option for the “IPv4 Method” setting.

Under the “Addresses” section, confirm the static IP address in the “Address” setting — for example, 10.1.4.201.

Ubuntu assign static IP address

Confirm the subnet mask in the “Netmask” settings — for example, 255.255.255.0.

Confirm the gateway address (usually the router’s IP) in the “Gateway” setting.

Turn off the Automatic toggle switch for the “DNS” setting.

Confirm the DNS address(es) for this static configuration — for example, the router IP address or your preferred DNS address, such as the ones from Google Public DNS, 8.8.8.8, 8.8.4.4 .

(Optional) Click the IPv6 tab.

Select the Disable option in the “IPv6 Method” setting.

Click the Apply button.

(Optional) Turn off and on the Wired toggle switch on the “Network” page if the configuration isn’t working.

Once you complete the steps, the Linux distro will start using the new static network configuration.

To assign a static IP address on Ubuntu Linux (server or client), use these steps:

Open Terminal

Type the following command to determine the network interface name and press Enter :

Ubuntu view IP config command

Type the following command to open the configuration file and press Enter :

Copy and paste the following configuration (changing the TCP/IP settings with your settings):

In the command, change “ens33” for the name of your server network adapter name and “10.1.4.201/24” for the static IP address and subnet mask after the forward slash (/) you want to assign to the Ubuntu Server. For example, the “/24” assigns the “255.255.255.0” address. Also, change “8.8.4.4, 8.8.8.8” for static DNS addresses. The comma (,) is only required when setting up multiple addresses. And change “10.1.4.1” for the default gateway of your network (usually the router IP address).

Ubuntu static IP set commands

Press “Ctrl + O,” “Enter,” and “Ctrl + X” to save the changes and exit the text editor.

Type the following command to apply the new static IP address configuration and press Enter :

(Optional) Type the following command to confirm the static network configuration and press Enter :

Ubuntu confirm IP address

In the command, change “ens33” to the name of the adapter.

After you complete the steps, the static  IP address configuration will apply to the network adapter on Ubuntu (server or client).

  • How to backup config file on TrueNAS
  • How to create Windows Server bootable USB media

Select Your Language

Infrastructure and management.

  • Red Hat Enterprise Linux
  • Red Hat Satellite
  • Red Hat Subscription Management
  • Red Hat Insights
  • Red Hat Ansible Automation Platform

Cloud Computing

  • Red Hat OpenShift
  • Red Hat OpenStack Platform
  • Red Hat OpenShift Container Platform
  • Red Hat OpenShift Data Science
  • Red Hat OpenShift Dedicated
  • Red Hat Advanced Cluster Security for Kubernetes
  • Red Hat Advanced Cluster Management for Kubernetes
  • Red Hat Quay
  • OpenShift Dev Spaces
  • Red Hat OpenShift Service on AWS
  • Red Hat Gluster Storage
  • Red Hat Hyperconverged Infrastructure
  • Red Hat Ceph Storage
  • Red Hat OpenShift Data Foundation
  • Red Hat Runtimes
  • Red Hat JBoss Enterprise Application Platform
  • Red Hat Data Grid
  • Red Hat JBoss Web Server
  • Red Hat Single Sign On
  • Red Hat support for Spring Boot
  • Red Hat build of Node.js
  • Red Hat build of Quarkus

Integration and Automation

  • Red Hat Application Foundations
  • Red Hat Fuse
  • Red Hat AMQ
  • Red Hat 3scale API Management
  • Single-page

Language and Page Formatting Options

Red hat training.

A Red Hat training course is available for Red Hat Enterprise Linux

3.6. Configuring IP Networking with ip Commands

Assigning a static address using ip commands, configuring multiple addresses using ip commands.

How to Configure Static IP Address on Fedora Linux

Hi techies, as we know Fedora is one of popular open source Linux based operating system. Fedora Linux can be used as workstation, Server, and CoreOS.

In this guide, we learn how to manually configure static ip address on Fedora Linux (Fedora 36 Workstation). A static IP address is an IP address that stays the same over time and remain persistent across the reboot. There are two different ways to configure static IP.

  • nmcli utility (Command Line)
  • Graphically

Configure Static IP address on Fedora 36 Using nmcli

The nmcli is a command line utility and used to configure a static IP address on Fedora Linux. To use this command, you must first open a terminal window (Ctrl+Alt+T). Then, you will need to type in the following commands:

This will show you a list of all the connections that are currently configured on your system.

nmcli-connection-show-fedora-linux

In my case, my Fedora system is connected to modem and got the IP from DHCP server. Now to make the IP address static and persistent, run following nmcli commands.

Following commands will modify the existing connection name ‘ Wired Connection 1 ’

Run beneath command to add static ip address along with the gateway ip.

To add DNS IP address, run

To make above changes into the effect, disable and enable the connection,

Verify the ip address using ip command ,

Output of above commands would like below,

nmcli-static-ip-fedora-linux

In case, you don’t want to use the existing connection and want to create new connection for configuring the static IP address, run following commands one after the another,

Assign Static IP Address on Fedora 36 via Graphically

Note: For this method to work, make sure desktop environment is installed on your fedora system.

Login to the desktop environment, go to Settings and then choose Network

Network-From-Settings-Fedora-Linux

Click on gearbox icon ,

In following window, Choose IPv4 ,

IPv4-Method-Graphically-Fedora-Linux

Choose ‘ Manual ’ to assign static ip address, gateway and DNS IP.

Specify details as below:

  • IP address: 192.168.1.189
  • Netmask: 255.255.255.0
  • Gateway IP: 192.168.1.1
  • DNS IP: 192.168.1.1

Note: Replace the IP details as per your environment.

Static-IP-address-Manual-Fedora-GUI

Click on Apply .

Now disable and enable the interface to make above changes into the effect.

Close the window and open the terminal and run ip command to verify the ip address.

Verift-Static-IP-Address-Fedora-Linux

Prefect, above commands output confirm that static IP address has been configured successfully on our Fedora Linux.

That’s all from this guide. In case you have found it informative, so please do share it among your technical friends.

1 thought on “How to Configure Static IP Address on Fedora Linux”

super, thanks of lot.

Leave a Comment Cancel reply

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 IP address in Linux

    how to assign ip address manually in linux

  2. How to configure IP address in Linux

    how to assign ip address manually in linux

  3. How to configure network interface to manually assign IP address on

    how to assign ip address manually in linux

  4. How To Assign Multiple IP Addresses To Network Interface In Linux

    how to assign ip address manually in linux

  5. 5 Ways to Assign an IP Address on a Linux Computer

    how to assign ip address manually in linux

  6. How to Configure Static IP Address on Ubuntu 20.04

    how to assign ip address manually in linux

VIDEO

  1. How to Assign IP Address in your computer using CMD

  2. set ip address manually in windows @for more updates fallow my channel

  3. How to manually configure IP address for a Windows server

  4. how to get ip address on linux system

  5. Configure IP address to PC in GNS3 #gns3 #networkengineer #networkengineerstuff #ipaddresstoPCGNS3

  6. Ip Address Settings With Windows 11 For Internet Connection

COMMENTS

  1. Manual Network Configuration in Linux and How to Set a Static IP Address

    Manual Network Configuration in Linux and How to Set a Static IP Address | Baeldung on Linux Manual Network Configuration in Linux and How to Set a Static IP Address Last updated: January 22, 2024 Written by: Hiks Gerganov Administration Networking ip systemctl 1. Introduction Many Linux distributions come with a network manager.

  2. How to Change IP Address in Linux

    sudo nano /etc/network/interfaces If your file read like the below, your IP address will be set by a DHCP client: auto eth0 iface eth0 inet dhcp To change the IP address as per our choice, we can modify this file to manually set the IP address. To set the IP address statically, for e.g. as 192.168.56.20, change the above entry to look as:

  3. How to Assign an IP Address on a Linux Computer (with Pictures)

    How to Assign an IP Address on a Linux Computer Download Article Written by Jack Lloyd Last Updated: July 28, 2022 Tested Debian, Ubuntu, & Linux Mint | Red Hat, CentOS, & Fedora | Video | Tips | Warnings This wikiHow teaches you how to assign a new IP address to your computer when using Linux.

  4. How to Set Static IP Address and Configure Network in Linux

    Open that file and set: NETWORKING=yes HOSTNAME=node01.tecmint.com GATEWAY=192.168..1 NETWORKING_IPV6=no IPV6INIT=no Next open: # vi /etc/sysconfig/network-scripts/ifcfg-eth0 Note: Make sure to open the file corresponding to your network interface. You can find your network interface name with ifconfig -a command.

  5. 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.

  6. How to Configure Static IP Address on Ubuntu 20.04

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

  7. How to Set a Static IP Address in Linux

    Configuring a static IP can be difficult in Linux because it's different based on the distro and version you're using. This guide will show you how to configure a static IP address on the most popular Linux distros. Ubuntu. As of version 17 of Ubuntu, networking is configured using Netplan, which is a YAML-based configuration system. ...

  8. How To Configure Static IP Address In Linux And Unix

    Table of Contents 1. Configure Static IP Address In Linux 1.1. Assign Static IP address In Fedora, RHEL, CentOS, AlmaLinux, Rocky Linux 1.1.1. Set Static IP Address By Editing Network Configuration File 1.1.2. Set IP Address Using Nmtui 1.1.3. Set IP Address Using Nmcli 1.2. Configure Static IP Address In Debian, Ubuntu 1.2.1.

  9. How to Assign Static IP Address on Ubuntu Linux

    Step 1: Get the name of network interface and the default gateway The first thing you need to know is the name of the network interface for which you have to set up the static IP. You can either use ip command or the network manager CLI like this: nmcli d In my case, it shows my Ethernet (wired) network is called enp0s25:

  10. Setting a Static IP in Ubuntu

    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. Manually setting a static IP using Ubuntu Desktop. Verify by using the command ip a.

  11. How to configure IP address in Linux

    There are two ways to configure an IP address on Linux: temporary and permanent. A temporary IP address works only in the current login session. Linux stores it in the RAM and removes it when you log out from the current session. A permanent IP address works until a service or you manually update or change it.

  12. How to Use the ip Command on Linux

    Key Takeaways The ip command has replaced the older ifconfig command in modern versions of Linux. The ip command allows you to configure IP addresses, network interfaces, and routing rules on the fly without rebooting. Run "ip addr" in the Terminal to get your PC's local IP address.

  13. How To Change IP Address on Linux

    To change your IP address on Linux, use the "ifconfig" command followed by the name of your network interface and the new IP address to be changed on your computer. To assign the subnet mask, you can either add a "netmask" clause followed by the subnet mask or use the CIDR notation directly.

  14. How to set up static IP address on Debian Linux 10/11

    Save and close the file when using vim/vi text editor.. Restart networking service on Debian Linux to switch from DHCP to static IP config. Warning: Do not run the following over ssh based session as you will disconnect.. Use the systemctl command as follows: $ sudo systemctl restart networking.service Make sure service restarted without any errors. Hence, type the following command: $ sudo ...

  15. Linux ifconfig Command

    With the ifconfig command, you can assign an IP address and netmask to a network interface. Use the following syntax to assign the IP address and netmask:

  16. How do I set a static IP in Ubuntu 20.04.3 LTS?

    @TopCoder2000 Firstly, you can't use both parts of my answer at the same time. It's part 1 or part 2. If you're using part 2, then my answer says "Use the NetworkManager GUI to setup your static IP for "Wired Connection"". See the IPv4 tab. Click on the manual button. Fill in the address, mask, gateway, and DNS servers, and turn off DNS Auto.

  17. How to configure a static IP address on RHEL 8 / CentOS 8 Linux

    In this tutorial we learn how to set a static IP address for a network interface in RHEL 8 / CentOS 8. We show three methods to perform said action: by manually editing a connection file, by using the nmcli command line utility, and finally by using nmtui, a text-user interface.

  18. How to Configure IPv4 and IPv6 Addresses in Linux

    How to Configure IPv4 Networking in Linux Configure IPv4 Address on Debian Configure IPv4 Address on Ubuntu Configure IPv4 Address on RHEL How to Configure Hostname in Linux Conclusion What is an IP Address? An IP address, which stands for Internet Protocol, is a unique numerical identifier or address that identifies a device in a TCP/IP network.

  19. How to assign static IP address on Ubuntu Linux

    To assign a static IP address on Ubuntu (server or client) through the Settings app, use these steps: Open Settings. Click on Network. Click the Settings button for the "Wired" network interface. Click the IPv4 tab. Select the Manual option for the "IPv4 Method" setting. Under the "Addresses" section, confirm the static IP address ...

  20. How to configure static IP address on Ubuntu 20.04 ...

    Hence, the configuration of your IP address is dynamic. In many scenarios, simply configuring your router or local DHCP server is a preferred way to set a static address to any host regardless of the operating system in use. Check your router manual and assign the static IP address to your host based on its MAC address using the DHCP service.

  21. 3.6. Configuring IP Networking with ip Commands Red Hat Enterprise

    The ip utility can be used to assign IP addresses to an interface with the following form:

  22. How to Configure Static IP Address on Fedora Linux

    Login to the desktop environment, go to Settings and then choose Network. Click on gearbox icon, In following window, Choose IPv4, Choose ' Manual ' to assign static ip address, gateway and DNS IP. Specify details as below: IP address: 192.168.1.189. Netmask: 255.255.255..

  23. How to configure static IP address on Alpine Linux

    IPv4 static address configuration for Alpine Linux version 3.13.xx. Let us set static IP address to 192.168.2.16 with 255.255.255. (/24) subnet. The default gateway set to 192.168.2.254 and Alpine Linux hostname set to nixcraft-x140e: auto eth0 iface eth0 inet static address 192.168.2.16/ 24 gateway 192.168.2.254 hostname nixcraft-x140e.

  24. 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 ...