Setting the IP address in Linux
To set the IP address on Linux® operating system, complete these steps.

About this task
- Make sure that you are logged on as a root user.
- Start a terminal session.
- Type ifconfig -a at the command prompt. Attention: Record or print the current settings and the eth1 or eth2 interfaces before making changes. This action allows you to restore these settings if you disconnect the PC or notebook after setting up the ASMI web interface.
- Type ifconfig ethx xxx.xxx.xxx.xxx netmask xxx.xxx.xxx.xxx , where the xxx.xxx.xxx.xxx values are the values from step 4 for IP address and Subnet mask. Replace ethx with the interface shown in step 3 .
- Press Enter.
How to Change IP Address on Linux?
An “ IP ” ( Internet Protocol) corresponds to a unique numeric address used to identify the network device. In Linux, It is automatically assigned by the “DHCP (Dynamic Host Configuration Protocol)” server. Sometimes, the user needs to change the dynamic IP address to the static because the static IP addresses provide a stable and reliable connection.
This post will provide possible different methods to change the IP address on Linux.
Method 1: Using the “ip” Command
Method 2: using the “ifconfig” command, method 3: using the “nmcli” tool, method 4: using the “network” window (gui).
Note: All the implementation is performed as a root user to change the system IP address.
The “ip” is an advanced built-in “Internet Protocol” command line tool to assign, show and configure the interface IP addresses. To perform this task following essential steps are required:
Step 1: Check Existing IP Address
First, use the “ ip ” command with the “ -c (highlight IP address)” flags to show the IP addresses of all the network interfaces available in the system:

The “ ens33 ” interface is running having an “IP” address “ 192.168.253.132 ”
Step 2: Assign New IP Address
Assign a new IP address to the “ ens33 ” interface by utilizing the following “ ip ” command. The “ add ” keyword assigns the specified new IP address to the the “ dev(device) ” “ens33”:

The above command has successfully assigned the “192.168.157.150” to an interface “ens33”.
Step 3: Verify IP Address
Run the “ip” command to verify the IP address assigned to the device “ens33”:
The output verifies that the “ens33” IP address has been changed to “192.168.157.150”.
The “ ifconfig ” stands for “ interface configuration ” command line tool to show the current network configuration information. It is used in the older version of the Linux system, having a minimal range of functionalities, then the “ ip ” command.
Follow these steps to check how “ifconfig” changes the IP address of a network:
Step 1: Display Network Details
Execute the “ ifconfig ” command to display the current interface details, including its IP address:

Here, the “ ens33 ” is the network interface having an IP address “192.168.253.130”.
Step 2: Network Interface Down
The “ens33” interface is in running status. So bring it “down”(offline) using the “ifconfig” command in the following way:

The “ ens33 ” interface has been “down,” i.e., not running.
Step 3: Change IP Address
Type the “ ifconfig ” command with the targeted network interface “ ens33 ” assigning the new IP address “ 192.168.253.132 ”. Specify the “netmask” “255.255.255.0” that is associated with the IP address:
It is verified that a new IP address has been assigned to the “ens33” network interface.
The Linux distribution supports the “ Network Manager ” tool that allows the user to change device connections settings. It can be managed through the “ nmcli ” command line tool.
Following these steps, let’s check the functionality of “ nmcli ” to change the IP address:
Step 1: Change IP Address
Execute the “nmcli” command to change the “ens33” network card by specifying the “ ipv4.address ” “192.168.253.134”:

The output shows that “192.168.253.134” of “ens33” has been changed successfully.
Step 2: Verify IP Address
Once the IP address is changed, verify it using either the “ ifconfig ” or the “ ip ” command specifying the device name, i.e., “ens33” in this scenario:
It is confirmed that the IP address of the “ens33” network card has been changed.
The GUI method also allows the Linux user to change “IPv4” address using the “Network” window by following the below-mentioned steps:
Step 1: Access the Network Window
Open the default “ Settings ” tool using the “Search” bar of the “Application” menu:

The “Settings” tool is being opened. Navigate to the “ Network ” window located in the left side panel of the system:

Tip: The user can also open the “Network” window using the “Wired Connected” icon present on the top right corner of the screen:

Step 2: Change IPv4 Address
Click on the “gear(settings)” wheel in front of the “connected” tab to change the IPv4 address:

The “ Wired ” window is opened with the “ IPv4 ” tab. Mark the “Manual” checkbox to set the IPv4 address manually:

Type the new IPv4 address and also the default “ Netmask ” and the “ Gateway ” in its sections:

At last, hit the green “Apply” button to save the new changes.
Step 3: Confirm IPv4 Address
Move on to the “ Details ” tab from the “ Wired ” window and check the “ipv4” details:

It shows the new IP address “ 192.168.253.137 ”.
Note: The GUI method is applicable to the Linux distributions supporting the GUI.
To change an IP address in Linux, utilize the “ ip ”, “ ifconfig ”, and the “ nmcli ” command line tools. The user can also perform this task using the “ Network ” window provided by the graphical user interface. Once the new IP address is changed, execute the commonly used “ip” command for verification.
This guide has illustrated both CLI and GUI tools to change the IP address on Linux.

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:

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.

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.

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.

- Verify by using the command ip a

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
- 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 716,373 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.

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

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

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

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

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

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

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

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

- 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

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

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

- 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

- ↑ https://danielmiessler.com/study/set_ip/
- ↑ https://www.youtube.com/watch?v=oQd5eG9BZXE&t=
About This Article

- Send fan mail to authors
Reader Success Stories

Buddy HaDagi
Jan 27, 2017
Is this article up to date?

Dmitry Ugay
Oct 10, 2017

Featured Articles

Trending Articles

Watch Articles

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

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.

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.

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.

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.

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.

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

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

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

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

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

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

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

Select the Quit option and press the Enter key.

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.

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

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.

Restart the interface and verify the new IP configuration.

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]

A Beginner-Friendly Guide for Linux / Start Learning Linux Quickly...
How to use ip command in linux [24 useful examples].
Brief: In this guide, we will discuss some practical examples of the ip command. By the end of this guide, users will be able to perform networking tasks efficiently in Linux from the command line interface.
System administrators often need to perform networking tasks on Linux servers. There are a variety of graphical and command-line tools available in the market. However, most Linux users prefer to use the ip command due to its simplicity and rich functionality.
The ip command is a new networking command-line utility that is used to assign an IP address to a network interface or configure/update useful network variables on a Linux system.
It is a part of the iproute2 package and offers several network administration tasks such as bringing up or down network interfaces, assigning and removing IP addresses and routes, managing ARP cache, and much more.
The ip command is much similar to the old ifconfig command , but it is greatly more powerful with more functions and capabilities added to it.
[ You might also like: Deprecated Linux Networking Commands and Their Replacements ]
The ifconfig command has been deprecated and replaced by the ip command in all modern Linux distributions. However, the ifconfig command is still works and available for most Linux distributions .
[ You might also like: ifconfig vs ip: What’s Difference and Comparing Network Configuration ]
Table of Contents
Note: Please take a configuration file backup before doing any changes.
1. Permanently Configure Static IP Address in Linux
To permanently configure a static IP address in Linux, you need to update or edit the network configuration file to assign a static IP address to a system. You must be a superuser with a su (switch user) command from the terminal or command prompt.

Set Static IP Address in RHEL Systems
Open and edit the network configuration files for ( eth0 or eth1 ) using your favorite text editor . For example, assigning IP Address to eth0 interface as follows on RHEL-based distributions .

Set Static IP Address in Debian Systems
To configure the permanent static IP address, you need to modify your network interface configuration file /etc/network/interfaces to make permanent changes as shown below for Debian-based distributions .

Next, restart network services after entering all the details using the following command.
[ You might also like: How to Configure Network Connection Using ‘nmcli’ Tool ]
2. Temporary Configure Static IP Address in Linux
For temporary network configurations, you can use the ip command to assign an IP address to a specific interface ( eth2 ) on the fly.
Note: Unfortunately all these settings will be lost after a system restart.
3. How to Display All Network Interfaces
In ip command , the link object represents the network interface. We can use the show command with it to display all network interfaces.
Now, let’s display all network interfaces using the following command:

The above output shows the details of all network interfaces, such as interface name, flags, status, link address, broadcast address, etc.
4. How to Check an IP Address of a Specific Network Interface
To get the depth information of your individual network interface like IP Address, and MAC Address information, use the following command as shown below.

So far, we used the link object shows detailed information about the network interfaces. However, it doesn’t show the IP address associated with the network interface. To overcome this limitation, we can use the addr object with the ip command.
Let’s understand this with an example.

Here, we can see that, now output shows the IP addresses of all network interfaces along with other details.
To display the IP address of the individual network interface, just need to provide the network interface name as an argument to the command.
5. How to Display IP Address in Colored Output
The ip command shows detailed information about the network objects. However, sometimes we need to take a look at the limited information. In such cases, we can enable the colored output. This option highlights important details in different colors.
Let’s use the --color option of the command to display the output in different colors:

In the above output, we can see that the interface name, ethernet address, and state are highlighted in different colors.
6. How to Display IP Address in JSON Format
In the previous examples, we saw that the ip command shows meaningful information. However, it is not an easy task to parse the raw output and extract meaningful information using rudimentary scripts. In such cases, we can instruct the ip command to generate the output in a JSON format.
So, let’s use the -j option with the command to display the same output in a JSON format:

This method comes in handy while doing automation because JSON is a widely accepted format and there are many JSON parser libraries/tools available in various programming languages.
7. How to Make JSON Output More Readable
In the previous example, we used the -j option to display output in a JSON format. This default JSON format is compact and space efficient. However, the output is not easy to read due to a lack of indentation.
To overcome this limitation, we can use the -p option which makes the output more readable by indenting it. Let’s understand this with the below example:

Here, we can see that the same output is much more readable as compared to the previous examples.
8. How to Remove an IP Address From the Network Interface
In the previous example, we used the add sub-command to assign an IP address. In a similar way, we can use the del sub-command to remove a particular IP address.
The following command will remove an assigned IP address from the given interface ( eth2 ).
Now, let’s verify that the IP address has been removed:

In the above output, we can see that the now eth2 network interface has only one IP address.
9. How to Enable the Network Interface
The “ up ” flag with interface name ( eth2 ) enables a network interface. For example, the following command will activate the eth2 network interface.
Now, let’s check the updated status:

10. How to Disable the Network Interface
The “ down ” flag with interface name ( eth2 ) disables a network interface. For example, the following command will De-activates the eth2 network interface.
Now, let’s check the status of the eth2 network interface:

The above output shows the modified state of the network interface.
11. How to Flush IP Addresses of Network Interface
In the previous example, we saw how to use a del sub-command to remove an IP address. However, sometimes we need to remove all IP addresses of the particular network interface. In such cases, we can use the flush sub-command.
First, use the flush sub-command to remove all the IP addresses of the eth2 network interface:
Now, let’s check that all IP addresses of the eth2 network interface have been removed:

In the above output, the addr_info field shows the empty JSON array. This indicates there isn’t any IP address associated with the eth2 network interface.
12. How Do I Check Routing Table
A routing table stores the necessary information to forward a network packet to the correct destination. We can use the route object of the ip command to display the routing rules.
Let’s use the below command to list the all rules of the routing table:

In the above output, the first column represents the destination whereas the last column represents the source IP address.
13. How Do I Add New Static Route
Why do you need to add static routes or manual routes, because the traffic must not pass through the default gateway? We need to add static routes to pass traffic from the best way to reach the destination.
Now, let’s verify that the entry has been added successfully:

15. How to Remove Static Route
The del sub-command removes a particular entry from the routing table. For example, the below command removes the entry of the eth2 device route:
Now, let’s verify that the entry has been removed successfully:

16. How Do I Add Permanent Static Routes
All the above routes will be lost after a system restart. To add a permanent static route, edit file /etc/sysconfig/network-scripts/route-eth2 (We are storing static route for ( eth2 ). By default, the route-eth2 file will not be there and need to be created.
Set Permanent Route in RHEL Systems
and add the following lines and save and exit.
Set Permanent Route in Debian Systems
Open the file /etc/network/interfaces and at the end add the persistence static routes. IP Addresses may differ in your environment.
17. How Do I Add the Default Gateway
In networking, the default gateway plays an important role. It gets used when the routing table doesn’t contain any information about the destination.
The default gateway can be specified globally or for interface-specific config files. The advantage of the default gateway is that we have more than one NIC present in the system. You can add the default gateway on the fly as shown below the command.
First, let’s add an eth0 network interface as a default gateway:
Now, let’s verify the default gateway setting using the following command:

Please note that we have executed this command on a test machine. Be careful while using this command in the production environment.
18. How to Remove a Default Gateway
We can use the following command to remove the default gateway:
Now, let’s list the routing table to verify the default gateway has been removed:

19. How to Display ARP Cache
ARP stands for the Address Resolution Protocol , which is used to find the MAC address associated with the particular IP address.
We can use the neigh object with the ip command to display the ARP cache:

In the above command, the neigh represents neighboring objects.
20. How to Add an ARP Entry
To create a new ARP entry, we can use the add sub-command with the neigh object.
Now, let’s list the ARP cache entries:

In the above output, we can see the new entry for the eth2 network interface.
21. How to Remove an ARP Entry
Like other network objects, we can use the del sub-command to remove the ARP entry. For example, the below command removes the ARP entry of the eth2 network interface:
Now, let’s verify that the entry has been removed by listing the ARP cache:

22. How to Flush the ARP Entries
We can use the flush sub-command to remove multiple ARP entries. To understand this, first, add a few ARP entries with the STALE state:
Next, verify that the new entries have been added successfully:
Then, flush all the entries using the below command:
Finally, verify that all the entries have been removed:

23. How to Set MTU for Network Interface
MTU stands for Maximum Transmission Unit , which represents the largest packet size that can be transmitted in a single transaction. We can manipulate the MTU size as per our performance requirements.
First, let’s find the MTU of the eth2 network interface:
Next, update the MTU size of the eth2 network interface to 3000 :
Finally, verify that the MTU has been updated successfully:

24. How to Change the Network Mac Address
The ip command allows us to change the MAC address of the network interface. To achieve this, we can use the set sub-command with the link object:
First, list the current MAC address of the eth2 network interface:
Next, change the MAC address of the network interface using the below command:
Finally, verify that the MAC address has been changed:

Please refer manual page doing man ip from the terminal/command prompt to know more about IP Command.
In this article, we discussed some common examples of the ip command . One can use these examples in day-to-day life to perform network administration.
Do you know of any other best example of the ip command in Linux? Let us know your views in the comments below.
How useful was this post?
Click a star to add your vote
Average rating 0 / 5. Vote count: 0
No votes so far! Be the first to rate this post.
As you found this post useful...
Follow us on social media!
We are sorry that this post was not useful for you!
Let us improve this post!
Tell us how we can improve this post?
Previous article:
Next article:
Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.
Related Posts

18 Tar Command Examples in Linux

How to List All Running Services Under Systemd in Linux

7 Interesting ‘sort’ Command Examples in Linux – Part 2

14 Useful Examples of ‘Sort’ Command in Linux – Part 1

How to Use /proc File System to Monitor Your Linux System

How to Add, Delete and Update Files in Tar Archive in Linux
36 thoughts on “How to Use IP Command in Linux [24 Useful Examples]”
I have Debian buster on my laptop. It defaults to nm. But I used network/interfaces years ago.
Calm down. Netplan is not in charge yet here, in Ubuntu 18 bionic beaver desktop. We may also run into trouble with resolvconf.
grep ‘^ *renderer: *NetworkManager’ /etc/netplan/01-network-manager-all.yaml && { [do stuff] } || echo netplan has superseded NetworkManager here\, \”man netplan\”
Your info is deprecated. For example:
There is netplan in Ubuntu now.
To add permanent Static route, edit file /etc/sysconfig file. There is no /etc/sysconfig directory at all.
Do you know why Ubuntu has implemented netplan? Is it across all Debian distro’s?
We are quite rapidly heading towards 2 distinct branches of Linux; RH based for enterprise, and Ubuntu/Debian for developers.
I think you should ask Canonical about this but not me. I’m usually remove this and configuring network by networkd.
September 9, 2018, Ubuntu bionic beaver desktop, netplan is not in charge here:
grep ‘^ *renderer: *NetworkManager’ /etc/netplan/01-network-manager-all.yaml && { sudo /etc/init.d/networking stop sudo ip addr add 192.168.1.1/24 dev $eth1
} || echo netplan may be in charge\, \”man netplan\”
A big thank’s
Problem with setting static IP.
Done static route through GUI and on reboot I get no WAN. Also my “ eth0 ” shows up as “ enp2s0 ” not sure how it got that way. (wired only, wireless off, set IPv6 as Link Local Only) Does Linux Mint 18.3 require IPv6 to connect to WAN ? The only way to restore my network is set to Auto DHCP and restart.
Thank you .
Your process was clean and tidy and it worked.
May I ask: I have taken over a slightly mis-configured system in my new position, and found some ifcfg-*** files that have quotation marks around some of the parameters.
I am wondering if these quotes have an affect on the system, or if they are simply one persons preference?
Please see below:
I don’t find any problem with the quotes but wonder why they are there.
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.

IMAGES
VIDEO
COMMENTS
In the Windows operating system, users can find the IP address of an SMTP server by using the “ping” command and the server’s hostname in the command prompt. The same process is used in the terminal of Unix-based systems such as Linux and M...
There are several ways to change your IP address, including unplugging your modem, using a different Internet connection, using a proxy server and contacting your Internet service provider.
Modify the IP address on an LG Smart TV by accessing the Network Settings menu and selecting the Manual IP Setting option in the IP Mode section. After selecting the option, use the remote to input the four digits manually in the IP Address...
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
To change IP address in Linux, we can use “ifconfig” command. Type ifconfig followed by the name of your network interface and the new IP
To change the IP address, replace the old IP address with a new one. Additionally, you can keep this IP and add one more to the above interface
Procedure · Make sure that you are logged on as a root user. · Start a terminal session. · Type ifconfig -a at the command prompt. Attention:
To change an IP address, utilize the “ip”, “ifconfig”, and the “nmcli” command line tools or the “Network” window in the GUI method.
Set Your Static IP in Ubuntu Set Your Static IP in CentOS Using the ip Command ifconfig is being replaced by the ip command. Configuring a static IP can be
How to Set a Static IP Using the GUI · Search for settings . · Click on either Network or Wi-Fi tab, depending on the interface you would like
5.1. Add Interface Configuration · auto eth1 enables automatic configuration for this interface during boot · iface eth1 inet static sets eth1
Type in sudo ifconfig name ipaddress netmask 255.255.255.0 up —making sure to replace name with your item's name and ipaddress with your
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
To permanently configure a static IP address in Linux, you need to update or edit the network configuration file to assign a static IP address