- Buying Guides

Complete Guides by How-To Geek
Our latest product roundups, reader favorites, more from how-to geek, latest geek news, latest reviews, across lifesavvy media.
Join 425,000 subscribers and get a daily digest of news, geek trivia, and our feature articles.
By submitting your email, you agree to the Terms of Use and Privacy Policy .
How to Change Your IP Address From the Command Line in Linux
Taylor Gibb is a professional software developer with nearly a decade of experience. He served as Microsoft Regional Director in South Africa for two years and has received multiple Microsoft MVP (Most Valued Professional) awards. He currently works in R&D at Derivco International. Read more...
Lowell is the founder and CEO of How-To Geek. He’s been running the show since creating the site back in 2006. Over the last decade, Lowell has personally written more than 1000 articles which have been viewed by over 250 million people. Prior to starting How-To Geek, Lowell spent 15 years working in IT doing consulting, cybersecurity, database management, and programming work. Read more...

This trick should work on all Debian-based Linux distros, including Ubuntu. To get started, type ifconfig at the terminal prompt, and then hit Enter. This command lists all network interfaces on the system, so take note of the name of the interface for which you want to change the IP address.
To change the settings, you also use the ifconfig command, this time with a few additional parameters. The following command changes the network interface named “eth0” to use the IP address 102.168.0.1, and assigns the subnet mask 255.255.255.0:
You could, of course, substitute in whatever values you want. If you run ifconfig again, you will see that your interface has now taken on the new settings you assigned to it.
If you also need to change the Default Gateway used by the network interface, you can use the route command. The following command, for example, sets the default gateway for the “eth0” interface to 192.168.0.253:
To see your new setting, you will need to display the routing table. Type the following command at the prompt, and then hit Enter:
RELATED: How to Work with the Network from the Linux Terminal: 11 Commands You Need to Know
That’s all there is to changing your IP address from the terminal. If you’re interested in other great networking tools you can use at the terminal, be sure to check out our guide to the subject.
RELATED: Best Linux Laptops for Developers and Enthusiasts
- › Let Alexa Be Your DJ With $30 off Echo Studio and Subwoofer
- › Windows 11 Feature Updates Are Speeding Up
- › Alienware Has New Gaming Keyboards, Mice, Monitors, and More
- › How to Enable or Disable Memory Compression in Windows 11
- › Microsoft Is Revamping Windows 11’s Bad Audio Settings
- › Proton VPN Is Coming to Your Web Browser
Daniel Miessler
How to Set a Static IP Address in Linux
Created/Updated: February 2, 2022

- 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 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.
As of version 17 of Ubuntu, networking is configured using Netplan , which is a YAML-based configuration system. It allows you to set your IP, netmask, gateway, and DNS all in one place.
Start by editing the file for your interface: in this case 01-netcfg.yaml .
vi /etc/netplan/ 01-netcfg.yaml
Editing your interface file
You’ll either see networkd or systemd in the renderer spot; keep that the same.
network: version: 2 renderer: networkd ethernets: enp0s3: dhcp4: no addresses: [192.168.2.2/24] gateway4: 192.168.1.1 nameservers: addresses: [8.8.8.8,8.8.4.4]
To have your changes take effect, restart networking with this command:
You can then apply this configuration by running netplan apply .
YAML configs are crazy about indentation, so if you get an error check there first.
netplan apply
Now let’s do the same thing in CentOS. Here we’ll need to edit things the old way using sysconfig and network-scripts:
vi /etc/sysconfig/network-scripts/ ifcfg-eth0
You’ll change what you see there to something like this:
HWADDR=$SOMETHING TYPE= Ethernet BOOTPROTO= none // turns off DHCP IPADDR= 192.168.2.2 // set your IP PREFIX=24 // subnet mask GATEWAY= 192.168.2.254 DNS1=1.1.1.2 // set your own DNS DNS2=1.0.0.2 DNS3=9.9.9.9 DEFROUTE=yes IPV4_FAILURE_FATAL=no NAME=eth0 DEVICE=eth0 ONBOOT= yes // starts on boot
You can then apply this configuration by running:
/etc/init.d/ network restart
Ok, that will get you up and running with a static IP on the two most common Linux distros. Now let’s take a deeper look at the new ip command.
Using ip and netplan
Most Linux nerds have been using ipconfig for a long time, but it’s now being replaced with a new command called ip . Here’s how to do some basic tasks using the new command.
Show your IP using ip
ip addr show
or even shorter and more efficient…
(both commands show all interfaces)
Show only one interface using ip
ip a show eth0
Bring an interface up or down using ip
ip link set eth1 up
ip link set eth1 down
Only show IPv4 interfaces
Ok, so now you should know how to set a static IP on both Ubuntu and CentOS, as well as how to get some basic network information using ip instead of ipconfig .
Happy hacking!

Written By Daniel Miessler
Recommended.
- Information Security
- Recommended Tutorials
- A Vim Primer
- A Tcpdump Primer
- Security Assessment Types
- URLs vs. URIs
- Unsupervised Learning
- Book Summaries

howtouselinux
3 ways to change ip address in linux.
- Last updated: February 27, 2023
- Cloud , Linux
Do you need to change your IP address frequently? Are you having trouble finding a way to do it on Linux? If so, you have come to the right place. In this blog post, we will discuss three different ways that you can change your IP address on Linux.
We will also provide instructions on how to do it. So, whether you are a beginner or an expert Linux user, you should be able to follow along without any problems!
- ifconfig eth0 192.168.0.100 netmask 255.255.255.0
- ip addr add 192.168.0.100/24 dev eth0
- change ip address in file /etc/sysconfig/network-scripts/ifcfg-eth0 and restart network systemctl restart network
understanding network interface and ip address in Linux
Network interfaces are devices that allow communication with other devices on a computer network. A computer can have multiple network interfaces, each of which has its own IP address.
In Linux, you can view a list of all the network interfaces and their associated IP addresses by running the ifconfig -a or ip addr command. Check this post to get more info about how to find ip address in Linux .
change ip address with ifconfig Command in Linux
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 address. Press enter. The new ip address will be assigned to this interface.
For example, ifconfig eth0 192.168.0.100 netmask 255.255.255.0 will change the ip address on eth0 to 192.168.0.100.
The “interface” parameter specifies the name of the network interface. The “ip address” parameter specifies the IP address for the network interface. The “netmask” parameter specifies the netmask for the network interface.
The changes made with ifconfig will not persist after a reboot, which means that every time the system is restarted. The IP address will be reset to the value it had before.
In addition, ifconfig command is considered as deprecated command and it is replaced by iproute2 package in many distributions.
procedure to change IP address with ifconfig command in Linux
The procedure to change IP address in Linux is as follows:
- Open the terminal application.
- List the current IP addresses for all network interfaces with command ifconfig -a
- Take the network interface down with command: ifconfig <interface> down
- Change the IP address with command ifconfig <interface> <ip address> <netmask>
- Press Enter to run the command.
- Verify that the new IP address is correct with command ifconfig -a
- Take the interface up with command ifconfig <interface> up
change ip address with ip Command in Linux
Another way to change your IP address on Linux is to use the ip command. This is a more advanced method to change your IP address. You will need to open a terminal window and type in the following command:
sudo ip addr add 192.168.0.100 255.255.255.0 dev eth0
Replace 192.168.0.100 with the IP address and netmask that you want to use. This will add an IP address to your system. You can then close the terminal window and continue using your computer as normal.
This command adds the new IP address to the specified interface.
Note: It does not remove or update the existing IP address. It appends the current IP configuration.You need to run sudo ip addr del command to remove the old ip address.
The new settings take effect immediately – however they are not persistent and will be lost after a reboot.
Ip command is more up-to-date, and it is considered as the standard tool for managing the network on Linux systems.
change ip address permanently in configuration file in Linux
You can change the IP Address permanently by modifying the configuration file. Under the /etc/sysconfig/network-scripts directory, you’ll see file for every network interface on your system. For example, if your interface is “eth0″, you’ll see ifcfg-eth0 file under this directory.
Modify the ifcfg-eth0 file with your favorite text editor (a lot of people prefer to use vi or nano) and change the IPADDR field accordingly as shown below to change the ip-address.
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
Change the IP address to the correct IP, make sure that the Netmask and Gateway are configured correctly as well and save.
# vi /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE="eth0" BOOTPROTO=none ONBOOT=yes TYPE="Ethernet" IPADDR="192.168.0.100" NETMASK="255.255.255.0" GATEWAY="192.168.0.1"
After you save the ifcfg-eth0 file you will have to restart the network. You can restart the network with the following command: systemctl restart network
Change Public ip address with VPN in Linux
A VPN (Virtual Private Network) is the best and safest way to change your public IP address. While there are many VPN apps on the market, one of the most popular options is ExpressVPN .
It can stop your ISP monitoring your internet activity. Changing to an address that’s based in another country can also give you access to that country’s streaming content.
We have found ExpressVPN to be extremely reliable and secure. Technically speaking, a VPN “hides” your IP address by creating an encrypted connection. This type of connection acts as a tunnel between your device and the internet.
- Open up your VPN application.
- Select which server you want to connect to. If you’re just looking for privacy, choose one in your home country. If you want to access content from another country, pick one in your desired location.
- Press the connect button — it should be easy to find.
- Wait a few seconds for the VPN to connect. You’ll now be using a new IP address.
So if you want to change your public IP address, look no further than ExpressVPN . Plus, they have a 30-day money-back guarantee and 3 months free , so you can try them out risk-free.
Check out ExpressVPN here
FAQ about ip address in Linux
How to find your IP address in Linux
To find your IP address in Linux , use the ip addr command. This will print the IP address and other information about your network interfaces.
If you want to find out your public IP address, you can use the curl command. This will send a request to a web server and return your public IP address. curl ifconfig.me
What is the netmask for your ip address in Linux?
The netmask in Linux is a bitmask that determines what IP addresses are on the same network as your computer. If two computers have the same netmask, they are on the same network. If they have different netmasks, they are on different networks.
how to find the gateway for ip address in Linux
To find the gateway in Linux , you can use the route command. This will print the IP address of the gateway for your default route. You can also use the ip addr command to find the gateway.
what is difference between a private and public IP address in Linux
The private IP address space is reserved for internal networks only and cannot be routed on the Internet as addressing like a public IP address space can be, which makes it much more difficult to use this form of addressing on the Internet.
A public IP address can be easily found by looking up the domain name of a website. Conversely, a private IP address is much harder to find as it requires special software and tools to do so.
Additionally, most home users will not have a static public IP address but their private IP addresses will remain the same unless they take specific action to change it.
ifconfig command vs ip command
The ip command is a replacement for the ifconfig command. In earlier versions of Linux, the ifconfig command was the default utility for checking and verifying IP configuration. The ifconfig command does not support many modern features that were not relevant in earlier times.
The ifconfig command is deprecated. Although some Linux distributions still include the ifconfig command for backward compatibility in their current version of Linux, they may consider gradually removing it from their upcoming Linux versions.
Because of this, even if the ifconfig command is still available on some Linux distributions, you should use the ip command for all IP validation and verification-related tasks. The ip command is designed to meet the requirements of modern networks.
Understanding /etc/resolv.conf file in Linux
How to list repository in Linux
How to Find Your IP Address in Ubuntu Linux
2 ways to use Linux ip addr command
Welcome to howtouselinux.com !
Our website is dedicated to providing comprehensive information on using Linux.
We hope you find our site helpful and informative, and we welcome your feedback and suggestions for future content.
The /etc/resolv.conf file is a configuration file used by the Linux operating system to store information about Domain Name System (DNS) servers. This file contains
In Linux, a repository is a collection of software packages that are available for installation on your system. Think of it as an app store
If you’re having trouble connecting to the internet or other devices on the network, checking your IP address can help you determine if the issue
As a Linux user, you may have used the ip addr command at some point. But do you know what this command does and how
3 ways to fix ping: cannot resolve Unknown host
“ping: cannot resolve Unknown host” is an error message that typically appears when the ping command is used to try and reach a hostname that
4 ways to fix cd: no such file or directory
“cd: no such file or directory” is an error message that is displayed when the command line interpreter (CLI) is unable to find the directory
- EXPLORE Coupons Tech Help Pro Random Article About Us Quizzes Contribute Train Your Brain Game Improve Your English 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
- HELP US Support wikiHow Community Dashboard Write an Article Request a New Article More Ideas...
- EDIT Edit this Article
- PRO Courses New Tech Help Pro New Expert Videos About wikiHow Pro Coupons Quizzes Upgrade Sign In
- Browse Articles
- Quizzes New
- Train Your Brain New
- Improve Your English New
- Support wikiHow
- About wikiHow
- Easy Ways to Help
- Approve Questions
- Fix Spelling
- More Things to Try...
- H&M Coupons
- Hotwire Promo Codes
- StubHub Discount Codes
- Ashley Furniture Coupons
- Blue Nile Promo Codes
- NordVPN Coupons
- Samsung Promo Codes
- Chewy Promo Codes
- Ulta Coupons
- Vistaprint Promo Codes
- Shutterfly Promo Codes
- DoorDash Promo Codes
- Office Depot Coupons
- adidas Promo Codes
- Home Depot Coupons
- DSW Coupons
- Bed Bath and Beyond Coupons
- Lowe's Coupons
- Surfshark Coupons
- Nordstrom Coupons
- Walmart Promo Codes
- Dick's Sporting Goods Coupons
- Fanatics Coupons
- Edible Arrangements Coupons
- eBay Coupons
- 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 690,225 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. ⧼thumbs_response⧽ Helpful 0 Not Helpful 0

- Don't forget to switch back to the regular (non-root) user account when you're done. ⧼thumbs_response⧽ 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 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.
Tutorial Feedback...
If you appreciate what we do here on tecmint, you should consider:.
TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

We are thankful for your never ending support.
Related Posts

How to Use ‘tee’ Command in Linux [8 Useful Examples]

How to Run Commands from Standard Input Using Tee and Xargs in Linux

How to Modify Linux Kernel Variables Using sysctl Command

4 Useful Commands to Clear Linux Terminal Screen

How to List and Extract tar.xz File in Linux

How to Find Parent Process PPID 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
Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.
Save my name, email, and website in this browser for the next time I comment.
Don't subscribe All Replies to my comments Notify me of followup comments via e-mail. You can also subscribe without commenting.
- United States
- Netherlands
- New Zealand
- United Kingdom
Changing IP addresses on Linux systems

Unix Dweeb, ITworld |
ITworld.com –
Changing the IP address on a Linux system involves both changing the IP address using the ifconfig command and modifying the files that will make your change permanent. The process is very similar to the process you would follow on a Solaris system, except that a different set of files must be modified. The proper steps to take also depend on the particular Linux distribution you are using. Debian systems, for example, use different files to store network configuration than do RedHat systems.
For starters, we use the ifconfig command to modify the active IP address. A command like this makes the change:
The ifconfig -a command will list the current settings as well as confirm that your network device is (or is not) eth0.
If the system needs to have its IP address changed, it may be joining a different subnet. If so, it will need to have its default route switched as well. Be careful when changing default routes not to break the connection that you are using to make the changes. Either make this change via a console connection or otherwise ensure that your connection to the system is not broken before you have completed your work.
The files you need to modify to make the IP address change permanent include the /etc/hosts file and the file in the /etc/sysconfig/network-scripts directory that sets up the parameters for the particular network interface. Typically, it is the /etc/sysconfig/network-scripts/ifcfg-eth0 file that needs to be modified. This file contains information that describes the network interface, including the IP address, netmask and MAC address. This file also indicates whether the IP address is static or assigned by DHCP. Here's an example of the file when a static IP address is used:
If you do not have an /etc/sysconfig directory, your network configuration parameters might be stored instead in a file named /etc/network/interfaces -- as it is on Debian, Ubuntu and related distributions. That file will have a similar look to what is shown in the example below.
The script below could be used to both detect the files to be modified and then make the required changes. Notice that it expects the old and new IP addresses along with an optional new default route. The script does no checking of the arguments, so they must be added in the correct order.
This script will not move you to a static address if you are currently obtaining your IP address through DHCP.
This story, "Changing IP addresses on Linux systems" was originally published by ITworld .
- Operating Systems
- Open Source
Sandra Henry-Stocker has been administering Unix systems for more than 30 years. She describes herself as "USL" (Unix as a second language) but remembers enough English to write books and buy groceries. She lives in the mountains in Virginia where, when not working with or writing about Unix, she's chasing the bears away from her bird feeders.
Copyright © 2008 IDG Communications, Inc.

IMAGES
VIDEO
COMMENTS
This trick should work on all Debian-based Linux distros, including Ubuntu. To get started, type ifconfig at the terminal prompt
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 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
Super Simple How to Tutorial Videos in Technology.The only channel that is backed up by computer specialist experts who will answer your
In this video we are going to assign static IP address to Window 10 and Kali Linux computers#staticIP.
ifconfig is being replaced by the ip command. Configuring a static IP can be difficult in Linux because it's different based on the distro and
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 address. Press enter.
Change the item's IP address. Type in sudo ifconfig name ipaddress netmask 255.255.255.0 up —making sure to replace name with your item's name and ipaddress
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
Changing the IP address on a Linux system involves both changing the IP address using the ifconfig command and modifying the files that will