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:
# The next line "127.0.0.1" is needed. Do not remove it. 127.0.0.1 localhost.localdomain localhost 10.0.1.23 server
Your /etc/sysconfig/network file would be:
NETWORKING=yes HOSTNAME=server GATEWAY=10.0.1.23
Your /etc/sysconfig/network-scripts/ifcfg-eth0:
DEVICE=eth0 BOOTPROTO=static BROADCAST=10.0.1.255 IPADDR=10.0.1.23 NETMASK=255.255.255.0 NETWORK=10.0.1.0 ONBOOT=yes
DNS servers are set in: /etc/resolv.conf. An example:
domain demo.eu search demo.eu nameserver 10.0.1.1 nameserver 10.0.1.253
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:
ifconfig eth0 10.0.1.23 netmask 255.255.255.0 up
To set a default route or gateway (“gw” = “gateway”):
route add default gw 10.0.1.254 eth0
Troubleshooting
If your system is saying there is no Ethernet card found, make sure the card is in the kernel.
Type:
modprobe eth0 dmesg | less Look for any info about eth0 to help track down the problem. cat /etc/modules.conf Look for a line line this: alias eth0 driver-name-like-wdi or 3c503
Source: http://www.linuxmigration.com/quickref/install/network.html