= Red Hat Networking =
**Summary**: How to setup networking on Red Hat. \\
**Date**: Around 2014 \\
**Refactor**: 29 March 2025: Checked links and formatting. \\
{{tag>redhat linux}}
With the introduction of Red Hat 6 a new utility was introduced to configure networking. It is called the Network Manager, is running as a service and appears on the desktop in the upper right corner: \\
[{{redhatnetworking01.jpg}}] \\
Since it is a service it can be stopped and started to reset the network settings and it can also be disabled. It cannot to do all settings you might want to configure, for example bonding of networkcards.
Besides the Network Manager there are other ways to configure the network. You can edit the network configuration files manually, or use the old "system-config-network" tool.
We'll go through the different options in this article.
= Network Manager =
As this is the preferred red hat way we'll do this option first. If you use Network Manager, all network related files are managed by Network Manager. This means that if you would edit the /etc/resolv file to modify DNS settings, these modifications would be overwritten by Network Manager if the network would be reset by for example a reboot.
Modifying the network settings using Network Manager is quite easy:
* Right-click on the icon of Network Manager
* Select "Edit Connections"
* This screen appears:
[{{redhatnetworking02.jpg}}] \\
* Select the network card (eth0) you want to edit and click edit
* Now this screen appears (note that I already clicked on the IPv4 tab):
[{{redhatnetworking03.jpg}}] \\
* Now here are a few thing you need to keep in mind:
* You should always select the options to Connect Automatically and to Make the connection available for all users.
* If you set the method to static, and enter the settings you need to confirm each field with a ENTER key
* If you would enter all these settings it would look like this:
[{{redhatnetworking04.jpg}}] \\
As you can see, for this example I just entered the information I already got from the DHCP server. If you want to look at that information right click again on the Network Manager icon and select "Connection Information". This shows the extra screen as displayed above.
If you save this information the network configuration gets updated immediately meaning you might lose the network connection for a short while. Keep that in mind if you logged in remote on the system.
== Network Files Managed by Network Manager ==
These are the files managed by Network Manager after setting the configuration as displayed above:
* /etc/resolv.conf
* /etc/sysconfig/network
* /etc/sysconfig/network-scripts/ifcfg-eth0
[root@localhost ~]# cat /etc/resolv.conf
# Generated by NetworkManager
domain localdomain
search localdomain
nameserver 192.168.25.2
[root@localhost ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=localhost.localdomain
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
BOOTPROTO=none
IPV6INIT="yes"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
UUID="e248948d-d50c-45d0-b224-eb5d3a4a8341"
HWADDR=00:0C:29:C2:37:4F
IPADDR=192.168.25.128
PREFIX=24
GATEWAY=192.168.25.2
DNS1=192.168.25.2
DOMAIN=localdomain
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME="System eth0"
LAST_CONNECT=1395170285
[root@localhost ~]#
The last file will change if you would change the settings back:
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
BOOTPROTO=dhcp
IPV6INIT="yes"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
UUID="e248948d-d50c-45d0-b224-eb5d3a4a8341"
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME="System eth0"
HWADDR=00:0C:29:C2:37:4F
PEERDNS=yes
PEERROUTES=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
LAST_CONNECT=1395171785
> Note that configured static routes are stored per interface in /etc/sysconfig/network-scripts/route-
== Permanently Disable Network Settings==
Although Network Manager is a service and could be disabled, the supported method for permanently disabling network manager is adding the following line to the ifcfg-* files for each interface:
NM_CONTROLLED=NO
== Reset Network Information ==
Using the network ifdown and ifup commands you can reset the network information as if the server was rebooted, perfect for testing your network config to see if it is persistent over reboots. If you are working remote, you should issue them on the same line:
ifdown eth0
ifup eth0
ifdown eth0;ifup eth0
The easiest way to check if a network connection is up is looking at the Network Manager icon, it will show a red error sign.
= Network Commands =
There are a few commands that can be very handy when viewing network information:
* ip addr show: shows network information
* ip addr show eth0
* short: ip a s
* hostname: shows the hostname
* hostname : sets the hostname until the next reboot
* ip route: shows routing information
* netstat -rn: shows routing information the old way
* short: ip r
* ip -s link show eth0: shows network statistics
* netstat -i: shows network statistics
* netstat -i 2: refreshed the network statistics every 2 seconds
* host hostname: resolves IP information for a specific host
* host ip address: resolves hostname information for a specific IP address
* disg hostname: shows extended resolving information for a specific host
* traceroute -Tn hostname: shows the network route with all hops
* mtr hostname: shows the network route with all hops with a nicer layout
= Change the Hostname =
As shown above in the commands to temporarily change the hostname use this command:
hostname new.fqdn.name
To permanently change the hostname edit the /etc/sysconfig/network file to reflect the new hostname.
= system-config-network =
In case you can't remember how all these tools are called and which files you need to edit you can always fallback on "system-config-network". This tool even works if you don't have a graphical environment: \\
[{{redhatnetworking05.jpg}}] \\
It will allow you to do some simple network troubleshooting.