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

how to change ip address in linux using command line

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

how to change ip address in linux using command line

Daniel Miessler

How to Set a Static IP Address in Linux

Created/Updated: February 2, 2022

static ip linux 2022

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!

how to change ip address in linux using command line

Written By Daniel Miessler

Recommended.

how to change ip address in linux using command line

howtouselinux

3 ways to change ip address in 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!

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:

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.

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.

David Cao

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

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.

Image titled Assign an IP Address on a Linux Computer Step 1

Image titled Assign an IP Address on a Linux Computer Step 3

Image titled Assign an IP Address on a Linux Computer Step 4

Image titled Assign an IP Address on a Linux Computer Step 5

Image titled Assign an IP Address on a Linux Computer Step 6

Image titled Assign an IP Address on a Linux Computer Step 7

Image titled Assign an IP Address on a Linux Computer Step 9

Image titled Assign an IP Address on a Linux Computer Step 15

Image titled Assign an IP Address on a Linux Computer Step 18

Image titled Assign an IP Address on a Linux Computer Step 19

Image titled Assign an IP Address on a Linux Computer Step 21

Expert Q&A

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

how to change ip address in linux using command line

You Might Also Like

Set up a Network in Ubuntu

About This Article

Jack Lloyd

Reader Success Stories

Buddy HaDagi

Buddy HaDagi

Jan 27, 2017

Is this article up to date?

Dmitry Ugay

Dmitry Ugay

Oct 10, 2017

Am I a Narcissist or an Empath Quiz

Featured Articles

Play FIFA 23 Career Mode

Trending Articles

Talk to a Girl in a Group

Watch Articles

Make Homemade Soup

wikiHow Tech Help Pro:

Level up your tech skills and stay ahead of the curve

Tecmint: Linux Howtos, Tutorials & Guides

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 .

Configure Static IP in RHEL Systems

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 .

Configure Static IP in Debian Systems

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:

Check IP Addresses of Network Interfaces

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.

Check IP Address of Network Interface

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.

Check IP Address of Interface

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:

Show IP Address in Color Output

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:

Show IP Address in 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:

Show IP Address in Readable Format

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:

Remove Network IP Address in Linux

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:

Enable Network Interface in Linux

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:

Disable Network Interface in Linux

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:

Flush Network IP Addresses in Linux

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:

Check Network 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:

Add Network Route in Linux

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:

Remove Network Route in Linux

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:

Add Network Gateway in Linux

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:

Remove Network Gateway in Linux

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:

Check ARP Cache in Linux

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:

Add ARP Cache in Linux

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:

Remove ARP Cache in Linux

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:

Flush ARP in Linux

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:

Set Network MTU in Linux

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:

Change Network MAC Address in Linux

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.

Support Us

We are thankful for your never ending support.

Related Posts

Linux tee Command Examples

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

Linux Tee and Xargs Command Examples

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

sysctl Command Examples in Linux

How to Modify Linux Kernel Variables Using sysctl Command

Clear Linux Terminal Screen

4 Useful Commands to Clear Linux Terminal Screen

Extract tar.xz File in Linux

How to List and Extract tar.xz File in Linux

Find Parent Process PID 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.

Changing IP addresses on Linux systems

Sandra Henry-Stocker

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 .

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.

how to change ip address in linux using command line

IMAGES

  1. Its easy to change your IP address using a graphic interface but did you know that Linux also

    how to change ip address in linux using command line

  2. How To Change IP Address with Terminal on Linux

    how to change ip address in linux using command line

  3. How to Change Your IP Address From the Command Prompt in Windows

    how to change ip address in linux using command line

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

    how to change ip address in linux using command line

  5. How to Change IP Address in Command Prompt (Renew IP)

    how to change ip address in linux using command line

  6. Linux Static IP Address Configuration

    how to change ip address in linux using command line

VIDEO

  1. Finding Applications in Linux using command line (အခြေခံ) #linux

  2. Upgrade All Windows Application's with one command (winget) 📈😱 #shorts

  3. How To Configure A Static IP Address and DNS on Ubuntu Linux

  4. How To Shut Down Your PC || Shut Down PC Like A Pro|| Shut Down Computer and Laptop #shorts

  5. Command to show IP of Linux Server ?

  6. How to Find your IP address in Windows #shorts

COMMENTS

  1. How to Change Your IP Address From the Command Line in Linux

    This trick should work on all Debian-based Linux distros, including Ubuntu. To get started, type ifconfig at the terminal prompt

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

  3. How to Change IP Address in Linux

    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

  4. How to change IP address in Linux by command line

    Super Simple How to Tutorial Videos in Technology.The only channel that is backed up by computer specialist experts who will answer your

  5. Changing IP address using Command line interface CLI on Windows

    In this video we are going to assign static IP address to Window 10 and Kali Linux computers#staticIP.

  6. How to Set a Static IP Address in Linux

    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

  7. 3 Ways to change ip address 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.

  8. How to Assign an IP Address on a Linux Computer

    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

  9. 24 Useful "IP" Commands to Configure Network Interfaces

    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

  10. Changing IP addresses on Linux systems

    Changing the IP address on a Linux system involves both changing the IP address using the ifconfig command and modifying the files that will