Last updated on November 22, 2020 by Dan Nanni
In CentOS, Fedora or RHEL, if you have disabled advanced network management tools such as Network Manager, you can configure network interfaces by using configuration files located in /etc/sysconfig/network-scripts
. For each network interface (e.g., eth0
), there should be a corresponding configuration file (e.g., ifcfg-eth0
) in the directory. If you would like to configure a network interface, do the following.
If you would like to assign a static IP address to the interface eth0
:
$ sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 BOOTPROTO=static HWADDR=00:05:29:E0:4F:3D IPADDR=10.0.1.10 NETMASK=255.255.255.0 GATEWAY=10.0.1.1 ONBOOT=yes TYPE=Ethernet
If the interface eth0
has IP address assigned by DHCP:
$ sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 BOOTPROTO=dhcp HWADDR=00:05:29:E0:4F:3D ONBOOT=yes TYPE=Ethernet
Once network configuration has been created/updated, you can activate a network interface by running:
$ sudo service network restart
Note that if you are using Desktop version of CentOS, where network interfaces are configured with Network Manager by default, you will need to disable NetworkManager first, before configuring interfaces as described in this post.
This website is made possible by minimal ads and your gracious donation via PayPal or credit card
Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.
Xmodulo © 2021 ‒ About ‒ Write for Us ‒ Feed ‒ Powered by DigitalOcean