IP address, subnet mask, and default gateway

For Debian and Ubuntu

Static Address:
You will need to configure your IP address, subnet mask and default by editing the interfaces file. I use VI but you can choose any text editor.

Edit the interfaces file
edit /etc/network/interfaces
iface eth0:1 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1

DHCP:

Edit the interfaces file with VI, make sure the static address is remarked out with the # sign.
edit /etc/network/interfaces
iface eth0:1 inet dhcp
# address 192.168.1.10
# netmask 255.255.255.0
# gateway 192.168.1.1

Restart the networking
/etc/init.d/networking restart

Take a network card down or interface down
ifdown eth0
ifup eth0
For Redhat, CentOS, and Fedora

Edit the network file to enable networking, the host name, and the default gateway

edit /etc/sysconfig/network

NETWORKING=yes
HOSTNAME=server.domainName.com
GATEWAY=192.168.1.254

To add or edit the ip address and subnet mask edit the ifcfg-eth0 file. If you have more than one network card you will have an ifcfg-eth1 and so on.

#vi /etc/sysconfig/network-scripts/ifcfg-eth0,

To view the file
# cat /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
BOOTPROTO=static
DHCPCLASS=
HWADDR=00:23:24:52:B9:4C
IPADDR=192.168.1.10
NETMASK=255.255.255.0
ONBOOT=yes

If you are using DHCP set the BOOTPROTO=dhcp
DNS

Edit the resolv.conf file and set change the ip addresses

# vi /etc/resolv.conf

search cyberciti.biz
nameserver 192.168.1.5
nameserver 8.8.8.8
nameserver 192.168.1.6