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

How to Assign an IP Address on a Linux Computer

Last Updated: July 28, 2022 Tested

Debian, Ubuntu, & Linux Mint

Red hat, centos, & fedora.

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

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

Step 1 Verify your Linux version.

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

Step 3 Switch to root.

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

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

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

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

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

Step 6 Change the item's IP address.

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

Step 7 Assign a default gateway.

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

Step 9 Check your item's new IP address.

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

Step 6 Switch to the network scripts directory.

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

Step 9 Edit the network's information.

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

Step 10 Enter a new IP category.

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

Step 12 Save and exit the file.

Expert Q&A

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

how to change computer ip address linux

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

You Might Also Like

Set up a Network in Ubuntu

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

About This Article

Jack Lloyd

  • Send fan mail to authors

Reader Success Stories

Buddy HaDagi

Buddy HaDagi

Jan 27, 2017

Is this article up to date?

Buddy HaDagi

Dmitry Ugay

Oct 10, 2017

Am I a Narcissist or an Empath Quiz

Featured Articles

Start a Text Conversation with a Girl

Trending Articles

How to Take the Perfect Thirst Trap

Watch Articles

Wrap a Round Gift

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

How to use the ip command on linux.

It is time to break up with ifconfig.

Quick Links

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

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

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

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

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

We'll look at the following objects:

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

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

The following commands are all equivalent:

ip address show

ip addr show

ip address show in a terminal window

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

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

Let's break down all the information we received:

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

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

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

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

ip -4 addr in a terminal window

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

ip -6 addr in a terminal window

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

ip addr show dev lo

ip addr show dev enp0s3

ip addr show dev lo in a terminal window

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

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

ip -4 addr show dev enp0s3

ip -4 addr show dev enp0s3 in a terminal window

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

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

We type the following:

sudo ip addr add 192.168.4.44/24 dev enp0s3

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

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

ip -4 addr show dev enp0s3 in a terminal window

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

ping 192.168.4.44

ping 192.168.4.44  in a terminal window

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

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

sudo ip addr del 192.168.4.44/24 dev enp0s3

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

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

ip -4 addr show dev enp0s3 in a terminal window

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

ip link show

ip link show: in a terminal window

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

ip link show enp0s3

ip link show enp0s3 in a terminal window

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

sudo ip link set enp0s3 down

sudo ip link set enp0s3 down in a terminal window

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

ip link show enp0s3 in a terminal window

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

sudo ip link set enp0s3 up

sudo ip link set enp0s3 up in a terminal window

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

ip link show enp0s3 in a terminal window

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

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

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

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

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

ip route in a terminal window

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

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

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

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

Let's take a look:

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

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

Let's break it down:

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

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

ip route list 192.168.4.0/24

ip route list 192.168.4.0/24 in a terminal window

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

ip link show in a terminal window

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

sudo ip addr add 192.168.121.1/24 dev enp0s8

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

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

sudo ip route delete default via 192.168.4.1 dev enp0s8

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

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

sudo ip route add 192.168.121.0/24 dev enp0s8 metric 100

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

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

ip route in a terminal window

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

sudo ip route delete 192.168.4.0/24 dev enp0s8

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

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

We type the following to confirm:

ip route in a terminal window

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

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

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

How To Change IP Address Linux

Copy to Clipboard

  • How-To Guides
  • Tech Setup & Troubleshooting

how-to-change-ip-address-linux

Introduction

Changing the IP address in a Linux system is a valuable skill that can come in handy for a variety of reasons. Whether you want to access geographically restricted content, troubleshoot network issues, or boost security, being able to modify your IP address gives you more control over your network connection.

Linux, known for its flexibility and customization options, provides several methods to change the IP address. In this article, we will explore different approaches to altering the IP address in Linux and discuss their advantages and use cases.

From command-line interfaces (CLI) to graphical user interfaces (GUI), Linux offers diverse options to suit different user preferences and skill levels. We will cover methods using the CLI, network manager GUI, configuring static IP addresses, and obtaining dynamic IP addresses through DHCP.

Whether you are a beginner or an experienced Linux user, understanding how to change the IP address will prove invaluable in managing and troubleshooting your network connections. So let’s dive in and discover the various methods to change the IP address in Linux!

Why Change IP Address in Linux?

There are several compelling reasons why you might want to change your IP address in a Linux system. Let’s explore some of the most common scenarios:

  • Access Geographically Restricted Content: Many online platforms and streaming services restrict access to certain regions. By changing your IP address, you can bypass these restrictions and gain access to content that might otherwise be unavailable in your location.
  • Enhance Online Privacy and Security: Your IP address is a unique identifier that can be used to track your online activities. Changing your IP address can help protect your privacy and make it more difficult for others to trace your online presence and data.
  • Troubleshoot Network Issues: Changing the IP address can sometimes resolve network problems, such as connectivity issues or conflicts with other devices on the network. By assigning a new IP address, you can refresh your network connection and potentially resolve any underlying issues.
  • Prevent IP Address Blocking: In some cases, you may find yourself blocked from accessing certain websites or services due to your IP address being flagged or banned. Changing your IP address can help circumvent these restrictions and regain access to the blocked content.
  • Secure Remote Access: If you need to access your Linux system remotely, changing the IP address can add an extra layer of security. By regularly changing your IP address, you can make it more difficult for unauthorized individuals to gain access to your system.
  • Network Testing and Configuration: Changing IP addresses can also be beneficial for network testing and configuration purposes. It allows you to simulate different network setups, test connectivity under various conditions, and ensure that your network infrastructure is functioning as intended.

These are just a few examples of why you might want to change your IP address in Linux. By understanding the reasons behind IP address modifications, you can make informed decisions and leverage this capability to enhance your online experience and network management.

Different Methods to Change IP Address in Linux

Linux offers various methods to change the IP address, providing flexibility and options based on the user’s preference and technical expertise. Let’s explore the different approaches:

The CLI is a powerful tool for Linux users to change their IP address. By utilizing commands such as ifconfig and ip, users can easily modify their network settings directly from the terminal. This method is ideal for those who prefer a command-line interface and have knowledge of Linux networking commands.

Linux distributions that include a graphical user interface often provide a Network Manager tool for managing network settings. Through the Network Manager GUI, users can easily change their IP addresses by selecting the desired network connection, accessing its properties, and modifying the IP address settings. This method is suitable for users who prefer a visual interface and are comfortable navigating through system settings.

Another method to change the IP address in Linux is by configuring a static IP address. This involves manually assigning a specific IP address to the network interface. By configuring a static IP address, users can have a consistent and predictable IP address for their system. This is especially useful for servers or devices that require a fixed IP address for networking and remote access purposes.

DHCP (Dynamic Host Configuration Protocol) allows Linux systems to automatically obtain IP addresses from a DHCP server. By enabling DHCP, the Linux system will request and receive an IP address dynamically from the DHCP server whenever it connects to the network. This method is convenient for users who prefer automatic IP address assignment and don’t require a specific IP address for their system.

These are the different methods available for changing the IP address in Linux. Each method has its own advantages and use cases, so choose the one that best suits your needs and preferences. Whether you prefer the CLI, the Network Manager GUI, static IP configuration , or dynamic IP assignment through DHCP, Linux provides the flexibility to adapt to different networking requirements.

Method 1: Changing IP Address Using Command Line Interface (CLI)

The Command Line Interface (CLI) is a powerful tool for changing the IP address in Linux using various networking commands. Here’s how you can change the IP address using the CLI:

  • Open the terminal on your Linux system. You can usually find the terminal application in the Applications or System Tools menu.
  • Type the following command to check the current IP address configuration:
  • Identify the network interface you want to modify. Common interfaces include eth0 (Ethernet) or wlan0 (Wi-Fi).
  • Use the following command to change the IP address for the desired network interface:

Replace [interface-name] with the name of the network interface you identified in step 3. Replace [new-IP-address] with the new IP address you want to assign to the interface. Replace [netmask] with the appropriate netmask for your network.

For example, to change the IP address of the eth0 interface to 192.168.1.100 with a netmask of 255.255.255.0, you would use the following command:

ifconfig eth0 192.168.1.100 netmask 255.255.255.0

  • Verify the changes by running the ifconfig command again. You should see the updated IP address configuration for the specified network interface.

Changing the IP address using the CLI provides a quick and efficient way to modify network settings in Linux. This method is particularly suitable for users who are comfortable working with the command line and prefer a more direct approach for network configuration.

Remember, the changes made using the CLI are temporary and will be reset after the system is restarted. To make the changes persistent, additional steps such as modifying configuration files may be required.

Now that you know how to change the IP address using the CLI, let’s move on to exploring other methods using the Network Manager GUI, static IP configuration, and DHCP in Linux.

Method 2: Changing IP Address Through Network Manager GUI

Linux distributions often come equipped with a graphical user interface (GUI) that includes a Network Manager tool, providing a user-friendly way to change the IP address. Follow these steps to modify your IP address using the Network Manager GUI:

  • Click on the Network Manager icon located on the system tray or taskbar. It is usually represented by an icon with two arrows forming a circle or a computer monitor symbol.
  • Select the network connection you want to modify. This could be a wired or wireless connection, depending on your system configuration.
  • Right-click on the selected connection and choose “Connection Information” or a similar option from the context menu.
  • A Network Manager window will open, displaying detailed information about the selected network connection.
  • Click on the “IPv4” or “IPv6” tab, depending on the IP version you want to modify.
  • From the drop-down menu, select the desired method for obtaining the IP address: Automatic (DHCP), Manual, or Shared with other computers.
  • If you choose the Manual option, you can enter the new IP address, subnet mask, gateway, and DNS servers manually.
  • Click “Apply” or “OK” to save the changes.
  • Once the changes are saved, the network connection will be updated with the new IP address.

The Network Manager GUI provides an intuitive interface for changing the IP address in Linux. It is especially useful for users who prefer a visual approach or find the command-line interface intimidating. By following these steps, you can easily modify your IP address and related network settings.

Keep in mind that the interface and options may vary slightly depending on the Linux distribution and desktop environment you are using. Nevertheless, the overall process for changing the IP address through the Network Manager GUI remains similar across different Linux systems.

Now that you are familiar with changing the IP address using the Network Manager GUI, let’s explore other methods, including configuring a static IP address and using DHCP to obtain a dynamic IP address in Linux.

Method 3: Configuring a Static IP Address in Linux

Configuring a static IP address in Linux involves manually assigning a specific IP address to your network interface. This can be useful in situations where you need a consistent and predictable IP address for your system, such as for servers or devices that require remote access. Follow these steps to configure a static IP address:

  • Open the terminal application on your Linux system.
  • Run the following command to open the network configuration file in a text editor:

sudo nano /etc/network/interfaces

Note: The above command assumes you are using a Debian-based distribution. For other distributions, the network configuration file may be located elsewhere or have a different name.

  • Locate the line that corresponds to the network interface you want to configure and modify. The line might look like “iface eth0 inet dhcp” or “iface ens33 inet dhcp” depending on your system configuration.
  • Change the line to the following format to configure a static IP address:

Replace [interface-name] with the name of the network interface you want to configure. Replace [desired-IP-address], [netmask], and [gateway-IP-address] with your desired IP address, netmask, and gateway IP address respectively.

For example, if you want to configure a static IP address for the eth0 interface with an IP address of 192.168.0.100, a netmask of 255.255.255.0, and a gateway of 192.168.0.1, the modified lines would look like this:

iface eth0 inet static address 192.168.0.100 netmask 255.255.255.0 gateway 192.168.0.1

  • Save the changes and exit the text editor.
  • Restart the networking service to apply the new static IP configuration. You can do this by running the following command:

sudo systemctl restart networking

  • Verify the changes by running the ifconfig command or using the Network Manager GUI. The network interface should now be assigned the static IP address you configured.

By following these steps, you can easily configure a static IP address in Linux. This method ensures that your system always uses the same IP address, which is particularly useful for devices that require a stable and predictable network configuration.

Remember to adjust the network configuration file and interface name according to your Linux distribution and network setup.

Now that you understand how to configure a static IP address, let’s explore the final method: using DHCP to obtain a dynamic IP address in Linux.

Method 4: Using DHCP to Obtain a Dynamic IP Address

DHCP (Dynamic Host Configuration Protocol) allows Linux systems to automatically obtain IP addresses from a DHCP server. This method is suitable for users who prefer automatic IP address assignment and don’t require a specific IP address for their system. Follow these steps to use DHCP to obtain a dynamic IP address:

  • Open the network configuration file in a text editor. The location and filename may vary depending on your Linux distribution, but it is commonly found at “/etc/network/interfaces”.
  • Locate the line that corresponds to the network interface you want to configure.
  • Change the line to the following format to use DHCP:

iface [interface-name] inet dhcp

Replace [interface-name] with the name of the network interface you want to configure. For example, if you want to use DHCP for the eth0 interface, the modified line would look like this:

iface eth0 inet dhcp

  • Restart the networking service to apply the new configuration. You can do this by running the following command:
  • Your Linux system will now use DHCP to obtain a dynamic IP address. The DHCP server on the network will assign an IP address to your system automatically.
  • Verify the changes by running the ifconfig command or using the Network Manager GUI. The network interface should now be assigned a dynamic IP address.

Using DHCP to obtain a dynamic IP address is a straightforward method that allows for automatic IP address assignment. This approach is ideal for users who prefer ease of configuration and don’t require a specific IP address for their system.

With this method explored, you now have a comprehensive understanding of different ways to change the IP address in Linux. Whether you prefer using the command-line interface, the Network Manager GUI, configuring a static IP address, or relying on DHCP for dynamic IP assignment, Linux provides the flexibility to adapt to your networking requirements.

Frequently Asked Questions (FAQs)

Here are some frequently asked questions about changing IP addresses in Linux:

  • Can I change my IP address without restarting the system?

Yes, you can change your IP address without restarting the system. In most cases, modifying the network settings or restarting the networking service will apply the changes immediately without requiring a system reboot.

  • Will changing my IP address affect my internet connection?

Changing your IP address may temporarily interrupt your internet connection while the changes take effect. However, once the new IP address is assigned and the network is reconfigured, your internet connection should resume normally.

  • Can I assign multiple IP addresses to a single network interface?

Yes, you can assign multiple IP addresses to a single network interface in Linux. This is known as IP aliasing or multiple IP address configuration. It allows a single network interface to have multiple IP addresses, each serving different purposes or applications.

  • Can I revert back to my original IP address after changing it?

Yes, you can revert back to your original IP address by modifying the network configuration settings or restarting the system. Alternatively, if your network uses DHCP to assign IP addresses dynamically, you can simply disconnect and reconnect to the network to obtain your original IP address.

  • Are there any security considerations when changing the IP address?

Changing your IP address can provide some level of security by making it more challenging for potential attackers to target your system. However, it is important to remember that changing the IP address alone is not a comprehensive security measure. It is recommended to implement additional security measures, such as using firewalls and keeping your system up-to-date with patches and security fixes.

These are some common questions that arise when it comes to changing IP addresses in Linux. If you have further inquiries or encounter specific issues, it is advisable to consult relevant documentation or seek guidance from the Linux community.

Changing the IP address in Linux is a valuable skill that allows for better control over network connections and can address various needs such as accessing restricted content, troubleshooting network issues, and enhancing security. In this article, we explored different methods to change the IP address in Linux.

We started by discussing the benefits of changing the IP address, including accessing geographically restricted content, enhancing privacy and security, troubleshooting network issues, and more. Understanding these reasons can help users make informed decisions regarding their IP address modifications.

We then explored four different methods to change the IP address in Linux:

  • Method 1: Changing IP Address Using Command Line Interface (CLI): This method involves using networking commands in the terminal to modify the IP address directly. It is suitable for users who prefer the command line and have knowledge of Linux networking commands.
  • Method 2: Changing IP Address Through Network Manager GUI: This method utilizes the graphical user interface of the Network Manager tool to modify the IP address. It is user-friendly and ideal for those who prefer a visual approach.
  • Method 3: Configuring a Static IP Address in Linux: This method involves manually assigning a specific IP address to the network interface. It ensures a consistent and predictable IP address, making it useful for servers and devices that require remote access.
  • Method 4: Using DHCP to Obtain a Dynamic IP Address: This method allows the system to automatically obtain an IP address from a DHCP server, making it convenient for users who prefer automatic IP address assignment.

Each method has its own advantages and use cases, providing flexibility for different user preferences and networking requirements.

By mastering these methods, Linux users can effectively manage their network connections and make necessary IP address modifications when needed. Whether you are a beginner or an experienced Linux user, having the ability to change the IP address in Linux is a valuable skill that can enhance your overall network management experience.

Now, armed with this knowledge, you can confidently navigate the Linux environment and make necessary changes to your IP address as required. So go ahead, explore the different methods, and unlock the full potential of your Linux system!

Leave a Reply Cancel reply

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

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

  • Crowdfunding
  • Cryptocurrency
  • Digital Banking
  • Digital Payments
  • Investments
  • Console Gaming
  • Mobile Gaming
  • VR/AR Gaming
  • Gadget Usage
  • Gaming Tips
  • Online Safety
  • Software Tutorials
  • Tech Setup & Troubleshooting
  • Buyer’s Guides
  • Comparative Analysis
  • Gadget Reviews
  • Service Reviews
  • Software Reviews
  • Mobile Devices
  • PCs & Laptops
  • Smart Home Gadgets
  • Content Creation Tools
  • Digital Photography
  • Video & Music Streaming
  • Online Security
  • Online Services
  • Web Hosting
  • WiFi & Ethernet
  • Browsers & Extensions
  • Communication Platforms
  • Operating Systems
  • Productivity Tools
  • AI & Machine Learning
  • Cybersecurity
  • Emerging Tech
  • IoT & Smart Devices
  • Virtual & Augmented Reality
  • Latest News
  • AI Developments
  • Fintech Updates
  • Gaming News
  • New Product Launches

Close Icon

How To Make A Painting Minecraft

How to make a item frame in minecraft, related post, how to get a invisible item frame in minecraft, how to use a hopper in minecraft, how to make tripwire minecraft, how to plant pumpkins in minecraft, how to make a dispenser in minecraft, related posts.

How To Configure Ip Address For Ethernet

How To Configure Ip Address For Ethernet

How To Find A Device IP Address

How To Find A Device IP Address

How To Find My Ip Address For Wifi

How To Find My Ip Address For Wifi

How To Setup A Linux Server For Remote Accessing IoT Devices

How To Setup A Linux Server For Remote Accessing IoT Devices

How To Change The IP Address On My Computer

How To Change The IP Address On My Computer

How To Find Default Gateway IP Address

How To Find Default Gateway IP Address

How To Find Ethernet Ip Address

How To Find Ethernet Ip Address

How To Find The IP Address Of A Website

How To Find The IP Address Of A Website

Recent stories.

How To Make A Painting Minecraft

The Impact of 3D Printing on Traditional Manufacturing: A New Era of Innovation

Unlocking the Realm of 3D Character Game Design

Unlocking the Realm of 3D Character Game Design

How To Get A Invisible Item Frame In Minecraft

Unlocking Creativity: How Essay and Content Creator Resources Empower Writers

Enhancing Software Development Processes with Artificial Intelligence

Enhancing Software Development Processes with Artificial Intelligence

Robots.net

  • Privacy Overview
  • Strictly Necessary Cookies

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.

If you disable this cookie, we will not be able to save your preferences. This means that every time you visit this website you will need to enable or disable cookies again.

Learn Ubuntu

Static IP in Ubuntu

Set static IP in Ubuntu using Terminal

Pratham Patel

Table of Contents

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

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

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

Please enable JavaScript

Step 1: Identify the correct network interface

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

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

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

Ubuntu Server

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

Doing so will show a similar result:

The output enumerates network interfaces with numbers.

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

Ubuntu Desktop

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

It has a pretty CLI output :)

Run the following command to view the available network interfaces:

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

Here is what it looks like on my computer:

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

how to change computer ip address linux

Step 2: See current IP address

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

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

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

Step 3: See the gateway

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

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

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

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

Make a note of your gateway address.

Step 4: Set static IP address

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

Step 4-A: Disable cloud-init if present

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

Run the following command to check:

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

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

Add the following line to it:

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

Back to Step 4

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

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

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

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

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

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

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

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

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

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

To apply the settings, run the following command:

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

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

Perfect! The IP address has now changed successfully.

how to change computer ip address linux

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

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

You might also like

How to Open and Edit bashrc file in Ubuntu

How to Open and Edit bashrc file in Ubuntu

Sagar Sharma

How to Quit the Terminal in Ubuntu

How to Find SSH Keys in Ubuntu

How to Find SSH Keys in Ubuntu

Tecmint: Linux Howtos, Tutorials & Guides

How to Set Static IP Address and Configure Network in Linux

If you are a Linux system administrator, time will come when you will need to configure networking on your system. Unlike desktop machines where you can use dynamic IP addresses, on a server infrastructure, you will need to setup a static IP address (at least in most cases).

Read Also: How to Set or Change System Hostname in Linux </p

This article is meant to show you how to configure static IP address on most frequently used Linux distributions.

For the purpose of this tutorial, we will use the following Internet Protocol version 4 (IPv4) details:

Configure Static IP Address in RHEL/CentOS/Fedora:

To configure static IP address in  RHEL / CentOS / Fedora , you will need to edit:

Where in the above "ifcfg-eth0" answers to your network interface eth0 . If your interface is named “ eth1" then the file that you will need to edit is "ifcfg-eth1" .

Let’s start with the first file:

Open that file and set:

Note : Make sure to open the file corresponding to your network interface. You can find your network interface name with ifconfig -a command .

In that file make the following changes:

You will only need to edit the settings for:

  • DNS1 and DNS2

Other settings should have already been predefined.

Next edit resolve.conf file by opening it with a text editor such as nano or vi :

Once you have made your changes restart the networking with:

Set Static IP Address in Debian / Ubuntu

To setup static IP address in Debian / Ubuntu , open the following file:

You may see a line looking like this:

Change it so it looks like this:

Save the file and then edit /etc/resolv.conf like this:

Restart the networking on your system with:

Your static IP address has been configured.

Conclusion:

You now know how to configure a static IP address on a Linux distro. If you have any questions or comments, please do not hesitate to submit them in the comment section below.

Previous article:

Next article:

Photo of author

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

Related Posts

Extract Linux Tar Files Different or New Directory

How to Extract Tar Files to Specific or Different Directory in Linux

Debian Goodies Utilities to Manage Debian Packakges

8 Useful ‘Debian Goodies Utilities’ for Package Management

Delete User Accounts with Home Directory in Linux

How to Delete User Accounts and Their Home Directories in Linux

Find and Kill Running Processes in Linux

How to Find and Kill Running Processes in Linux

Set System Time, Date and Timezone in Linux

How to Set Time, Timezone and Synchronize System Clock in Linux

FFMPEG Command Examples in Linux

15 Must-Know FFmpeg Commands for Video, Audio & Image Conversion

32 thoughts on “How to Set Static IP Address and Configure Network in Linux”

The time will come when you will need to configure networking on your system. Unlike desktop machines where you can use dynamic IP addresses, on a server infrastructure, you will need to set up a static IP address (at least in most cases).

Terrible – and my ‘ linux distro ‘ isn’t the same as yours, there’s no ‘ /etc/sysconfig/ ‘ folder.

In Ubuntu 20.04 there is no interfaces file they switch to netplan . If you can update this article to include the new change it will help a lot.

thanks Raouf

Well, this isn’t correct. Just trashed my Linux mint distro

Is it public Static IP? or can I use to access data from other networks?

Failed to restart network.service: Unit network.service not found.

I’m asking a question on a fairly old thread, but just in case, is it possible to do this on a WIFI network?

For example, when using the first command (# nano /etc/network/interfaces ) in Ubuntu, the result I see is:

There isn’t an “ eth0 ” on my server because it is connected by WIFI only. Will it still work using another option?

Yes it will work I think so, just change the settings in the interfaces file as explained in this article.

I set the static IP in ifcfg-eth0, added HWADDR and UUID, but on reboot system does not associate the IP to eth0.

This is VM. Any idea why its happening and steps to troubleshoot.

I think you need to make sure that you select “ manual ” and the correct IP address, subnet mask, and gateway and save the configuration as explained in the article. Also, I personally would select a new and different IP address, so that you can really check if it has been saved by opening the terminal and typing:

after a restart.

If i set ip address as static am not able to ping google.com why and also packages are not installed.

Please give me reply as soon as possible.

@Rajeshkar,

Please add the DNS Name servers in your /etc/resolv.conf file..

@Ravi Saive thanks for your reply , yes i did /etc.resolv.conf also but getting the same problem

@Rajesekar,

The file is /etc/resolv.conf , in this file add your DNS name servers for example.

When I enter the /etc/resolv.conf file, what is it supposed to look like? And when you say “edit” do you mean delete what’s there and write what you’ve provided, or just add new lines?

Hello Marin, Thank you very much for this article. It was a major help in my class project. This is my first time using a vm and it is an awesome learning experience. I’m really glad I ran into this article, it was well written and easy to follow.

Just wanted to say a million thank you’s for this well-written, comprehensive and easily-understood article! Awesome stuff! A real lifesaver too, as I had to quickly configure a static IP for myself to get access to remote computing. Thank you! :-D

A question from a linux newbie. Does this instruction apply for both ubuntu running on my desktop PC as well as debian linux on an embedded board?

Yes, the instructions will works on any Debian/Ubuntu based distribution without any issues..have you tried on your embedded board? does these instructions worked? let us know.

Hi Ravi, thanks for your reply.

Default the folder /etc/sysconfig does not exist on my embedded system. Of Course i could create it as well as the files mentioned, but it would be out of the context of this instructions.

Thanks, Rob

I found here very good stuff! You are doing an excellent job and I like your site! Thanks!

Thanks for finding this site very useful and thanks for appreciating our work, Keep visiting for more such useful articles…

Great job, I was I actually looking for an article like this one. So thank you so very much. Keep up the good work.

Thanks for appreciating and finding this article useful, keep connected to Tecmint for such wonderful articles…:)

What if I have 2 NICs on my server one for LAN & one for WAN and I want to set one of them (WAN) as default gateway? How to configure this server as gateway and as a router.

The easiest way to add default gateway using route command as shown:

Don’t forget to replace the gateway IP address and interface-name in the above command.

One can also use following command to setup static IP on eth0 interface for example. # ifconfig eth0 192.168.1.1 netmask 255.255.255.0 up # route add default gw 192.168.0.1 # service network restart

Thanks for the tip, but I think setting IP address directly from the commandline using ifconfig and route will only allow you to set temporarily, once you reboot, these settings disappears. So, the best option to set static IP address permanently in network configuration files only….

wipe on reboot, so that best option is to set permannetly

Hello Ravi, What is difference between the service “NetworkManager” and “network”

@Augustine,

This article will help you to understand the difference between and NetworkManager and Network: http://askubuntu.com/questions/1786/what-is-the-difference-between-network-manager-and-ifconfig-ifup-etc

Why do we need to specify DNS in both ifcfg-eth0 and resolvlf.conf?

Hello Augustine,

Actually if you have added the DNS servers in the ifcfig-eth0 file the DNS servers will be automatically added to /etc/resolv.conf. You can skip defining the DNS servers in the ifcfig-eth0 file, but then you will need to have them set in /etc/resolv.conf manually. It’s a good practice to make sure that the DNS servers are specified correctly in both files, this is why the article says to set them in both files.

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.

Stack Exchange Network

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

Q&A for work

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

How to change ip address in ubuntu desktop through command line

In Ubuntu desktop 13.04 changing /etc/network/interfaces file don't change ip address or convert DHCP to static network interface configuration. after changing the file I tried

----------EDIT----------

I have connected to system with ssh.

  • command-line
  • network-manager

Necktwi's user avatar

  • How are you changing the IP when editing the` /etc/network/interfaces` file? –  Mitch Aug 21, 2013 at 11:46
  • @Mitch link –  Necktwi Aug 21, 2013 at 11:50
  • 1 You mean to say you edited that file but it doesn't have any effect? It doesn't change the IP address? –  Alaa Ali Aug 21, 2013 at 11:52
  • @Alaa i did sudo service networking restart –  Necktwi Aug 21, 2013 at 11:53

6 Answers 6

By default, Ubuntu (or Network Manager to be specific) ignores the /etc/network/interfaces file. To make the changes you made take effect, execute the following commands:

Assuming that wlan0 is the interface you are editing. Once you do that, wlan0 will come up with the settings you have under its stanza in /etc/network/interfaces .

Edit: since you're connected through SSH. You can try the following:

Edit /etc/NetworkManager/NetworkManager.conf and change ifdown managed to false :

  • How to restart the networking service?

Community's user avatar

  • if i use ifdown i will loose connection to the system. If it dont work there is no way to connect again. –  Necktwi Aug 21, 2013 at 12:10
  • i can try restarting the system but if static ip is not set i cant know its dynamic new ip –  Necktwi Aug 21, 2013 at 12:14
  • @neckTwi try my updated answer. Also, are you sure it's going to have a different IP? Usually, there's a lease period where, even if you restart the machine, it'll still get the same IP until the pre-defined lease period expires. But that depends of course, I'm just saying what's on my mind. –  Alaa Ali Aug 21, 2013 at 12:17
  • what does [ifupdown] managed=false mean? –  Necktwi Aug 21, 2013 at 12:20
  • If it is set to true, NetworkManager "manages" the interfaces mentioned in /etc/network/interfaces . If it's set to false, NetworkManager does not manage the interfaces mentioned there. –  Alaa Ali Aug 21, 2013 at 12:27

Try this. Just press Ctrl + Alt + T on your keyboard to open Terminal. When it opens, run the command(s) below:

This is done with the help of guntbert

Once done save and exit

add this line DHCP mode

Static mode

Once done save the file, and:

Mitch's user avatar

  • These aren't permanent changes. They'll be overridden when the computer restarts. –  Alaa Ali Aug 21, 2013 at 11:52
  • that dont survive system restart –  Necktwi Aug 21, 2013 at 11:52
  • Do you have a static or dynamic IP? –  Mitch Aug 21, 2013 at 11:57
  • @guntbert Is this better? Thanks :) –  Mitch Aug 21, 2013 at 16:49
  • This doesn't work (or no longer works). Ubuntu doesn't seem to care about /etc/network/interfaces . –  giusti Mar 12, 2017 at 13:39

You can change your ip address by using the following script:

Open terminal with Ctrl + Alt + t and type the following command:

Find eth0 section and setup IP address as follows:

Save and close the file. Once done, restart network:

Verify new IP address by using the following command :

Seth's user avatar

  • This is just a vehicle for your own websites; please disclose your affiliation to ip-details.com and Whoisxy.com , or don't link to these sites from all your posts . See the help center . –  Martijn Pieters Jun 19, 2014 at 11:31

I am posting this answer to give another dimension to the question and existing answers, not as a direct answer to the original question. Your IP will be lost at reboot. However, I think it's worth you understanding these commands, iproute2 package is the currently method of on-the-fly interface management via the CLI. Lots of people are still writing scripts using ifconfig for example.

I think it's worth noting the use of the iproute2 packages;

Show current IPs on all interface ( ip addr )

Add an IP address to my wireless interface ( ip addr add )

Show my IP addresses again, note the additional IP on wlan0 ( ip addr )

Show the link state of my interfaces ( ip link )

Delete this 2nd IP address from my wireless interface ( ip addr delete )

Show IP addresses just for wlan0 to check ( ip addr show wlan0 )

The same commands could have been used to remove my current IP, 172.22.0.221 then add another, but I would have lost connectivity, which I can't right now. Below are those commands though, after which I would also need to add a new default route route;

Baldrick's user avatar

From t he detailed instructions on this site :

  • disable the graphical management of your network connection in /etc/NetworkManager/NetworkManager.conf
  • Gather the information for the static IP (interface, IP to be used, default gateway, subnet,DNS)
  • Modify /etc/network/interfaces to include the information above.
  • Restart networking and network-manager services

steampowered's user avatar

This is the right way to do it.

lewis4u's user avatar

You must log in to answer this question.

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

  • The Overflow Blog
  • Who owns this tool? You need a software component catalog
  • Featured on Meta
  • Upcoming privacy updates: removal of the Activity data section and Google...
  • Changing how community leadership works on Stack Exchange: a proposal and...
  • Notifying users about the policy on AU concerning AI-generated content
  • AI-generated content is not permitted on Ask Ubuntu

Hot Network Questions

  • Approximating norm of a Hilbert space point with the norm of a vector
  • Maze-Jigsaw Fusion
  • Why did it take so long for the U.S. government to give Medicare the power to negotiate prescription drug prices directly with drug companies?
  • Would a giant ball on earth roll towards the poles?
  • Can I raise my ceiling in my shed?
  • Which type of female connector is this?
  • Is it okay for a co-author to share an unfinished manuscript with others?
  • How to not fear the supernatural?
  • How do I properly present dialogue in a scene with two female characters?
  • How to replace one item with another in itemize?
  • Examples of stochastic processes that don't exist
  • How do I compute a probability from the MGF?
  • What is the most logical way to have my dragon breathe lightning?
  • How do I read the last lines of a huge log file?
  • Hiding public IP address while using free DynDns?
  • How not to sound midi without real instrument?
  • Can I run wires from separate panels through the same conduit?
  • How can I create OCW that won't activates every block, but will activates only when I call function that it represents?
  • Does adding twist to wing always decrease induced drag and what are its effect on parasite drag?
  • What happens when the Sitecore license got expired?
  • Is there a flight search engine that can order results based on cost and travel time *together*?
  • securely tunneling through a MITM proxy
  • How does EXT4 handle sudden lack of space in the underlying storage?
  • What's wrong with this derivation of the volume of a hemisphere?

how to change computer ip address linux

Network Settings

How to change ip address on ubuntu.

change ip address ubuntu

IP address assignment is typically handled by a DHCP server. You can request the server to end the DHCP lease and release your device’s current IP address. Depending on how the server is configured, your device may or may not be assigned a different IP address with this method.

Another way to change your IP address is with DHCP reservation. But that’s a feature that’s configured from your router settings. Instead of such methods, we’ll specifically cover ways to change your IP address directly from Ubuntu in this article.

The easiest way to change your IP address on Ubuntu is via the NetworkManager GUI.

ubuntu settings app

Netplan is used to configure networking on Linux systems through the networkd or NetworkManager backends. It reads the configuration from a YAML description file and hands off device control to the specified networking daemon.  

To change your IP address, you’ll need to modify the netplan config file. The default config file named 01-network-manager-all.yaml or 50-cloud-init.yaml can be found in the /etc/netplan directory. 

First, check the interface’s logical name.

Open the config file with a text editor like nano.

Use the configuration provided below. Ensure the number of prefix spaces is correct as shown here or the config won’t work.  

We’re using NetworkManager as the backend here. We specified enp1s0 as the Ethernet interface and DHCP is disabled . Then, we set the interface’s IP address with a Class C subnet prefix length ( 192.168.122.50/24 ).

We then set the gateway , defined it via a default route , and finally set the DNS servers . Remember to change these values as appropriate for your own network. After your configuration looks good, apply the new config with

You can verify the changes with

IP Address changes made by the previous two methods were persistent. But if you only want to make a temporary IP change that’ll revert upon connection reset, you can use the ip command.

First, identify the interface.

Use the add option to add a new IP address to the interface. Remember to adjust the IP address and interface name values.

Remove the old IP address with del option like so

Here, we changed the IP address of the enp1s0 interface from 192.168.122.11 to 192.168.122.186 . Once again, you can verify the change with

Ubuntu desktops use the NetworkManager daemon by default, whereas Ubuntu servers normally handle network configuration with networkd . On such systems, you can edit the network configs in /etc/systemd to change your IP address.

Use the following configuration and adjust the interface name, IP address, gateway, and DNS values as you require.

Save the new configuration and restart the networkd service to apply the changes.

You can also use NetworkManager’s command-line version ( nmcli ) to manage network configurations such as your IP address.

First, list your connections and note the connection name.

You can directly change the IP address configuration, replacing the values with your own like so

We identified that we need to modify Wired connection 1 with the previous command. Then, we set the IPv4 method to manual and set the IP address with prefix , gateway , and DNS values.

Finally, activate the connection and verify the change with

This is sufficient for basic configuration, but nmcli is a highly versatile tool. If you want to learn to make advanced config changes, we recommend using the interactive editor.

The editor will display which settings you can edit (connection profile, ipv4, proxy, etc). Enter help to list the available commands (set, print, describe, save, quit, etc). Enter print ipv4 to list the modifiable IPv4 settings and properties.

You can use the describe command to view the documentation for each setting (e.g., describe ipv4, describe ipv4.addresses). Now, use the set command to set the property values like so

Save the connection with save persistent or save temporary . Then, enter quit to exit nmcli and verify the new config with

Senior Writer

Anup Thapa is a Linux enthusiast with an extensive background in computer hardware and networking. His goal is to effectively communicate technical concepts in a simplified form understandable by new Linux users. To this end, he mainly writes beginner-friendly tutorials and troubleshooting guides. Outside of work, he enjoys reading up on a range of topics, traveling, working out, and MOBAs.

XDA Developers

How to set a static internal IP in Ubuntu

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

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

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

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

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

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

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

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

Setting complete

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

How to set a static internal IP in Ubuntu

IMAGES

  1. How to Find IP Address in Linux [Step-by-Step]

    how to change computer ip address linux

  2. How to Change IP Address in Windows 10

    how to change computer ip address linux

  3. Set IP Address in Linux

    how to change computer ip address linux

  4. How to convert mac address to ip

    how to change computer ip address linux

  5. Does IP Address Change With WiFi? (Factors And Its Types)

    how to change computer ip address linux

  6. 4 Ways to Change IP Address on Windows 10

    how to change computer ip address linux

VIDEO

  1. How to find IP address in windows7

  2. How To Configure Static IP in Ubuntu 18.04 Desktop

  3. CARA KONFIGURASI IP ADDRESS LINUX UBUNTU SERVER 23.10 (MANTIC MINOTAUR) PADA VIRTUALBOX

  4. How to change ip address automatically on Linux

  5. How To Check & Change IP Address in CentOS 7

  6. How to show information about PC IP Addresses and Connections in windows #windows #kalilinux #shorts

COMMENTS

  1. How to Change IP Address in Linux

    The ip command is available on most Linux distributions. For setting an IP address, use it like this: ip addr add [ip_address] dev [interface] For example, add an IP address to the eth1 interface as: sudo ip addr add 192.168.56.21/24 dev eth1. You now have two IP addresses: one from the old configuration and one from the new command:

  2. How To Change IP Address on Linux

    To change your IP address, use "nmcli" on the "device" section and specify that you want to "modify" the "ipv4.address" of your network card. $ nmcli device modify <interface_name> ipv4.address <ip_address>. When using the "nmcli device modify" command, your Network Manager will automatically create a new connection file in ...

  3. 3 Ways to change ip address in Linux

    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.

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

    Change the item's IP address. Type in sudo ifconfig name ipaddress netmask 255.255.255. up—making sure to replace name with your item's name and ipaddress with your preferred IP address—and press ↵ Enter.. To assign an IP of "192.168.2.100" to your ethernet connection ("eth0"), for example, you'd enter sudo ifconfig eth0 192.168..100 netmask 255.255.255. here.

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

    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.

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

    auto eth1 enables automatic configuration for this interface during boot. iface eth1 inet static sets eth1 as an IPv4 interface with a static address. address, netmask, and gateway assign the respective addresses and network. dns-nameservers, while not strictly necessary, sets the DNS servers to use.

  7. How to Set a Static IP Address in Ubuntu

    Set a Static IP in Ubuntu with the GUI. Click the icons at the far-right end of the system bar to show the system menu, then click on the "Wired Connected" menu option. If you're using a wireless connection, instead click the name of your Wi-Fi network. The available connections are displayed.

  8. How to Use the ip Command on Linux

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

  9. How To Change IP Address Linux

    Method 3: Configuring a Static IP Address in Linux. Another method to change the IP address in Linux is by configuring a static IP address. This involves manually assigning a specific IP address to the network interface. By configuring a static IP address, users can have a consistent and predictable IP address for their system.

  10. How to Configure Static IP Address on Ubuntu 20.04

    Depending on the interface you want to modify, click either on the Network or Wi-Fi tab. To open the interface settings, click on the cog icon next to the interface name. In "IPV4" Method" tab, select "Manual" and enter your static IP address, Netmask and Gateway. Once done, click on the "Apply" button.

  11. Linux change ip address

    Task: Change IP address. You can change ip address using ifconfig command itself. To set IP address 192.168.1.5, enter command: # ifconfig eth0 192.168.1.5 netmask 255.255.255. up. # ifconfig eth0. To make permanent changes to IP address you need to edit configuration file according to your Linux distribution.

  12. How to Update Ubuntu IP and Hostname via Bash

    To execute the script, run the below command to invoke the script with bash in your terminal. sudo bash ~/host_deploy.sh. The script prompts you to enter a new hostname and IP address information and reminds you to reboot the host for the changes to take effect.

  13. Set static IP in Ubuntu using Command Line

    Step 2: See current IP address. Now that you know which interface needs to be addressed, let us edit a file. Before I change my IP address/set a static one, let us first see what my current IP address is. $ hostname -I 192.168.122.69. Nice! But let's change it to '192.168.122.128' for demonstration purposes. Step 3: See the gateway

  14. Linux ip Command with Examples

    For example, to bring the interface eth0 online, you would type:. ip link set eth0 up. And to bring if offline. ip link set eth0 down Displaying and Altering the Routing Table #. To assign, remove, and display the kernel routing table use the route object. The most commonly used commands when working with the routes objects are: list, add, and del. Display routing table #

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

    Unlike desktop machines where you can use dynamic IP addresses, on a server infrastructure, you will need to setup a static IP address (at least in most cases). Read Also: How to Set or Change System Hostname in Linux</p. This article is meant to show you how to configure static IP address on most frequently used Linux distributions.

  16. Linux Static IP Address Configuration

    For static IP configuration you need to edit the following files using a text editor such as vi. Edit /etc/sysconfig/network as follows, enter: # cat /etc/sysconfig/network. Sample static ip configuration: NETWORKING=yes HOSTNAME=server1.cyberciti.biz GATEWAY=192.168.1.254.

  17. How to Change IP Address on Linux?

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

  18. How to change ip address in ubuntu desktop through command line

    Add an IP address to my wireless interface (ip addr add) n2:~$ sudo ip a a 10...56/24 dev wlan0 [sudo] password for bensley: Show my IP addresses again, note the additional IP on wlan0 ( ip addr )

  19. Ubuntu Change IP

    To change IP address select Wired or wireless connection and click on properties button: Click on OK > Close to save the changes. ... Ubuntu Linux Change Hostname (computer name) How to change root password in Ubuntu Linux; How to change theme in Ubuntu 16.04/17.10;

  20. Change IP address on Ubuntu Server

    You have two options when configuring the IP address on your Ubuntu Server, and that is either a static IP address or DHCP. A static IP address allows you to manually select your IP address by configuring it on the Linux system, whereas DHCP relies on the router or DHCP server to lease you an IP address - either a reserved one or the next available one that is currently free, depending on ...

  21. How To Change IP Address On Ubuntu

    Open the Settings app and switch to the Network (wired) or Wi-Fi tabs depending on which connection you want to change the IP address for. Click on the Settings cog next to the connection. In the IPv4 tab, set the IPv4 method to Manual and fill in the IP Address, Gateway, and Netmask values.

  22. IP Address Management on Ubuntu

    Step 1: First, open the terminal. Once the terminal is open, you will see a screen like this: Step 2: Enter " ip addr show " command to see the available network adapter which you want to change the IP address and press execute. ip addr show. In this tutorial, we are focusing on " eth0 ". The output will be like this:

  23. How to Set a Static IP Address in Linux

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

  24. How to set a static internal IP in Ubuntu

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

  25. How to change username on Linux

    Open the Users and Groups application. In the User Settings menu, highlight the user whose name you want to change, then click on the first 'Change' option next to the name. Click on 'Change' to get started with changing the name.