Configuring Network Interfaces in RedHat

A minimal install of RedHat 7.x does not enable the network by default (network interfaces are enabled when you login to the GUI bu the network manager – which doesn’t work if there is no GUI).

The available network interfaces may be detected but will not be assigned an IP address.

# ifconfig
ens33: flags=4163 mtu 1500
        ether 00:0c:29:a4:38:d0 txqueuelen 1000 (Ethernet)
        RX packets 4 bytes 800 (800.0 B)
        RX errors 0 dropped 0 overruns 0 frame 0
        TX packets 0 bytes 0 (0.0 B)
        TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
        
lo: flags=73 mtu 65536
        inet 127.0.0.1 netmask 255.0.0.0
        inet6 ::1 prefixlen 128 scopeid 0x10
        loop txqueuelen 1 (Local Loopback)
        RX packets 8 bytes 812 (812.0 B)
        RX errors 0 dropped 0 overruns 0 frame 0
        TX packets 8 bytes 812 (812.0 B)
        TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

To enable networking you need login on the console as root and update the system network configuration.

# vi /etc/sysconfig/network

Add or change the line shown below to enable the network.

NETWORKING=yes

Then you need to create a config file for each interface, however you need to remember that the name of the config file depends on the interface name which in this case is ens33.

On recent versions of RedHat the network interface may be called something like enp2s0 or even enp1s0f1 (if you prefer to use the old naming then you can turn off the BIOS enumeration of device names).

# vi /etc/sysconfig/network-scripts/ifcfg-ens33

If you want to use DHCP then you just need the following settings. If you are have installed the network manager then you need to include NM_CONTROLLED=no otherwise these settings will be ignored.

DEVICE=ens33
NM_CONTROLLED=no
BOOTPROTO=dhcp
ONBOOT=yes

Or if you want to use a static address.

DEVICE=ens33
NM_CONTROLLED=no
ONBOOT=yes
IPADDR=192.168.0.1
NETMASK=255.255.255.0
GATEWAY=192.168.0.254

Then you should be able to bring the interface up.

# ifup ens33
# ifconfig
ens33: flags=4163 mtu 1500
        inet 192.168.16.111 netmask 255.255.255.0 broadcast 192.168.16.255
        inet6 fe80::dc2e:f37f:dbf2:b4c2 prefixlen 64 scopeid 0x20
        ether 00:0c:29:a4:38:d0 txqueuelen 1000 (Ethernet)
        RX packets 41 bytes 5210 (5.0 KiB)
        RX errors 0 dropped 0 overruns 0 frame 0
        TX packets 44 bytes 3902 (3.8 KiB)
        TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
        
lo: flags=73 mtu 65536
        inet 127.0.0.1 netmask 255.0.0.0
        inet6 ::1 prefixlen 128 scopeid 0x10
        loop txqueuelen 1 (Local Loopback)
        RX packets 20 bytes 1964 (1.9 KiB)
        RX errors 0 dropped 0 overruns 0 frame 0
        TX packets 20 bytes 1964 (1.9 KiB)
        TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

This entry was posted in CentOS, RedHat and tagged , , . Bookmark the permalink.

Leave a comment

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