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
  • Single-page

Language and Page Formatting Options

Red hat training.

A Red Hat training course is available for Red Hat Enterprise Linux

3.6. Configuring IP Networking with ip Commands

Assigning a static address using ip commands, configuring multiple addresses using ip commands.

how to configure ip address in linux rhel 6

Configure CentOS 6 Network Settings

This tutorial will walk you through configuring your network configurations on CentOS 6.X. There are three different methods to choose from, depending on what installation type and packages you have installed.

Manual configuration is done by directly modifying the configuration files. You will need to be comfortable with the command-line for this one. However, this will give you the most flexibility and is worth learning.

System Config Network is a command-line tool that presents a very basic graphical interface. This a great tool for those who just want to quickly configure the network and do not require advanced features, like interface bonding (teaming).

And lastly, from a Gnome desktop. This is for those trying Linux out, who have yet to venture into command-line territory, or have no interest in it at all.

Manual Configuration

This configuration is done by modifying the network configuration directly, using a text editor. This method is typical for servers and is a more advanced way of doing it.

Set the Hostname

  • Open the following file into a text editor, like VI or Nano. vi /etc/sysconfig/network
  • Change the  hostname  value to the fully qualified name of your computer. HOSTNAME= slcentos6-01.serverlab.intra
  • Save your changes and exit the text editor. The new name will be applied after your next reboot.

Set a DHCP Address

  • Open the configuration file for the first network interface,  eth0 , into a text editor. vi /etc/sysconfig/network-scripts/ifcfg-eth0
  • Modify the file to look similar to the example below. DEVICE=eth0 TYPE=Ethernet ONBOOT=yes BOOTPROTO= dhcp IPV4_FAILURE_FATAL=yes NAME="System eth0"
  • Save your changes and exit the text editor.
  • Restart the network service. service network restart

Set a Static IP Address

  • Modify the configuration file to look similar to the one below. Remember to change the highlighted values to match your environment’s. DEVICE=eth0 TYPE=Ethernet ONBOOT=yes BOOTPROTO=none IPADDR= 172.30.0.53 PREFIX= 24 GATEWAY= 172.30.0.1 IPV4_FAILURE_FATAL=yes NAME="System eth0"

Setting DNS Name Servers

DNS configurations are set in /etc/resolv.conf. Within this file, we can specify the search domains and the name servers. The search domains are used as default suffixes when no domain is added to a hostname.

  • Open the resolvr configuration file into a text editor. sudo vi /etc/resolv.conf
  • Add the following lines, modifying it them to match your environment. domain example.com search example2.com lab.example2.com nameserver 8.8.8.8 nameserver 8.8.4.4
  • All changes to resolvr.conf are applied immediately.

Using the System Config Network Tool

The System Config Network tool is a terminal application that presents a very basic GUI. It can do basic network configurations, such as configuring static or DHCP addresses, setting the DNS server IP addresses, and setting the default gateway.

Install System Config Network

The base CentOS 6 installation includes the tool by default. To install it on a minimal installation, follow these instructions.

  • Install it from the yum repository. yum intall system-config-network
  • If you have no Internet access, install it from the CentOS DVD. Create a directory in /media called cdrom. mkdir -p /media/cdrom
  • Mount the CentOS DVD to the directory. mount /dev/cdrom /media/cdrom
  • Run yum and target the repository that uses the DVD. yum --disablerepo=/* --enablerepo=c6-media install system-config-network

Configure the Network Settings

  • Launch the System-Config-Network tool from the terminal. system-config-network-tui
  • Ensure  Device Configuration  is highlighted, and then press  Enter .

how to configure ip address in linux rhel 6

  • Tab to highlight  Ok , and then press  Enter .
  • Press tab until  Save  is highlighted, and then press  Enter  to save your changes.
  • Press tab until  Save&Exit  is highlighted, and then press Enter to save your changes.
  • To apply your changes, restart your network services. service network restart

From a Gnome Desktop

Gnome is the default environment for CentOS 6 Desktop installations. There are plenty of alternative environments that can be installed, but being the default, this one is more widely used.

CentOS 6 Gnome Desktop

  • From the list of connections in Network Connections application, select the interface you want to configure.

CentOS 6 Network Connections

  • Click the  IPv4 Settings  tab.

Editing System eth0

  • If required by your DHCP server, set a Client ID in the  DHCP Client ID  input box.
  • Click  Apply  to save your changes.
  • From the Method drop-down list, select Manual.
  • Click the Add button, located beside the Addresses table.
  • Enter an IP address into the  Address  field.
  • Enter a subnet mask in the  Netmask  field.
  • Enter the gateway address in the  Gateway  field.
  • Enter the IP addresses of your DNS servers in the  DNS servers  input box, separating each entry with a comma.

CentOS Static IP

Following one of the three examples above, you should now have a configured network connection. There are more advanced configurations that can be done, like bonding connections together to increase throughput or add fault tolerance, but those subjects are too advanced for this tutorial.

No related posts found

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.

ITzGeek

How To Configure IP Address in CentOS 7 / RHEL 7 & CentOS 6 / RHEL 6

how to configure ip address in linux rhel 6

Just after the installation of operating systems, you must configure the network to access your system from outside. This guide helps you to Configure IP Address in CentOS 7 / RHEL 7 & CentOS 6 / RHEL 6 .

Here I will show how to configure Static IP addresses for your machine and also configure the network interface to get an IP address from the DHCP server.

Prerequisites

Let’s check the available interfaces on our system. Use the ifconfig command to list interfaces.

From the above output, you can see my system has two interfaces namely lo and ifcfg-enp0s3 . Depends on hardware, the name of the interface will change.

To set an IP address to an interface, go to /etc/sysconfig/network-scripts/ directory, there you will find a file ifcfg-<interfacename> .

As per the above output, my system has a file ifcfg-enp0s3 since CentOS 7 / RHEL 7 uses consistent network interface naming.

Static IP Address

In this mode, we will manually assign an IP address to machines.

Edit the ifcfg-<interfacename> file.

Restart the network service using the below command.

Now you can see the ip address 192.168.0.10 assigned to the interface enp0s3 .

DHCP IP Address

In this mode, the system will get an IP address from the DHCP server. This is the default mode set on CentOS to get an IP address from the DHCP server.

Just modify the lines like this.

Now you can see the ip address 192.168.0.23 assigned to the interface enp0s3 using DHCP.

That’s All. Please share your feedback in the comments section.

Top Important Docker Commands – Working with Docker Containers

Fedora Server 22 Installation – Step by Step with screen shot

How to Install Oracle Java JDK 18 on Linux

How to Install Oracle Java JDK 17 on Linux

How to Upgrade CentOS 7 to Rocky Linux 8

How To Install PHP 8.0 on CentOS 7 / RHEL 7

How To Install NTP (Chrony) On CentOS 8 / CentOS 7 & RHEL 8 / RHEL 7

How To Install Gradle on CentOS 8 / 7 & RHEL 8 / 7

  • CentOS 8 / RHEL 8
  • CentOS 7 / RHEL 7
  • CentOS 6 / RHEL 6
  • LinuxMint 20
  • Linux Mint 19
  • Linux Mint 18
  • Rocky Linux 8
  • Ubuntu 22.04
  • Ubuntu 20.04
  • Ubuntu 18.04
  • MySQL / MariaDB
  • Other Tools

Tecmint: Linux Howtos, Tutorials & Guides

A Beginner’s Guide to Configuring IPv4 and IPv6 Addresses in Linux

As a systems administrator, you will occasionally be tasked with configuring or setting up the IP addresses of your servers to keep up with changing network requirements. As such, having fundamental skills in assigning IP addresses and configuring hostname resolution is crucial in ensuring that servers conform with the network topology.

Table of Contents

What is an IP Address?

An IP address, which stands for Internet Protocol , is a unique numerical identifier or address that identifies a device in a TCP/IP network. This could be a local area network ( LAN ) or the internet.

The IP address allows communication between devices in a network such as servers, routers, switches, and any other network device connected to the network.

Difference Between IPv4 vs IPv6

An IP address can be broadly categorized into two: IPv4 and IPv6 .

IPv4 Address

An IPv4 (IP version 4) address is a 32-bit number that is split into four octets, with each octet separated by a period or a decimal point. This is usually referred to as dotted-decimal format.

Each octet is made up of 8 bits which collectively represent a byte. An IPv4 address can further be divided into two sections. The first part represents the network section, while the remaining part defines the host section.

Network Section

The network section of an IP address identifies the class the IP address belongs. There are 3 distinct classes of IP addresses used in computer networks: Class A , Class B , and Class C .

What is IPv4 Class A

In Class A type of network, the first 8 bits (octet) define the network, while the remaining 24 bits are reserved for the hosts in the network.

  • The Public IP addresses range from 1.0.0.0 to 127.0.0.0.
  • The Private IP addresses range from 10.0.0.0 to 10.255.255.255.

Addresses 127.0.0.0 to 127.255.255.255 are reserved for loopback and other diagnostic purposes, and hence are not allocated to hosts in a network.

The default subnet mask of class A is 255.0.0.0 with the first 8 bits used to identify the network. The remaining 24 bits are designated for hosts. This class is used in networks that command a large number of hosts. It yields a maximum of 16,777,214 hosts and 126 networks.

What is IPv4 Class B

In Class B , the first two octets, or 16 bits are used to define the network ID.

  • The Public IP addresses range from 128.0.0.0 to 191.255.0.0.
  • The private IP range is from 172.16.0.0 to 172.31.255.255.

The default subnet mask is 255.255.0.0 where the first 16 bits define the network ID. This class of IP is typically used for medium-large networks and yields 65,534 hosts per network with a total of 16,382 networks.

What is IPv4 Class C

This class of IP is mostly used for small networks such as a home network or a small office or business.

In a Class C network, the first two network bits are set to 1 while the third is set to 0, i.e. 1 1 0. The remaining 21 bits of the first three octets define the network ID, and the last octet defines the number of hosts.

As such, Class C IP address produces the highest number of networks amounting to 2,097,150 , and the least number of hosts per network which is 254 hosts.

  • The public IP addresses range from 192.0.0.0 to 223.255.255.0.
  • The private IP range is from 192.168.0.0 to 192.168.255.255.

The subnet mast is 255.255.255.0.

Host Portion

The remaining section of the IP address is the host portion, which is the section that determines the number of hosts in a network. This part uniquely identifies a host in a network. All hosts in the same network share the same network portion.

For example, the following host IP addresses belong to the same network.

IPv6 Address

An IPv6 address is an alphanumeric address that is 128 bits long, arranged in eight groups, each of which contains 16 bits.

Like an IPv4 address, it is split into two parts: the network and host component. The network part makes up the first 64 bits and is used for routing purposes. The remaining 64 bits identified the address on the nodes.

Below is an example of a full IPv6 address.

This can be further shortened as follows.

IPv6 was developed as a solution to the imminent exhaustion of addresses in IPv4. As you know by now, IPv6 contains 128 bits which is four times more than the number of bits in IPv4 (32 bits). These extra bits provide more addressing space which will supplement the address provided by IPV4.

Although IPv6 is set to take over from IPv4 addressing in the near future, many organizations and ISPs still use and largely rely on IPv4 addresses.

In fact, you’ll hardly ever need to configure an IPv6 on your device to provide connectivity. The fact is, it will take a while before IPv6 replaces or phases out IPv4.

Dynamic (DHCP) and Static IP Configuration

IP allocation on client machines or any end-point devices connected to a network is done either using the DHCP protocol or manual configuration where IP addresses are statically allocated.

DHCP IP Address

DHCP ( Dynamic Host Configuration Protocol ) is a client-server protocol that dynamically allocates IP addresses to client systems on a network. The DHCP server, which in most cases is a router, contains a pool of addresses that it leases out to client devices on a network for a certain period of time. Thus, it simplifies and makes the configuration of IP addresses more efficient. Once the lease time lapses, the client acquires a new IP address.

Most systems, by default, are configured to obtain an IP automatically using the DHCP protocol. This eliminates the possibility of IP conflicts in a network where two devices share the same IP address.

The drawback of DHCP is that the IP addresses change once the lease expires. If a server is set to acquire an IP via DHCP, this will lead to connectivity issues once the IP address changes. And this is where static IP configuration comes in.

Static IP Address

In static IP configuration, IP addresses are manually configured on a client system, especially servers. Unlike dynamically allocated addresses, statically configured IP addresses remain the same and do not change.

However, the static configuration requires a lot of work from network admins. They have to manually log in and configure the static IP along with other details such as subnet mask, DNS servers, and gateway IP. In addition, they need to keep track of all the client systems with static IP addresses.

In this tutorial, we will focus on how to statically configure IP addresses on various systems.

How to Configure IPv4 Networking in Linux

In this section, we will shift focus and see how to configure an IPv4 address on Linux. We will look at how you can do this on Debian , Ubuntu , and later on RHEL and Red Hat distributions .

Configure IPv4 Address on Debian

To get started, it’s always a good idea to check your current IP configuration of the Linux system.

This displays the IP addresses and status of your network interfaces. From the output, we have two interfaces.

Find IP Address in Linux

The first one is the lo interface which is a loopback address reserved for testing purposes only and is always designated the address 127.0.0.1 . The loopback address is not associated with any physical network interface.

The second interface is enp0s3 (this might be different in your case). This is the active network interface that maps to the physical network card on the server.

Its IPv4 address is denoted by the inet parameter, and in this case is 192.168.2.113 , which is assigned via the DHCP protocol.

In Debian, the network configuration is contained in the /etc/network/interfaces file. You can view it using the nano or vim editor .

Debian Network Configuration

To configure a static IPv4 address, remove or comment the allow-hotplug and dhcp lines, Then add the following configuration.

In this configuration, 192.168.2.150 will be our new IPv4 address with a netmask or network subnet of 255.255.255.0. The default gateway, which also happens to be the router’s IP, is 192.168.2.1 while the DNS nameservers are 192.168.2.1 and 8.8.8.8 .

Set Static IP Address in Debian

Save the changes and exit the file.

To apply the changes, restart the networking service.

Then confirm no errors were encountered

Start Network in Debian

To confirm that the server has acquired the new IP, run the following command:

The output below confirms that we have successfully configured the static IPv4 address.

Find IP Address in Debian

Configure IPv4 Address on Ubuntu

In Ubuntu 18.04 and later versions, Netplan is the default network configuration tool, which enables easy configuration of network settings via YAML files. According to Canonical, netplan processes the YAML files and generates network configurations for systemd-network or NetworkManager .

The network configuration file for modern Ubuntu distributions is located in the /etc/netplan directory. For the desktop system, the configuration file in this directory is 01-network-manager-all.yaml . For servers, the file is /etc/netplan/01-netcfg.yaml .

Once again, let’s check our current IP address which is auto-assigned by DHCP.

Our current IP is 192.168.2.106 . We will set this to 192.168.2.180 .

Check IP Address in Ubuntu

To assign an IPv4 address, we will open the network configuration file.

By default, the following lines automatically set the system to use DHCP for IP assignment.

Ubuntu Network Configuration

Add the following lines to assign a static IP.

Set Static IP Address in Ubuntu

Let us break down the parameters used:

  • enp0s3 – is the name of the network interface.
  • addresses – This configures the IPv4 address on the interface. This is followed by the CIDR, in this case,/24 which implies a network subnet of 255.255.255.0.
  • nameservers – This specifies the DNS servers to be used. In this case, we are using 8.8.8.8 and 8.8.4.4 which are Google’s name servers.
  • routes – This sets the gateway on your system.

Remember to replace the interface name and IP configuration to match your network environment.

Save the changes and exit.

To apply the changes made, run the following command:

Once again, verify if the changes have been reflected as shown.

Find IP Address in Ubuntu

Configure IPv4 Address on RHEL

In Red Hat distributions , the nmcli (NetworkManager Command Line Interface) command-line tool is one of the most preferred ways of configuring an IPv4 address. It does so using the NetworkManager service.

To view the network interface name attached to your system, execute the command:

To display the active connection, run the command:

Find Network Interface in RHEL

In RHEL 9 and other Red Hat distributions based on RHEL, the network configuration file resides in the /etc/sysconfig/network-scripts directory. In our case, the configuration file is ifcfg-enp0s3 .

We will assign a static IPv4 address on the interface ‘ enp0s3 ‘ as shown:

To do so, we will run the following commands:

Set Static IP Address in RHEL

The commands save the changes inside the associated network configuration file. You can view the file using your preferred text editor

RHEL Network Configuration

To confirm the new IP address, run the following command

You can also run the nmcli command without any command-line options and the active interface will be displayed at the top.

Find IP Address in RHEL

How to Configure Hostname in Linux

A well-configured system should be able to resolve its hostname or domain name to the IP address configured. Usually, the hostname and IP address mapping is done in the /etc/hosts file.

To configure hostname resolution, add a host’s entry to the /etc/hosts file. This entry includes the host’s IP address and the hostname as shown.

Be sure to update the /etc/hosts file on every Linux system that you intend to connect to the system on the same local network.

Once done, you can successfully ping the hostname of the Linux machine.

Ping Hostname in Linux

In this tutorial, we have covered IPv4 and IPv6 IP addresses and explored how you can configure IPv4 networking and hostname resolution on Linux.

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

Compile Kernel in Debian

How to Install and Compile Kernel in Debian

Proxmox Create Container

How to Create Containers in Proxmox

Best Debian-based Linux Distributions

The 12 Best Debian-based Linux Distributions

Create VM on Proxmox

How to Create a Virtual Machine in Proxmox

Install TFTP Server on Ubuntu

How to Install and Configure TFTP Server on Ubuntu and Debian

Install Proxmox VE Debian

How to Install Proxmox (Server Virtualization) on Debian 12

8 thoughts on “A Beginner’s Guide to Configuring IPv4 and IPv6 Addresses in Linux”

Ah, it is working like this:

I only have to put into an init script.

I face the following situation: The Internet provider has switched to IPv6.

This means the first 4 blocks, e.g., a02:560:4c19:cd00……. are changing time by time.

The Internet router is able to configure “port forwarding” for IPv6. Indeed, it is not port forwarding, but routing to an IPv6 address in my network.

Unfortunately, the Internet router is not able to route the dynamic part of the IPv6 address of my internal server. I can only configure a fix postfix of the IPv6 address:

let it be: …….. 2001:db8:1234:abcd

While the prefix is changing by the internet provider, the postfix I set it to fix.

To make a service from my internal address available to the internet, I must configure the IPv6 address of my server with the dynamic prefix of the router and the fix postfix configured for routing.

Is it possible to configure it?

Clear, it is a bug in my internet router.

Another way, maybe I will try at the weekend, while the server is getting up, I can call via IPv4 DNS to get the current IPv6 address, put it into the configuration, and restart the network stack.

Title says “Configuring IPv4 and IPv6 Addresses”.

What happened to the “ configure IPv6 section ?”

The pool of IPv4 addresses has already been exhausted so we will have to use IPv6 from now on. I may “hardly ever need to configure an IPv6” but, nevertheless, there WILL be times that I will have to configure IPv6.

It would be handy to know how to do the configuration ahead of time unless IPv6 is self-configuring.

@Dragonmouth,

To assign an IPv6 address temporarily to the network interface, run the following command:

Replace <IPv6_ADDRESS> with the desired IPv6 address, <PREFIX_LENGTH> with the appropriate prefix length and <INTERFACE_NAME> should be replaced with the actual interface name.

For example:

To assign an IPv6 address permanently to the network interface, use the following instructions:

1. Open the configuration file for the desired network interface.

The file name will usually be in the format ifcfg-<INTERFACE_NAME> . For example, if the interface name is eth0 , the file would be ifcfg-eth0 .

Add the following lines to the configuration file.

Restart the network service to apply the changes.

You can confirm your IP address by running ip command.

How to configure IPv6 static IP address using Netplan?

To configure an IPv6 address using Netplan, you can follow these steps:

1. Open the Netplan configuration file using a text editor.

Add the following network configuration to configure an IPv6 address.

In the above example, the interface eth0 is configured with the static IPv6 address 2001:db8:1234:abcd::1 with a prefix length of /64 . The IPv6 gateway is set to 2001:db8:1234:abcd::a .

2. Apply the changes by running the following command:

Thank you, it may help users with old Ubuntu versions.

In newer versions, gateway6 is deprecated.

I don’t think the gateway6 parameter is deprecated in the netplan configuration. Any source you have please share…

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.

  • Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

CentOS / RHEL 6 : How to add/remove additional IP addresses to a network interface

There are two ways to add another IP address to an interface. The old way creates a new virtual interface named in the style of ethX:Y where X and Y are numbers, for instance, eth0:1. Each interface has one IP address. It appears in ifconfig output as an ordinary interface and in ip output with a label attached.

The new way adds a secondary address to the main interface. So, instead of having one interface per IP address, it is possible to add many addresses to the real interface. However, ifconfig tool is too old and can’t see the additional IP addresses, so in this case, the ip tool must be used instead. This is the preferred way nowadays.

Add/Remove additional IP manually

1. Use the ip command to display the current ip address configuration of the interface eth0 :

2. To delete an existing IP

3. To add an IP address:

Add/Remove Additional IP persistently

To add or remove additional IP adresses and keep the configuration persistent, we need to Edit the corresponding /etc/sysconfig/network-scripts/ifcfg-eth[x] configuration file and add/remove as many additional IPADDR[n] and PREFIX[n] entries as additional IP addresses are required.

For example the following configuration file:

would give the following result:

The following additional entries are possible:

You May Also Like

Press ESC to close

configure ip address centos

Configure IP address in Linux (RHEL/CentOS 7)

The first thing that we do after installing an operating system is to configure the IP address i.e. networking on the machine. Whether we want to connect to the internet or only to our local area network (LAN), we must provide information regarding our network to the machine. In this tutorial, we are going to discuss how to configure IP address in Linux (RHEL/CentOS 7) using three different methods.

Also if you would like to assign an IP address to your Ubuntu system, then please refer to this tutorial How to manage network in Ubuntu 18.04 – Netplan Command  or you can also refer to the tutorial for IP COMMAND, using which you can manage the network on all Linux distributions that have IP command installed.

(Recommended Read: IP Aliasing: Assigning multiple IP addresses to single NIC )

Configure IP address in Linux

Method 1- by editing the network interface file.

This method works on all Linux distributions. To configure the IP address, we need to open the network configuration file & pass our network information in the file. In RHEL/CentOS 7, location for all network interfaces in ' /etc/sysconfig/network-scripts ', in our case name of network interface is 'ifcfg-en0s3'. We will now edit the file to configure a static IP address for our system. Open the network interface file,

$ cd /etc/sysconfig/network-scripts $ vi ifcfg-en0s3

configure ip address linux

To configure a static IP address, change the ' BOOTPROTO ' to ' none ' (it's DHCP by default) & enter IP address, gateway & DNS information.  Also, change ' ONBOOT ' to ' yes ' so that we don't have to start networking services every time we restart our system.

configure ip address linux

After making all the changes, save the file & then restart the networking services to implement the changes.

$ systemctl restart network $ vi ifcfg-en0s3

Method 2 - Using the Graphical interface

If we are using RHEL/CentOS with GUI then we can easily configure IP address graphically.  Open 'Network' either by clicking the network icon & then selecting ' Network Settings ' on the top-left corner of the screen or goto Applications-> System Tools-> Settings-> Network.

configure ip address linux

Next, click on the Settings icon (on the bottom right corner of the opened window) & select IPV4 then mention your network information on the opened window.

configure ip address linux

After the IP information has been edited, click on apply & exit from the menu. Lastly restart network services for implementing the changes.

Method 3- Using NMTUI command

This method can be used in GUI as well as in CLI. For using it in GUI mode, open a terminal and enter the command 'nmtui' & press enter or if using CLI, just enter the command 'nmtui' & press enter. This will open a new window with 3 options i.e. we can edit our network interface, activate a network interface, or set a hostname for our system  (read our tutorial on setting hostname HERE ).

To set up networking for the system, select 'Edit a connection', select your network interface & then select 'Edit' using the arrow keys. In the 'IPv4 Configuration' select 'manual' & then enter your network information.

configure ip address centos

After making changes, press 'OK' to save the file & on the next screen press 'Quit' to exit from the menu. Restart your network services for changes to take effect.

Apart from these three methods, you can also configure IP address when installing operating system & also there are two more methods through which we can configure our network on RHEL/CentOS 7 machines i.e. by using ' nmcli command & ifconfig command . This wraps up our tutorial on how to configure IP address in Linux. For any queries/questions, please use the comment box below.

If you think we have helped you or just want to support us, please consider these :-

Connect to us: Facebook | Twitter

Linux TechLab is thankful for your continued support.

Share Article:

Passionate about Linux & open source. Loves to learn, read & write about Linux as well as new technologies.

Install TeamViewer on Ubuntu & CentOS /RHEL

Omd monitoring: install omd on centos 6, one comment.

how to configure ip address in linux rhel 6

That was very helpful, thank you. Best regards.

Leave a Reply Cancel reply

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

GoLinuxCloud

How to configure ipv6 address in Linux (RHEL / CentOS 7/8)

This step by step by guide to configure IPv6 address is validated on RHEL and CentOS 7 .

How-to-configure-ipv6-address-linux

IPv6 can act as a replacement for the IPv4 network protocol. The major problem it solves is the exhaustion of IPv4 addresses by using a much larger network address space. It also provides a number of enhancements and new features for network configuration management and support for future protocol changes.

The key reason IPv6 is not yet in wide deployment is that the core protocol does not have a simple way for systems that only have IPv6 addresses to communicate with systems that only have IPv4 addresses.

An IPv6 address is a 128-bit number , normally expressed as eight colon-separated groups of four hexadecimal nibbles (half-bytes). Each nibble represents four bits of the IPv6 address, so each group represents 16 bits of the IPv6 address.

To make it easier to write IPv6 addresses, leading zeros in a colon-separated group do not need to be written. However at least one nibble must be written in each field. Zeros which follow a non zero nibble in the group do not need to be written.

Since addresses with long strings of zeros are common, combine one or more groups of consecutive zeros with exactly one :: block.

Notice that under these rules 2001:1:1:1443::400 would be another less convenient way to write the example address. But it is a valid representation of the same address, and this can confuse administrators new to IPv6.

Some tips for writing consistently readable addresses

  • Always suppress all the leading zeros in a group
  • Use :: to shorten as much as possible. If two runs of zeros are equal in length, shorten the leftmost run of zeros by preference.
  • Although it is allowed, do not use :: to shorten one group of zeros, Use :0: instead, and save :: for runs of zeros longer than a single group.
  • Always use lowercase letters for hexadecimal numbers a through f .

Pre-requisite before starting to configure IPv6 address

Make sure that IPv6 is enable on your node. Look out for below entry in your sysctl configuration

This will list the IPv6 status for the default value and per interface value.

Here " 0 " means IPv6 is in active on our node, if the above returns " 1 " then it means IPv6 is disable on your node. So if the IPv6 is disable then your IPv6 configuration will not work.

I have already written an article with steps to enable or disable IPv6

Comparison of nm-setting and ifcfg-* directives

The following table maps some of the key NetworkManager settings name relevant to IPv6 connections to ifcfg-* directives.

Configure IPv6 address using Network Manager.

Open Network Manager Console from your Linux node

Select Edit a Connection and click on Ok

How to configure ipv6 address in Linux (RHEL / CentOS 7/8)

Next look out for your Ethernet card on which you wish to configure IPv6 address. If your NIC card does not appear on the list then you can add a new device . Since for me my device ( eno50 ) exists, so I will select the device and select Edit

How to configure ipv6 address in Linux (RHEL / CentOS 7/8)

This will bring you the main configuration page where you must give all the details to configure IPv6 address. Since I do not want to add IPv4 address to the same Ethernet device, I have disabled the IPv4 option.

Provide the IPv6 address/subnet and the gateway . Make sure you select Automatically Connect

How to configure ipv6 address in Linux (RHEL / CentOS 7/8)

Lastly click OK to exit the utility.

Next restart the network services to activate the changes

Now let us check the network configuration of eno50

So looks like I was able to successfully configure my interface with IPv6 address.

Validate the connectivity by pinging the IPv6 gateway

So I am able to connect to my gateway which means my IPv6 configuration was successful.

Configure IPv6 address using CLI

The following command will add a new connection for the interface eno49 , which will auto connect at startup, getting IPv4 networking information using DHCPv4. It will also get IPv6 networking settings by listening for router advertisements on the locallink.

The below command configures the eno49 interface statically using the IPv6 address and network prefix 2001:1:1:1443::433/122 and default IPv6 gateway 2001:1:1:1443::43F , but it still auto connects at startup and saves its configuration into /etc/sysconfig/network-scripts/ifcfg-eno49 .

Let us validate our configuration by pinging the gateway using eno49 interface

Again with the CLI looks like the steps are successful for me.

Modify existing IPv6 configuration

In the below command we are changing the IPv6 address of our interface eno49 from 2001:1:1:1443::433 to 2001:1:1:1443::434 , while the gateway remains the same.

Restart the eno49 interface

Next bring the the interface

Validate the new IP address for eno49 device

Check the connectivity from eno49 to it's gateway

Check the configuration file for eno49

I hope the steps from the article to configure IPv6 address on Linux (CentOS/RHEL 7/8) was helpful. Let me know your suggestions and feedback using the comment section.

How to configure ipv6 address in Linux (RHEL / CentOS 7/8)

He is the founder of GoLinuxCloud and brings over a decade of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, AWS, Networking, and Security. With extensive experience, he excels in various domains, from development to DevOps, Networking, and Security, ensuring robust and efficient solutions for diverse projects.

Can't find what you're searching for? Let us assist you.

Enter your query below, and we'll provide instant results tailored to your needs.

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can send mail to [email protected]

Thank You for your support!!

6 thoughts on “How to configure ipv6 address in Linux (RHEL / CentOS 7/8)”

How did you get /122 when creating the new ip address and same gateway example?

This is the gateway and subnet provided by our network team.

For us noobs: the network should be restarted after the address setup:

service network restart

Thanks for your feedback, I have updated the article 🙂

I really love your website.. Very nice colors & theme. Did you make this amazing site yourself? Please reply back as I’m planning to create my very own site and want to know where you got this from or exactly what the theme is called. Kudos!

One update for Centos 8. Change systemctl restart network to systemctl restart NetworkManager.service

Leave a Comment Cancel reply

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

Notify me via e-mail if anyone answers my comment.

5 Commands to Get IP Address Information on Linux

If you are using a Linux distro without a graphical interface then to find the IP address you have to use the command line interface. Here in this article, we learn the multiple commands that can be used to get information about networking configuration. Finding IP address details can be beneficial in networking configuration and troubleshooting purposes.

Few popular commands to obtain IP Address information on Linux servers or desktops.

The most common command to display network adapter information is “IP addr” on the Linux system. When we execute it without supplying any extra arguments, the command will show the IP address, netmask, gateway, physical address of the adapter, and other details…

To use it, run the given command in your Terminal:

ip addr command

2. ifconfig

Although “ifconfig” is a common command and traditional utility, many modern Linux distros would not have it by default and users need to install it manually. Like “ ip addr” this one can also be used to display IP address information for all active network interfaces.

ifconfig command

3. hostname -I

Those who don’t want detailed info about their Linux system network interfaces, instead of only the IP addresses assigned to them on the system, can use the hostname command with the “ -I ” option. This command provides a simple list of IP addresses assigned to all network interfaces on the system.

hostname command to get IP address

Linux systems users with GUI can also use the Network Manager’s “nmcli” command which offers a powerful interface for managing network connections. Unlike other commands, “ nmcli ” gives well-detailed and structured information about the network interfaces of the system including their IP addresses, here is the command to follow, you can use it without any parameter as well.

nmcli device show command

Note : Those who don’t have “ Network Manager ” and if you like its way of showing the details, install it manually. For example in Ubuntu or Debian, use the command – “ sudo apt install network-manager ” to install it.

nmcli command

5. ip route

The last command that we discuss in this article is “ ip route ” used to display the kernel’s IP routing table . It shows the routes the system learns, including the destination network, gateway, and interface used for forwarding packets.

Although, the output of the “ IP route” command will also have the private address of the PC as well, however, if you want to list only it rather than routing details use the command in the following way:

ip route command to find ipaddress

So, we have seen how we can use the commands like “ ip addr “, “ ifconfig “, “ hostname “, “ nmcli “, and “ ip route “, to quickly find the details of our network interfaces on Linux-running devices. Also, it is better to run these commands with Admin rights i.e. using ‘sudo’ to access restricted network information and make configuration changes when necessary.

Other Articles:

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

  • Use GUI to find my IP address on Ubuntu 22.04 Jammy JellyFish
  • Assign multiple IP addresses to Ubuntu on a single network interface- GUI
  • How to install ifconfig on Kali Linux to check IP address

Newly installed Bitnami Ghost blog keeps redirecting to the LocalHost

Newly installed Bitnami Ghost blog keeps redirecting to the LocalHost

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?

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 .

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 configure IP address in Linux

    how to configure ip address in linux rhel 6

  2. How to configure IP address in Linux

    how to configure ip address in linux rhel 6

  3. How to Configure IPv4 and IPv6 Addresses in Linux

    how to configure ip address in linux rhel 6

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

    how to configure ip address in linux rhel 6

  5. How to Check the IP Address in Linux: 12 Steps (with Pictures)

    how to configure ip address in linux rhel 6

  6. Check IP Address CentOS/RHEL

    how to configure ip address in linux rhel 6

VIDEO

  1. How to Install and Configure Nagios Core Server on Ubuntu 22.04

  2. ip command in Linux with examples

  3. Linux Tutorial 01: How to configure static IP on Redhat Linux

  4. How to Configure IP Address in Linux?

  5. (Tips)Configuring IP Networking with nmtui,Hostname and How do I set a local repo in RHEL 9

  6. Linux

COMMENTS

  1. 3.6. Configuring IP Networking with ip Commands Red Hat Enterprise

    The ip utility can be used to assign IP addresses to an interface with the following form:

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

    Networking ip systemctl 1. Introduction Many Linux distributions come with a network manager. In theory, it should help during the networking setup. Yet, we might not always want to install or use managers when setting up an interface.

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

  4. Configure CentOS 6 Network Settings

    Overview This tutorial will walk you through configuring your network configurations on CentOS 6.X. There are three different methods to choose from, depending on what installation type and packages you have installed. Manual configuration is done by directly modifying the configuration files.

  5. How to Configure IP address in Red Hat LINUX 6

    How to Configure IP address in Red Hat Enterprise Linux 6 RHEL 6how How to configure ip address in red hat enterprise linux 6 rhel 6 using three 3 ways1 Co...

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

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

    To configure static IP address in RHEL / CentOS / Fedora, you will need to edit: ... 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. Tags Linux Tricks.

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

  9. How To Configure IP Address in CentOS 7 / RHEL 7 & CentOS 6 ...

    DHCP IP Address. In this mode, the system will get an IP address from the DHCP server. This is the default mode set on CentOS to get an IP address from the DHCP server. Edit the ifcfg-<interfacename> file. Just modify the lines like this. Restart the network service using the below command.

  10. How to Configure IPv4 and IPv6 Addresses in Linux

    Table of Contents What is an IP Address? Difference Between IPv4 vs IPv6 IPv4 Address Network Section What is IPv4 Class A What is IPv4 Class B What is IPv4 Class C Host Portion IPv6 Address Dynamic (DHCP) and Static IP Configuration DHCP IP Address Static IP Address How to Configure IPv4 Networking in Linux Configure IPv4 Address on Debian

  11. CentOS / RHEL 6 : How to add/remove additional IP addresses to a

    The new way adds a secondary address to the main interface. So, instead of having one interface per IP address, it is possible to add many addresses to the real interface. However, ifconfig tool is too old and can't see the additional IP addresses, so in this case, the ip tool must be used instead. This is the preferred way nowadays.

  12. Set Static IP in CentOS 6.4?

    You can read about the new naming convention for devices here, titled: Features/ConsistentNetworkDeviceNaming.The change in naming conventions is also discussed in the official Redhat docs titled: Appendix A. Consistent Network Device Naming.The convention now follows one based on location rather than arbitrarily eth0, etc.. Change the network device naming scheme from ethX to a physical ...

  13. Configure IP address in Linux (RHEL/CentOS 7)

    Method 2 - Using the Graphical interface. If we are using RHEL/CentOS with GUI then we can easily configure IP address graphically. Open 'Network' either by clicking the network icon & then selecting 'Network Settings' on the top-left corner of the screen or goto Applications-> System Tools-> Settings-> Network.. Next, click on the Settings icon (on the bottom right corner of the opened window ...

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

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

    Type the following ip command: # ip a Fig.01: List NICs in a CentOS 7 server using ip command Or use the following command: # nmcli -p dev Fig.02: nmcli command in action Here is a typical DHCP configration for eth0 (stored in /etc/sysconfig/network-scripts/ifcfg-eth0 file):

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

    Method 1 - modifying interface configuration file manually For each network interface managed by the NetworkManager daemon, a configuration file is created inside the /etc/sysconfig/network-scripts directory. The name of the file is composed by the ifcfg- prefix plus the name of the interface.

  17. Check IP Address CentOS/RHEL

    Get started by opening a command line terminal and check for your internal IP address by executing the ip command. $ ip a Locate the requested network interface and check for assigned IP address. Additionally, the above command also reveals the network interface hardware address a.k.a MAC address.

  18. How to configure ipv6 address in Linux (RHEL / CentOS 7/8)

    Select Edit a Connection and click on Ok. Next look out for your Ethernet card on which you wish to configure IPv6 address. If your NIC card does not appear on the list then you can add a new device. Since for me my device ( eno50) exists, so I will select the device and select Edit.

  19. 5 Commands to Get IP Address Information on Linux

    Like "ip addr" this one can also be used to display IP address information for all active network interfaces. ifconfig 3. hostname -I. Those who don't want detailed info about their Linux system network interfaces, instead of only the IP addresses assigned to them on the system, can use the hostname command with the "-I" option. This ...

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

  21. Run container-based workloads on LinuxONE Virtual Servers for VPC

    Complete the following steps: Step 1. Create a LinuxONE Virtual Servers instance. Log in to IBM Cloud. In the left menu, click VPC Infrastructure > Virtual server instances . On the "Virtual server instances for VPC" page, click the Create button. Select a location for your virtual server.