Select Your Language

Infrastructure and management.

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

Cloud Computing

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

Integration and Automation

  • Red Hat Application Foundations
  • Red Hat Fuse
  • Red Hat AMQ
  • Red Hat 3scale API Management

How do I change the IP address/netmask and hostname on the command line WITHOUT rebooting the machine?

Here are some example configuration files:

/etc/sysconfig/network

/etc/sysconfig/network-scripts/ifcfg-eth0

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content

Formatting Tips

Here are the common uses of Markdown.

Request a English Translation

Generating machine translation.

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

When Did Minecraft Come Out

  • What Time Does Minecraft 117 Come Out

Related Post

How to make cauldron minecraft, what is the latest minecraft version, how to update minecraft on pc, how to update the minecraft launcher, how to add shaders to 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.

When Did Minecraft Come Out

What Time Does Minecraft 1.17 Come Out

What Is The Latest Minecraft Version

Varda Space Industries Receives Approval To Bring Drug Manufacturing Spacecraft Back To Earth

Largest Text-to-Speech AI Model Shows Emergent Abilities

Largest Text-to-Speech AI Model Shows Emergent Abilities

How To Update The Minecraft Launcher

  • 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 ip address in linux 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 .

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 ip address in linux using command line

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

  • Command Line Interface (CLI)
  • Denial-of-Service Attack (DoS)
  • Desktop Managers
  • Linux Administration
  • Virtual Private Network (VPN)
  • Wireless LAN (Wi-Fi)
  • Privacy Policy

blackMORE Ops Learn one trick a day ….

Setup dhcp or static ip address from command line in linux.

March 26, 2015 Command Line Interface (CLI) , How to , Linux , Linux Administration , Networking 25 Comments

This guide will guide you on how to setup DHCP or static IP address from command Line in Linux. It saved me when I was in trouble, hopefully you will find it useful as well. In case you’ve only got Wireless, you can use this guide to connect to WiFi network from command line in Linux .

Note that my network interface is eth0 for this whole guide. Change eth0 to match your network interface.

Static assignment of IP addresses is typically used to eliminate the network traffic associated with DHCP/DNS and to lock an element in the address space to provide a consistent IP target.

Step 1 : STOP and START Networking service

Some people would argue restart would work, but I prefer STOP-START to do a complete rehash. Also if it’s not working already, why bother?

Step 2 : STOP and START Network-Manager

If you have some other network manager (i.e. wicd, then start stop that one).

Just for the kicks, following is what restart would do:

Step 3 : Bring up network Interface

Now that we’ve restarted both networking and network-manager services, we can bring our interface eth0 up. For some it will already be up and useless at this point. But we are going to fix that in next few steps.

The next command shows the status of the interface. as you can see, it doesn’t have any IP address assigned to it now.

Step 4 : Setting up IP address – DHCP or Static?

Now we have two options. We can setup DHCP or static IP address from command Line in Linux. If you decide to use DHCP address, ensure your Router is capable to serving DHCP. If you think DHCP was the problem all along, then go for static.

Again, if you’re using static IP address, you might want to investigate what range is supported in the network you are connecting to. (i.e. some networks uses 10.0.0.0/8, some uses 172.16.0.0/8 etc. ranges). For some readers, this might be trial and error method, but it always works.

Step 4.1 – Setup DHCP from command Line in Linux

Assuming that you’ve already completed step 1,2 and 3, you can just use this simple command

The first command updates /etc/network/interfaces file with eth0 interface to use DHCP.

The next command brings up the interface.

With DHCP, you get IP address, subnet mask, broadcast address, Gateway IP and DNS ip addresses. Go to step xxx to test your internet connection.

Step 4.2 – Setup static IP, subnet mask, broadcast address in Linux

Use the following command to setup IP, subnet mask, broadcast address in Linux. Note that I’ve highlighted the IP addresses in red . You will be able to find these details from another device connected to the network or directly from the router or gateways status page. (i.e. some networks uses 10.0.0.0/8, some uses 172.16.0.0/8 etc. ranges)

Next command shows the IP address and details that we’ve set manually.

Because we are doing everything manually, we also need to setup the Gateway address for the interface. Use the following command to add default Gateway route to eth0 .

We can confirm it using the following command:

Step 4.3 – Alternative way of setting Static IP in a DHCP network

If you’re connected to a network where you have DHCP enabled but want to assign a static IP to your interface, you can use the following command to assign Static IP in a DHCP network, netmask and Gateway.

At this point if your network interface is not up already, you can bring it up.

Step 4.4 –  Fix missing default Gateway

Looks good to me so far. We’re almost there.

Try to ping http://google.com/ (cause if www.google.com is down, Internet is broken!):

Step 5 : Setting up nameserver / DNS

For most users step 4.4 would be the last step. But in case you get a DNS error you want to assign DNS servers manually, then use the following command:

This will add Google Public DNS servers to your resolv.conf file. Now you should be able to ping or browse to any website.

Losing internet connection these days is just painful because we are so dependent on Internet to find usable information. It gets frustrating when you suddenly lose your GUI and/or your Network Manager and all you got is either an Ethernet port or Wireless card to connect to the internet. But then again you need to memorize all these steps.

I’ve tried to made this guide as much generic I can, but if you have a suggestion or if I’ve made a mistake, feel free to comment. Thanks for reading. Please share & RT.

how to change ip address in linux using command line

Find exact installation date of Linux

Ran into an interesting question today while trying to debug a problem with a monitoring …

Correct way of installing VirtualBox Guest Additions in Kali Linux 2016.2/2017 (Kali Rolling)

How to install VirtualBox Guest Additions in Kali Linux (Kali Rolling / Kali Linux 2016.2 / Kali 2017)

Since Kali Linux 2016 came out (also known as Kali Rolling), it seems that Official …

25 comments

' src=

Just wanted to say, your guides are amazing and should be included into kali’s desktop help manual. Thanks for your awesome work!

' src=

Hi Matt, That’s very kind, thank you. I’m happy that my little contributions are helping others. Cheers, -BMO

' src=

I’ve gone through the steps listed in Step 4.2 and when I check my settings are correct, until I reboot. After I reboot all my settings have reverted back to the original settings. Any ideas?

' src=

The only problem with this is that nowadays Linux machines aren’t always shipped with the tools you use. They are now shipped with the systemd virus so the whole init.d doens’t work anymore and ifconfig isn’t shipped on a large number of distro’s.

Hi, The intention was to show what to do when things are broken badly. In my case, I’ve lost Network Manager and all of Gnome Desktop. I agree this is very old school but I’m sure it’s better than reinstalling. Not sure what distro you’re talking about. I use Debian based Kali (and Debian Wheezy), CentOS(5,6,7) and Ubuntu for work, personal and testing. ifconfig is present is every one of them. ifconfig also exists in all variants of server distro, even in all Big-IP F5’s or CheckPoint Firewalls. Hope that explains my inspiration for this article. Cheers, -BMO

' src=

Hi , I want to say Thank you for your Guide, it’s very useful. and want to add another method for Step 5 : Setting up nameserver / DNS: add nameserver directly to resolv.conf file

nano /etc/resolv.conf

Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)

DO NOT EDIT THIS FILE BY HAND — YOUR CHANGES WILL BE OVERWRITTEN

nameserver 8.8.8.8 nameserver 8.8.4.4 search Home

' src=

nano or vi is not requiered, use “printf” instead “echo”… e.g:

printf “nameserver 8.8.8.8\nnameserver 8.8.4.4\n” >> /etc/resolv.conf

double-check with:

grep nameserver /etc/resolv.conf

' src=

Hey I’m new to VM my eth0 inet addr is 10.0.02.15 but every video I watch their inet addr always starts with 192. I was wondering what I can do to change my inet addr to start with 192. Is this guide a solution

Hi Billy Bob, Is 10.x address coming from VBox internal or from your router? You possibly selected Bridged network. Try juggling between Bridged and NAT. Also look up VBox IP addressing in Google. Cheers -BMO

' src=

Please help, I’ve done all these steps and still I don’t have internet connection with bridged adapter. When I set NAT I have internet connection but with bridged adapter i don’t. I checked with ifconfig eth0 command and I have ip, netmask and broadcast ip. What could be the problem?

' src=

Excellent guide. I haven’t been using any debian based linux distros in a while and forgot where the entries go manually. I was actually kind of surprised how long it took to find your page in google, there is a lot of pages that don’t actually answer the question, but yours was spot on.

' src=

I did all the commands but my IP address doesn’t show up, and now my internet server on Linux iceweasel is down. It’s telling me that “Server not found” I really need help.

' src=

Hi Blackmoreops Thanks for the tutorial. I do have a question tho, in kalisana, I have followed your advice step by step to configure a static ip on my kali VM. But when I check with ifconfig, I still get the ip assigned by my modem? I run the kali vm on fedora 22 host… Is there a way around this? Regards Adexx

' src=

Hey Blackmoreops, Thanks for the great article. Being a total NOOB, I’m wondering if these are the last steps in getting my correct lab setting to enumerate De-Ice 1.100 with nmap. My current setting on Kali 2016 machine are: add:192.168.1.5 , mask: 255.255.255.0, default gw 192.168.1.1. Both machine set to NAT in Virtualbox 5. I’ve tried numerous scans ie., ping, list proctocol verify, and stealth and I’m unable to find any open ports. Help!!!!!!!

Best Regards. C

' src=

i tried on my kali linux but i lost my internet connection

' src=

hello everyone i have got problem on my kali linux with internet. Kali is connected to my wifi but iceweasel can’t open any site. Can you help me solve this problem please ?

' src=

check mtu and DNS

' src=

Followed through all the steps, and it worked. Then I restarted the router, and everything is back to the earlier configuration?

' src=

thanks for tutorial.bu how change the ip that blocked by google :D

' src=

Hello sorry but wasnt able to configure my network. I installed kali into my hdd and im using it as my main OS on this pc(idk if thats recommended or not) . I am curently connected to the internet with an ethernet cable and somehow in th top-right corner it says that is curently connected but when i try to open ice weasel i get a message that tells me “server not found” can someone please tell me how to fix this issue and also i followed your tutorial until the end but i had trouble in the end because i get this message bash: /etc/resolv.conf: no such file or directory . If you can help me i would be so gratefull. Sorry for butchering the english language and its grammar

' src=

Sir, How can we change or spoof dns server in kali Linux.

' src=

I can’t get my static IP address to ping google.

This is what I am trying to do:

ping google.com using a server created with static IP address using Linux Redhat VM Ware,

please help!

' src=

For setting up DHCP using the Command : ifconfig eth0 inet dhcp Also works

For setting up DHCP using command : ifconfig eth0 inet dhcp Also works

Use WordPress.com, Twitter, Facebook, or Google+ accounts to comment (anonymous comments allowed). Leave your solution to help others. Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed .

Privacy Policy on Cookies Usage

Some services used in this site uses cookies to tailor user experience or to show ads.

How-To Geek

How to set a static ip address in ubuntu.

When static is the way forward.

Quick Links

What is a static ip address, setting a static ip in ubuntu, set a static ip in ubuntu with the gui, connection convenience, key takeaways.

After gathering your connection name, subnet mask, and default gateway, you can set a static IP address in the terminal using the nmcli command. Or, in the GNOME desktop, open your connection settings and click the + icon, then enter the info for your static IP address there.

Your home network relies on IP addresses to route data between devices, and sometimes on reconnecting to the network a device's address can change. Here's how to give an Ubuntu Linux computer a permanent IP address that survives reboots.

Everything on your network home network, whether it's using a wired connection or Wi-Fi, has an IP address . IP stands for Internet Protocol. An IP address is a sequence of four numbers separated by three dots. Each IP address that is unique within that network.

IP addresses act as numeric labels. Your router uses these labels to send data between the correct devices. Usually, your router assigns IP addresses. It knows which IP addresses are in use and which are free. When a new device connects to the network, it requests an IP address and the router allocates one of the unused IP addresses. This is called DHCP, or dynamic host configuration protocol .

When a device is restarted or powered off and on, it may receive its old IP address once more, or it might be allocated a new IP address. This is normal for DHCP and it doesn't affect the normal running of your network. But if you have a server or some other computer that you need to be able to reach by its IP address, you'll run into problems if its IP address doesn't survive power downs or reboots.

Pinning a specific IP address to a computer is called allocating a static IP address . A static IP address, as its name suggests, isn't dynamic and it doesn't change even if the computer is power-cycled .

Nmcli is the command-line network manager tool , and can be used to change your IP address, configure network devices, and --- relevant to our purposes --- set up a static IP in Ubuntu.

We're demonstrating this technique on Ubuntu 22.04 LTS, but it ought to work on any Linux distribution, including Ubuntu 23.04. The nmcli tool was released in 2004, so it should be present on just about any standard distribution.

Let's take a look at the network connections that already exist on the computer. We're using the connection command with the show argument.

nmcli connection show

Using nmcli to list network connections

This displays some information about each connection. We only have a single connection configured.

The details of a single network connection displayed by nmcli

The output is wider than the terminal window. This is the information that we're shown.

  • Name : Our network connection is called "netplan-enp0s3."
  • UUID : The universally unique identifier Linux uses to reference this connection internally.
  • Type : This is an ethernet connection.
  • Device : This connection is using the "enp0s3" network interface. It's the only network card in this computer.

We can use the ip command to discover the IP address this computer is using.

The output of the ip addr command showing the ip address of the computer

In the output we can see the "enp0s3" entry, and its current IP address, 192.168.86.117. The "/24" is a shorthand way of saying that this network uses a 255.255.255.0 subnet mask . Take a note of this number, we'll need to use it later.

We need to choose the IP address we're going to set as our static IP address. Obviously, you can't use an IP address that is already in use by another device. One safe way to proceed is to use the current IP address assigned to the Ubuntu system. We know for certain that nothing else is using that IP address.

If we want to use a different IP address, try pinging it. We're going to test whether IP address 192.168.86.128 is in use. If everything else on your network uses DHCP and you get no response to the ping command, it should be safe to use.

ping 192.168.86.128

Using ping to determine if an IP address is in use

Even if another device had previously used that IP address, it'll be given a new IP address when it next boots up. Nothing responds to the ping requests, so we're clear to go ahead and configure 192.168.86.128 as our new static IP.

We also need to know the IP address of your default gateway , which will usually be your broadband router. We can find this using the ip command and the route option, which we can abbreviate to "r."

Using the ip command to find the IP address of the default gateway

The entry that starts with "default" is the route to the default gateway. Its IP address is 192.168.86.1. Now we can start to issue commands to set up our static IP address.

The first command is a long one.

sudo nmcli con add con-name "static-ip" ifname enp0s3 type ethernet ip4 192.168.86.128/24 gw4 192.168.86.1

Creating a new connection with the nmcli command

Taken in small chunks, it's not as bad as it looks. We're using sudo . The nmcli arguments are:

  • con : Short for "connection."
  • add : We're going to add a connection.
  • con-name "static-ip" : The name of our new connection will be "static-ip."
  • ifname enp0s3 : The connection will use network interface "enp0s3."
  • type ethernet : We're creating an ethernet connection.
  • ip4 192.168.86.128/24 : The IP address and subnet mask in classless inter-domain routing notation . This is where you need to use the number you took note of earlier.
  • gw4 192.168.86.1 : The IP address of the gateway we want this connection to use.

To make our connection a functioning connection, we need to provide a few more details. Our connection exists now, so we're not adding anything, we're modifying settings, so we use the mod argument. The setting we're changing is the IPv4 DNS settings. 8.8.8.8 is the IP address of Google's primary public DNS server , and 8.8.4.4 is Google's fallback DNS server.

Note that there is a "v" in "ipv4." In the previous command the syntax was "ip4" without a "v." The "v" needs to be used when you're modifying settings, but not when adding connections.

nmcli con mod "static-ip" ipv4.dns "8.8.8.8,8.8.4.4"

Using the nmcli command to set the DNS servers for a connection

To make our IP address static, we need to change the method which the IP address obtains its value. The default is "auto" which is the setting for DHCP. We need to set it to "manual."

nmcli con mod "static-ip" ipv4.method manual

Using the nmcli command to set an IP address to static

And now we can start or "bring up" our new connection.

nmcli con up "static-ip" ifname enp0s3

Using the nmcli command to start a network connection

We didn't get any error messages which is great. Lets use nmcli to look at our connections once more.

nmcli con show

The details of two network connections displayed by nmcli

Here's the output:

Our static-ip connection is active and using device "enp0s3." The existing connection "netplan-enp0s3" is no longer associated with a physical network interface because we've pinched "enp0s3" from it.

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. A dot indicates which is in use. Click the "Wired Settings" or "Wi-Fi Settings" menu option. The details of the active connection are displayed.

If you followed our previous instructions the new connection will be the active connection. We can see our new "static-ip" connection has the IP address, default gateway, and DNS servers that we set for it.

The system menu with the

To create a new connection using the "Settings" application, click the " + " icon on the "Networks" page, above the list of wired connections.

The wired connection section in the Network tab of the Settings app

A dialog appears. We need to provide a name for our new static IP connection.

Giving a name to a new connection profile in the

We're calling our new connection "static-2." Click the "IPv4" tab.

Supplying the IPv4 connection details to a new connection profile in the

Select the "Manual" radio button, and complete the "Address", "Netmask", and "Gateway" fields. Also complete the DNS field, and then click the green "Apply" button. Note the comma between the DNS entries.

Our new connection is listed in the "Wired" connections pane.

A newly-added connection in the wired connection section of the Network tab of the Settings app

You can swap between the available connections by clicking directly on their names.

If you want to modify a connection after you create it, click the cog icon. In this case, we'll enter the settings for the "static-ip" connection.

The wired connection section in the Network tab of the Settings app

A dialog box opens. Click on the "IPv4" tab.

The IPv4 tab of the connection settings dialog

Because we set our new IP address to be static, the "Manual" radio button is selected. You could change this back to DHCP by selecting the "Automatic (DHCP)" radio button, and clicking the green "Apply" button.

Using the nmcli command or the GNOME desktop and apps, you can hop between network connections very easily and very quickly.

It's more convenient to have a selection of connection profiles and move between them as you need to, rather than to have one that you keep editing. If something goes horribly wrong with the connection you're editing or adding, you can always fall back on one of the existing connections.

GeniusGeeks logo

How to Change IP Address in Debian 11

Sagar Sharma

  • July 26, 2023
  • November 24, 2023
  • How To , Linux

If you have been using computers for a while, you must have heard of the term IP Address which stands for Internet Protocol Address. An IP Address is a numeric value assigned to a network device by which we can identify a specific device from the network.

We are going to discuss multiple ways by which you can change your IP Address in Debian which will also apply to other Debian-based Linux distributions such as Ubuntu , Linux Mint , Peppermint OS, and many others before that let’s see how to find your IP.

Table of Contents

How to Find IP Address on Debian 11

We can find the IP Address of our system in two ways. One is by using Terminal and another is by using GUI. As we are going to discuss both, you can choose what seems most appropriate to your workflow.

Method 1: Finding IP Address Using Terminal

This is the most efficient way as we are just going to use a few commands and it will bring an IP Address of our system. If you are familiar with Terminal, you will be able to perform these steps easily.

Step 1: Open Terminal

Click on Activities and type Terminal. Hit Enter on the first result and it will open Terminal for us.

1.0 Finding Terminal

Step 2: Executing Command to Get IP Address

Use the following command to get your IP Address:

 ip addr 

1. ip addr

The above command will get the address from available network interfaces and you will be shown more if you have connected more than one. Similarly, you can also use another command to display the IP Address and that command is as follows:

 ip a 

1.1 ip a

Method 2: Finding IP Address Using GUI

This is the easiest way to know your IP Address especially if you don’t have much experience using Terminal as this method does not involve any commands and you will get your IP Address displayed in a few clicks by following the given simple steps.

Step 1: Open Settings

Click on Activities situated on the top left corner and type Settings. Hit Enter on the first result and it will open settings for you.

2. Finding Settings from Activites

Step 2: Locate Network

Click on Network and it will show you available interfaces that have an IP Address. To see its IP Address, click on that little gear icon.

2.1 Locating Network for IP

It will bring you IPv4 and IPv6 addresses, including DNS.

2.2 IPv4 and IPv6 Addresses

After finding an IP Address of our system, we can proceed with how we can change it. But before discussing how you can change it, let’s discuss why you should change it and how it can be helpful in different scenarios.

Why you should change your IP Address?

Changing an IP Address of your system can be helpful in many scenarios such as if you want to solve some IP Address related issues, If you have some privacy issues online you can overcome them by changing your IP Address if you want to secure your system from online attacks and many more.

Before changing your IP Address make sure your new IP is active as having a faulty address can disconnect you from the internet and will leave you helpless. Let’s start the process of changing the IP Address in Debian 11 .

Changing IP Address in Debian 11

We are going to show you two different ways by which you can easily change your IP with your preferred method. So let’s start with the easiest method of changing IP Addresses using GUI.

Method 1: Changing IP Address Using GUI

This is the easiest way to change the IP Address on Debian and any other Debian-based Linux distribution as it does not involve any usage of complex steps such as commands and Terminal. This method enables you to change IP with a few clicks. Follow the given steps to change your IP Address.

Click on Activities and search for settings. Hit Enter on the first result and it will open Settings for us.

3. Finding Settings from Activites

Step 2: Locate Network Interface

From settings, click on the first option labeled “Network” and it will open network interfaces for our system. From there, click on the small gear icon to open the configuration for IP Address.

3.1 Locating Network for changing IP

Step 3: Enable Manual Setting for IP

You will be given multiple options when you will click on that little gear icon. From those given icons, click on IPv4 and choose manual as we are going to configure IP Address manually.

3.2 enable manual settings from IPv4

Step 4: Configuring IP Address

Once you will select manual from the given options, it will enable you to enter Address, Netmask, and Gateway manually. You have to enter your desired data on the given blanks. We have used the given data for this guide:

Address: 192.168. 62.185

Netmask: 255.255.255.255

Gateway: 192.168.62.2

Once you are done entering details, click on Apply button.

3.3 Entering data fo Address, Gateway and Netmask

Step 5: Applying Changes

Reconnect your network as it is required to apply changes. Click on that gear icon and you will see the default IP Address has been changed to our desired one.

3.4 output with changed IP

Method 2: Changing IP Address Using Terminal

This method will utilize Terminal and will get the job done efficiently. Open your Terminal and follow the given steps to change your IP using Terminal.

Step 1: Utilizing Nmtui for Changing IP

We are going to use nmtui which is a command-line utility for network configuration in GNU/Linux. It provides a graphical user interface to its user for simplifying the network configuration process. Use the following command to open the nmtui utility:

 sudo nmtui 

4. sudo nmtui

Step 2: Configuring Nmtui

The above command will open nmtui from which hit Enter on the first option named “Edit a connection”.

4.1 choose edit connection

Use Tab keys to select the Edit option and hit Enter to open configuration.

4.2 use tab to select edit option

Use navigation keys and select the option for IPv4 configuration. By default, it will be on Automatic mode.

4.3 go to IPv4 configuration

Hit Enter on Automatic and it will open options to choose from. Select the Manual option.

4.4 choose manual option

Use navigation keys to select “show” and hit Enter.

4.5 choose show option

From here, you are required to enter your desired IP Address.

4.6 changing address

Use navigation keys and hit Enter on OK.

4.7 click on OK

Step 3: Restarting Network

To activate the changes we have made, we will have to restart our network. It does not require any extra utility as you can easily restart your network in nmtui.

Use your navigation keys to select the Back option and hit Enter.

4.8 going back to main menu

Select “Activate a connection” option

4.9 choose activate connection

Use navigation keys to select Deactivate option and hit Enter.

4.10 deactivating connection

Hit Enter on Activate and it will start your network service with a new IP Address.

4.11 activating connection

Frequently asked questions related to IP Address

How do i find my ip address on debian.

Open your Terminal and use this single command and it will show your IP Address: ip a

This was our take on how to change IP Addresses in Debian 11 and other Debian-based distros. We have included all the possible methods so you can follow the 2nd if 1st does not work. We hope from now, you can use the desired IP on your Debian system.

Sagar Sharma

Sagar Sharma

Sagar always uses Linux to its core and loves to write the technical side of system administration! While he's not writing for GeniusGeeks, you can find him writing for core linux blogs like IT'SFOSS.com and LinuxHandBook.com

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 can you display host IP address in bash prompt?

Like above, I'd like to display IPv4 address of eth0 (or part of it) in PS1 or bash. Is there a way to do this?

lang2's user avatar

  • 1 define: ip address -- of which interface ? ipv4 / ipv6 ? localhost too ? –  Sirex Nov 1, 2013 at 3:55
  • Is that supposed to say "in PS1 on (or in) bash"? Just checking. –  beroe Sep 5, 2014 at 4:40

11 Answers 11

I use the following in my .bashrc

This will show you a prompt of:

Remove the \w to get rid of the present working directory or make it \W to make it only the a partial working directory

You can also use the following, assuming that there is only one IP address in your /etc/hosts file:

SomeGuyOnAComputer's user avatar

  • Interesting solutions. Not sure what OS the OP is using, but in OSX, hostname doesn't have the -i option. You could do something silly like host $(hostname) | cut -f 4 -d " " if there is a DNS available. –  beroe Sep 5, 2014 at 4:44
  • 2 The ifconfig output format has changed slightly (I'm using bash in ubuntu 18.04), and the 'cut' command does not seem necessary if the awk command is adjusted slightly, so I am using: THEIP=$(ifconfig | grep 'inet '| grep -v '127.0.0.1' | tail -1 | awk '{ print $2}') –  geekbrit Jun 23, 2018 at 13:58

Disclaimer: literally no attempt made to make this less-rubbish.

Below is the way to do that...

Sirex's user avatar

As stated by Sirex you can do a lot of tricky things with command substitution, I would prefer the following declaration using the ip utility:

export PS1="IP: $(ip addr show dev eth0 | grep "inet " | cut -d" " -f6) #" or something like that.

Another option is to use the tool facter which provides a lot of information about your system so a simple facter ipaddress_eth0 gives you the IP-Adress. So the new example would be

export PS1="IP: $(facter ipaddress_eth0) #

facter allows you to use much more system informations for scripting if you want. Just execute facter to see what it got in it's whole configuration. If you want you can also declare your own facts in /etc/facts.d .

noggerl's user avatar

In my case: I have some VMs run Ubuntu server, each of them have private it's IPv4 address, and it should be nice if I can see the IP address each time I login (like EC2 Instances), and here is what I did:

  • Add the following lines in the bottom of ~/.bashrc file:
  • Then type the command: source ~/.bashrc , and the IP is displayed
  • I also use rsync to sync the .bashrc between multiple machines (examples: rsync -avzhe ssh /path/to/file user@server:/path/to/destination ), hope it helps

Chau Giang's user avatar

This is the minimalist way. Feel free to add whatever other characters you need in PS1.

Jonathan's user avatar

I've taken @SomeGuyOnAComputer's answer and improved it slightly:

IP=$( ifconfig | grep ^eth -A2 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1 }' ) PS1='\n\[\033[00;32m\]\u@$IP \[\033[00;33m\]\w\n\\$\[\033[00m\] '

I had a docker container running on my machine so it was picking up the docker's ip address when I ran @SomeGuyOnAComputer's command. The new version looks for the line that starts with 'eth' and prints the 2 lines after the matching line (-A2) information. The rest is just like @SomeGuyOnAComputer's version.

Craig's user avatar

I am using this config in .bashrc and is pretty cool (similar to suggested above)

Mohammad Shahid Siddiqui's user avatar

  • 00:02:03 @10.112.202.108~/shahid/ansible/ $ –  Mohammad Shahid Siddiqui Aug 13, 2017 at 10:44

You may also like this-

IP Address in Prompt With Automatic Updating

My solution was as follows (works on Fedora). Adapted from the the other answers here and info from this post http://sysadminsjourney.com/content/2008/12/18/use-networkmanager-launch-scripts-based-network-location/ .

Create the following script as root: /etc/NetworkManager/dispatcher.d/99smartsynergy.sh

Then in your .bashrc :

SilverlightFox's user avatar

this works for me:

nir's user avatar

  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center . –  Community Bot Dec 16, 2022 at 20:35
  • not sure what is unclear, Mr. bot. please be more specific –  nir Dec 18, 2022 at 21:26

Export your IP variable: export MYIP=$(ifconfig | grep inet | egrep -v "127|inet6" | awk '{print $2}') Export your bash variable: export PS1='[\u@"$MYIP" \W]\$ '

Burebista1404's user avatar

  • 1 (1) Why would exporting help?  (2) You know that 192.168.1.127 is a valid IP address, right? –  G-Man Says 'Reinstate Monica' Oct 24, 2017 at 19:48

You must log in to answer this question.

Not the answer you're looking for browse other questions tagged bash ..

  • The Overflow Blog
  • Exploring the inclusive tech revolution sponsored post
  • Would you trust an AI bot to find the fix for vulnerabilities in your code?
  • Featured on Meta
  • Site maintenance - Saturday, February 24th, 2024, 14:00 - 22:00 UTC (9 AM - 5...
  • Upcoming privacy updates: removal of the Activity data section and Google...

Hot Network Questions

  • Advisor's Move to Another University: Should I Identify as a Visiting Student or Visiting Researcher?
  • how to keep the original material after using simulation zone in GN?
  • Motivation and physical interpretation of the Laplace transform
  • What is causing this impossibly long return time in AC Brotherhood on the PS3?
  • How can the Klein-Gordon equation have negative-energy solution if its Hamiltonian is positive-definite?
  • How can the ECtHR judgement on encryption be reconciled with the UK's Online Safety act?
  • What's the word similar to jittery in spelling or pronunciation, but means some privately-run transportation by small vehicles?
  • How do I know it is safe to remove eclipse glasses when viewing a total solar eclipse?
  • Accidental colonists on Mars survive being stranded because Mars plants grow and provide the necessities of life
  • YA novel where a thief meets a disguised princess
  • How could we have defined time, had matter in our universe not been atomic?
  • Odd use(s) of "bauen"
  • Spot The Difference
  • What is the better rendering of colossians 2: 14?
  • Why does GCC generate code that conditionally executes a SIMD implementation?
  • How to tell if tension is a problem while writing?
  • In the U.S. academia, why do many institutes never send rejection letters for postdoc positions (to save the hassling of inquiries from applicants)?
  • DIY system for charging battery packs from hub dynamo
  • QGIS functions: aggregate and array_foreach not working for vertices
  • Trie implementation using std::shared_ptr
  • Why does the exported video still have control buttons, causing the screen to be too large?
  • If the tidal bulge on the earth speeds the moon up, how does the moon move to a higher orbit?
  • What is this equivalence relation on topological spaces: there are bijective continuous maps in both directions
  • How to combine two different datasets to create a unified dataset

how to change ip address in linux using command line

How to Check if Virtualization is Enabled via Command Prompt (CMD)

command to check virtualization is enabled in Windows 11 or 10

Want to confirm the virtualization is enabled on your Windows 11 or 10 PC & Laptop using the command prompt or Powershell, then just use the command “systeminfo”.

On most modern systems, Virtualization is enabled by default on the BIOS, however, we can confirm that without actually opening the BIOS/UEFI firmware menu. We learn later how to do that but before that let’s quickly know what is virtualization.

It is a technology that allows users to run multiple operating systems on a single physical hardware but virtually. This means, on the physical machine there will be an OS that in computer language known as the host. Whereas the operating systems run on it using virtualization tech and with the help of software like Hyper-V, VirtualBox, VMware, etc known as Guests.

How to ensure Virtualization is enabled on Windows using Command

CMD and PowerShell can be used to check Virtualization on Windows 11 or 10.

Step 1: Open Command Prompt or PowerShell as Admin

As we are about to use the command line to determine whether the virtualization is enabled or not, so go to the Windows Start menu and search for either the CMD or PowerShell, then click on “ Run as Administrator ” to open it with administrative privileges.

Rus as administrator command prompt

Step 2: Run System Information Command

The easiest way to get all the key information about Windows PC or laptop using the command line is with the help of “ systeminfo “. It is a tool that is available to display information about the system including hardware and software configurations using both GUI and CLI. Hence, execute it as shown below:

Step 3: Check Virtualization Status

The output of the command we ran in the previous step will be long because it provides all the important details of Windows hardware and software, however as we are looking specifically for Virtualization, hence scroll down and at the end of the output you will find a line saying “Hyper-V Requirements.” If virtualization is enabled, you should see the following information:

command to check virtualization is enabled in Windows 11 or 10

If the “ Virtualization Enabled In Firmware ” is marked as “ Yes “, this means the Virtualization on your Windows 10 or 11 is enabled in the system’s BIOS and can be used to run virtual machines or applications. Not only regular VMs but we can even run Windows Sandox for testing apps, learn how.. .

However, if instead of “Yes” it is marked as “No” or not available then you need to enable the virtualization in the BIOS of the system.

Conclusion:

It is not very difficult to find out the virtualization status on Windows, single command can do that for us. Also, it is necessary to know about it before installing any application that requires virtualization such as Oracle VirtualBox. By the way, if you are using VirtualBox already then you might would like to learn how to enable Virtualbox nested VTX/Amd-V on Windows or Linux .

Other Articles:

  • Windows XP ISO installation on Windows 11 using VirtualBox
  • How to install MX Linux on VirtualBox VM
  • Convert VMware Workstation Pro Virtual machine to use in VirtualBox

Single Command to Install Virt-viewer on Windows 11 or 10

Inside kodak tv factory: a glimpse into the manufacturing process, related posts.

What is the DPC watchdog violation on Windows 11

What is the DPC watchdog violation on Windows 11? Why this is caused and the possible fixes

Reinstall Windows step by step to Factory settings

How to Reset Windows 11: A Step-by-Step Guide to Restore Your PC to Factory Setting

command prompt to find hostname ip address

How to find the IP address in CMD using hostname?

Mr. Avneet, Director and CEO of Super Plastronics Pvt. Ltd. min

Leave a Comment Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed .

Reach out to us for sponsorship opportunities or suggestions

Problems are meant to be solved.

© 2024 H2S Media

XDA Developers

How to see your IP address in Ubuntu

Quick links, check for a private ip address using the gui, check for a private ip address using the terminal, check for a public ip address using the terminal, check for a public ip address using the gui, next steps and more.

An IP address is like your physical mailing address. Once you connect a Linux distribution like Ubuntu to the internet or a router, your system gets assigned two IP addresses. There's the private one, which is used to identify your device on an internal network, and the public IP address, which is what websites see when you connect.

It's important to know your IP address on Linux should you be having network issues or if you're on a call with an IT administrator and they need to connect remotely. The good news is that Ubuntu makes it easy to see your IP address. You can use the terminal or the graphical user interface (GUI) settings app.

Checking for a private IP address through the GUI on Ubuntu is easy. Just open the settings app and follow the steps below:

  • Click Network in the sidebar. If you're connected to Wi-Fi, choose Wi-Fi.
  • Click on the settings gear next to the network that you're connected to.
  • You'll see your IP address listed under IPv4 address.

If you want to find a private IP address on Ubuntu, fire up a terminal with Ctrl + Alt + T . Once open, you can use the following commands.

  • Type the command: ip a
  • You'll see a list. Look for the network interface that you're connected to.
  • In our case, we're connected to the Ethernet interface. It is listed as ether .
  • The IP address will be listed under inet . In our case, it's 10.02.15

To check for a public IP address using the terminal, you need to install and use the curl command. Fire up a terminal with Ctrl + Alt + T, and then follow the steps below:

  • Install Curl with the command sudo apt install curl
  • Once installed, type the command curl ifconfig.me
  • Confirm with Enter on the keyboard.

You should get a readout like the one above.

You can check a public IP address on Ubuntu by using your web browser of choice.

  • Open your web browser. Firefox should be pre-installed.
  • Visit whatsmyip.org .

You should see your IP address listed at the top of the website.

Knowing your IP address means you can dive into more advanced settings. For example, you might want to use a static internal IP address . This is just one setting that can be changed, though. Ubuntu is an open-source and highly customizable operating system, giving you plenty of room for additional changes.

How to see your IP address in Ubuntu

How to find the IP address of a Guest in VirtualBox?

VirtualBox is one of the popular ways to run multiple virtual machines on a single hardware system running with either Windows, Linux, or MacOS. There are no limitations on how many guest operating systems we can run using Virtualbox, as long as our physical machine allows, it can be one or 100. However, if you want to connect the Guest VMs to perform any network setup or troubleshoot connectivity issues, it becomes important to know the IP address of a guest machine. Here in this article, we learn the two ways to retrieve the IP address of a running guest virtual machine in VirtualBox .

Note : Before using any of the given methods, ensure the Guest OS is up and running in the VirtualBox.

#1st Method

By directly accessing the Guest OS UI

The simplest way to know the IP address of your running Guest OS in VirtualBox is by manually opening and running the appropriate command or checking its network settings. This method works the same way as we check the IP address in an OS running on any physical machine.

So, go to VirtualBox, select Guest OS, and open it to get the GUI or command line interface.

On Windows Guest OS:

Those who are running a Windows virtual machine on VirtualBox , need to follow these steps to directly find the IP address.

  • If you want to use the graphical user interface to find the IP address then go to the Windows Start menu search for – Control Panel and open it.
  • In the Control panel, select “ Network and Internet “.
  • Under View your Active Networks, click the Connection name and then Details . Here, you’ll find the IPv4 address.

check Windows guest IP address

Alternatively , Windows 10 or 11 users can press the “ Win key + I” keys to open Settings and there select the “ Network and Internet ” Tab given on the left side of the window.

Open Wi-Fi settings or Ethernet Settings to reveal the IP address and other network details…

Ethernet revealing address Windows 11

On Linux Distros

If your VirtualBox Guest OS is Linux then just like Windows, go to the VirtualBox interface and open the running Linux OS such as Ubuntu or any other to access its User interface.

However, the Linux GUI users need to open the Terminal app from the Application area whereas the CLI Linux users can directly move to the next step.

After having the Terminal access execute the given command and it will give you the IP address of the running Linux Guest virtual machine.

#2nd Method

Find IP-address using VBoxManage Command without opening the Guest OS

VBoxManage is the command line tool that is available on all host operating systems where the VirtualBox has been installed. So, using it we can run the command directly from the host command terminal inside the VirtualBox running Guests, including a command to find the IP address.

Note : Make sure, the IP address of the guest OS you want to find without opening VirtualBox Interface must be active and running.

# 1st way: The common command to check the Ip-address of existing VirtualBox:

The given command syntax can be used for any existing Windows or Linux Guest OS:

Just Change the “Guest VM” with actual Virtual Machine name that

command to check the Ip address of existing VirtualBox

# 2nd command: That can be use to get the Ipaddress:

The second command given below with VBoxManage can be used to execute any command inside the Guest virtual machine by using its logging details. Hence, not only the IPaddress but even can be used to execute scripts…

For Windows running guest

If your guest in VirtualBox is running with any Windows OS version then go to your host operating system and open the command prompt or terminal.

Once you have the command line, we need to follow the given command syntax:

Replace “ VM_NAME ” with the name of your virtual machine along with the username and password of that to log in using the command line and run the command to find the IP address.

For Windows hosts, the above command will be like this:

First switch to the VirtualBox installation directory:

Example: Let’s say we have a Linux Guest VM on VirtualBox named “ Debian 12 ” with username – “ vboxuser and password ‘ d ‘. Inside the Guest VM we want to run a command “ /bin/ip a ” to find the IP address:

find virtualBox VM ipaddress using command

Similarly for Windows running Guest VMs:

Note: Don’t forget to change the VM name, Username , and password.

VBOXManage command to find Windows IP address

For macOS or Linux host:

The commands we discussed above will be the same for Linux and even macOS . However, you don’t need to switch to the VirtualBox installation directory as we did in the Windows host case.

  • VM_Name- Repalce with the Guest VM name that IP address you want
  • Command – Replace with the command you want to execute in the Guest VM
  • Username – Use the exact username of the Guest OS
  • Password – Enter the password to log in using the username.

How to list all the VirtualBox Guest VMs using the VBoxManage command

If you don’t want to open the VirtualBox manually to learn how many virtual machines have been created, then we can use the VBoxManager command tool to list them all along with their UUID right in our Terminal or Command prompt. Here is the syntax to use:

command to list VirtualBox aa guest virtual machines

Other Articles:

  • Installing VirtualBox on Debian 12 Bookworm
  • How-to: Unattended Ubuntu server or desktop installation in Virtualbox
  • How to install Ubuntu 22.04 Server on VirtualBox
  • 6 Best Linux Distros to Try on VirtualBox Virtual machine

Use Cockpit as Virt-Manager alternative to manage KVM VMs

Use Cockpit as Virt-Manager alternative to manage KVM VMs

How to install KVM on Oracle Linux 9?

How to install KVM on Oracle Linux 9?

How to Install Cockpit-Podman for Container Management on Linux

How to Install Cockpit-Podman for Container Management on Linux

What is the difference between OpenVZ and Docker?

What is the difference between OpenVZ and Docker?

6 Top Free Tier Ubuntu Cloud Server Options & Limitations

6 Top Free Tier Ubuntu Cloud Server Options & Limitations

What to Look for in an Affordable Ubuntu VPS Provider

What to Look for in an Affordable Ubuntu VPS Provider

Leave a Comment Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed .

  • Business Routers
  • IP Surveillance
  • Accessories

how to change ip address in linux using command line

How do I change the IP address of my D-Link Managed Switch through the CLI?

Follow the directions below to change the IP address of your D-LinkManaged Switch using CLI. Step 1. Connect to the switch using Telnet(Standard Port 23) or HyperTerminal (Port speed is listed beneaththe console port on the front panel of the switch). Enter yourusername and password (default is blank for both). Press Enter toaccess the Command Line Interface (CLI). Step 2. Enter the following command for changingthe default IP address (10.90.90.90). Syntax: config ipif System ipaddress x.x.x.x/x.x.x.x or x.x.x.x/x Note: All commands are case-sensitive. Pleaseverify the syntax of the interface name before changing the IPaddress. You can view the interface settings by typing showswitch .

  • x.x.x.x = ip address
  • /x = Subnet Mask

Example: config ipif System ipaddress 192.168.10.115/24 Step 3. Press Enter to initialize IP addresschange.

Step 4. After performing the IP address change,connect back into the switch via Telnet using the new IP address.If you are using HyperTerminal, run show switch toverify the IP address on your switch.

Note: All changes take effect immediately, butwill NOT be saved to N/V RAM until you type the SAVE command.

75 people found this useful.

Thank you for your feedback.

Sorry we couldn't help! Click here for more  FAQs or go to Support .

IMAGES

  1. How to get IP Address in Linux using Command terminal

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

    how to change ip address in linux using command line

  4. Set IP Address in Linux

    how to change ip address in linux using command line

  5. How to Change IP Address in Linux

    how to change ip address in linux using command line

  6. How to Change IP Address in Linux

    how to change ip address in linux using command line

VIDEO

  1. Easy! How to change your IP Address on Windows PC

  2. How To Change IP Address On Windows 11

  3. How To Configure Static IP in Ubuntu 18.04 Desktop

  4. How to Fix change ip address windows 10

  5. How to a Setup Static IP Address on Linux PART-30 Step-by-Step Demonstration

  6. HOW TO CHANGE IP ADDRESS ON WINDOWS 10

COMMENTS

  1. How to Change IP Address in Linux

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

  2. 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. The new ip address will be assigned to this interface. For example, ifconfig eth0 192.168..100 netmask 255.255.255. will change the ip address on eth0 to 192.168..100.

  3. How To Change IP Address on Linux

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

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

    sudo route add default gw 192.168..253 eth0 To see your new setting, you will need to display the routing table. Type the following command at the prompt, and then hit Enter: route -n Related: That's all there is to changing your IP address from the terminal.

  5. How to Use the ip Command on Linux

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

  6. How to change IP address on RHEL 8 / CentOS 8 Linux

    The CLI way You can manually change your IP address by modifying the corresponding configuration file for each network card. First see how your network cards are named by invoking ifconfig in a Terminal window: $ ifconfig or $ ip a The output for a wired connection should name your network card something like ens33.

  7. How do I change the IP address/netmask and hostname on the command line

    How do I change the IP address/netmask and hostname on the command line WITHOUT rebooting the machine? Updated September 16 2012 at 2:04 AM - English Here are some example configuration files: /etc/hosts Raw 127.0.0.1 localhost.localdomain localhost 192.168..254 server1.example.com server1 /etc/sysconfig/network Raw

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

  9. How To Change IP Address Linux

    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.

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

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

  12. Change IP address on Ubuntu Server

    Locate and edit with administrative privileges the /etc/netplan/50-cloud-init.yaml file (it may be called /etc/netplan/01-netcfg.yaml instead) with the following configuration. Update your desired static IP address, DNS server and gateway where appropriate. Save and exit the file after you have applied your changes.

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

  14. Linux IP Command Ultimate Tutorial with 31 Examples

    How to Use the ip Command. 1. link ( l) - used to display and modify network interfaces. 2. address ( addr/a) - used to display and modify protocol addresses (IP, IPv6). 3. route ( r) - used to display and alter the routing table. 4. neigh ( n) - used to display and manipulate neighbor objects (ARP table).

  15. How to Change IP Address on Linux?

    Step 1: Display Network Details Execute the " ifconfig " command to display the current interface details, including its IP address: # ifconfig Here, the " ens33 " is the network interface having an IP address "192.168.253.130". Step 2: Network Interface Down The "ens33" interface is in running status.

  16. How to configure a static IP address on CentOS 7 / RHEL 7

    Verify new IP settings using the ip command for the NIC named eth0: # ip a s eth0 Verify new routing settings: # ip r Next, verify DNS servers settings using the cat command or grep command to query the /etc/resolv.conf file as follows: # cat /etc/resolv.conf Finally verify the internet connectivity using the ping command: # ping -c 3 cyberciti ...

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

  18. How to Configure Static IP Address on Ubuntu 20.04

    To do so, use the ip link command, as shown below: ip link The command prints a list of all the available network interfaces. In this example, the name of the interface is ens3:

  19. how can I change the interface ip address in linux without ifconfig

    You can also use ip route add or ip r a. First add your IP to the route table ip route add 192.168.10.100 dev ens160 proto static metric 100 Then add the route via the gateway ip route add default via 192.168.10.1 dev ens160 proto static metric 100 These changes will be temporary until a reboot. To make them persist, you will need to add the changes to your NIC.

  20. Setup DHCP or static IP address from command line in Linux

    With DHCP, you get IP address, subnet mask, broadcast address, Gateway IP and DNS ip addresses. Go to step xxx to test your internet connection. Step 4.2 - Setup static IP, subnet mask, broadcast address in Linux. Use the following command to setup IP, subnet mask, broadcast address in Linux. Note that I've highlighted the IP addresses in ...

  21. How to Set a Static IP Address in Ubuntu

    Nmcli is the command-line network manager tool, and can be used to change your IP address, configure network devices, and --- relevant to our purposes --- set up a static IP in Ubuntu. We're demonstrating this technique on Ubuntu 22.04 LTS, but it ought to work on any Linux distribution, including Ubuntu 23.04.

  22. Setting a Static IP Address in Ubuntu 24.04 via the Command Line

    Use the command ip link to find out the names of your interfaces. dhcp4: no This setting disables DHCP for IPv4 on the interface, indicating that a static IP address will be used instead. If set to "yes," the interface would obtain an IP address automatically from a DHCP server.

  23. How to Change IP Address in Debian 11

    Step 2: Locate Network. Click on Network and it will show you available interfaces that have an IP Address. To see its IP Address, click on that little gear icon. It will bring you IPv4 and IPv6 addresses, including DNS. After finding an IP Address of our system, we can proceed with how we can change it. But before discussing how you can change ...

  24. How can you display host IP address in bash prompt?

    As stated by Sirex you can do a lot of tricky things with command substitution, I would prefer the following declaration using the ip utility: . export PS1="IP: $(ip addr show dev eth0 | grep "inet " | cut -d" " -f6) #" or something like that. Another option is to use the tool facter which provides a lot of information about your system so a simple facter ipaddress_eth0 gives you the IP-Adress.

  25. How to Check if Virtualization is Enabled via Command Prompt (CMD)

    Step 1: Open Command Prompt or PowerShell as Admin . As we are about to use the command line to determine whether the virtualization is enabled or not, so go to the Windows Start menu and search for either the CMD or PowerShell, then click on "Run as Administrator" to open it with administrative privileges. Step 2: Run System Information ...

  26. How to see your IP address in Ubuntu

    You'll see your IP address listed under IPv4 address. Check for a private IP address using the terminal . If you want to find a private IP address on Ubuntu, fire up a terminal with Ctrl + Alt + T.

  27. How to find the IP address of a Guest in VirtualBox?

    #2nd Method . Find IP-address using VBoxManage Command without opening the Guest OS. VBoxManage is the command line tool that is available on all host operating systems where the VirtualBox has been installed.So, using it we can run the command directly from the host command terminal inside the VirtualBox running Guests, including a command to find the IP address.

  28. How do I change the IP address of my D-Link Managed Switch through the

    Press Enter to initialize IP addresschange. Step 4. After performing the IP address change,connect back into the switch via Telnet using the new IP address.If you are using HyperTerminal, run show switch toverify the IP address on your switch. Note: All changes take effect immediately, butwill NOT be saved to N/V RAM until you type theSAVE command.