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
domainname: demo.eu
Static IP address: 10.0.1.23
Netmask: 255.255.255.0
Gateway: 10.0.1.254
Primary DNS server: 10.0.1.1
Secondary DNS server: 10.0.1.253

Networking is set up in these files:
/etc/sysconfig/network
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/resolv.conf

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”):

 


Troubleshooting

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

Type:

 

Source: http://www.linuxmigration.com/quickref/install/network.html

Leave a Reply