In CentOS, Fedora or RHEL, 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:
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 has IP address assigned by DHCP:
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:
Note that if you are using Desktop version of Linux, you will need to disable NetworkManager first, before attempting to configure interfaces as described above.
Subscribe to Xmodulo
Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.
Did you find this tutorial helpful? Then please be generous and support Xmodulo!
Latest posts by Dan Nanni (see all)
- How to install Suricata intrusion detection system on Linux - September 3, 2015
- How to switch from NetworkManager to systemd-networkd on Linux - August 31, 2015
- How to set up a system status page of your infrastructure - August 25, 2015