Setting your hostname, IP address, netmask, gateway, DNS server via files

It is sometimes helpful to know what is going on behind the scenes or if you want to modify the network configuration via changing files.

For example, assume you want to modify the network configuration by modifying files with the following:
hostname: server
Static IP address:
Primary DNS server:
Secondary DNS server:

Networking is set up in these files:

First, add your host to the /etc/hosts file:

Your /etc/sysconfig/network file would be:

Your /etc/sysconfig/network-scripts/ifcfg-eth0:

DNS servers are set in: /etc/resolv.conf. An example:


Using ifconfig and route

You normally would not need to use ifconfig or route unless you want to change your IP address, disable the Ethernet interface, etc. change your gateway, etc. This is sometimes helpful, so the information is here. To set an ip address:

To set a default route or gateway (“gw” = “gateway”):



If your system is saying there is no Ethernet card found, make sure the card is in the kernel.




Leave a Reply