On CentOS I no longer have a ifcfg-eth0
configuration file (I deleted it). When I run system-configure-network
it shows no interfaces that I can edit. How can I recreate the ifcfg-eth0
configuration file? (Like the CentOS installer does)
I can manually do a: ifconfig eth0 192.168.0.199
and then a ping 192.168.0.1
. But that's not the proper way. How can I do it using the CentOS network scripts?
I prefer not to do this by hand as there are many hardlinks and confusing stuff. I am new to CentOS.
There might be a utility, but I don't know what it is. You can just create a file at
/etc/sysconfig/network-scripts/ifcfg-eth0
with contents similar to:I use the command: system-config-network-tui
Creating the file by hand is a good answer too, but this will get the MAC address for you.
This may not be valuable anymore to the asker but for someone else, if you have the gui running you can go to
System > Preferences > Network Connections
and a window will open. Now if you see a device listed there then click on it and just make some edit and save and the file will appear. If no device is listed (will be rare and only if you aren't getting internet connectivity) then you can simply click add and name iteth0
or whatever you like and click save. No need to edit anything, it'll automatically do it all for you.PS: the file
ifcfg-"NAME"
is the name you give it in the network connections window when you created it.So this Worked for me.
History:
I added a new Virtual Network card, whose ifcfg-eth2 file was not generated after a re-boot.
I navigated the the network-scripts directory and ran the commands in the below sequence.
There is a utility called sysconf-network or something like that to allow you to manager the network connections. That is a command line utility.
Here is a link to the FAQ about their /etc/sysconfig system.
Under CentOS 8, I used the
nmtui
tool that comes with minimal installation in order to recreate the/etc/sysconfig/network-scripts/ifcfg-{interface}
files. So far the easiest I found.