Category Archives: Linux

Linux Static IP Address Configuration

You need to update and/or edit the network configuration files.

In this example you will use the following Internet Protocol Version 4 (TCP/IPv4) Properties including IP, default gateway, and preferred DNS servers:

IP address: 192.168.1.10

Netmask: 255.255.255.0

Hostname: server1.cyberciti.biz

Domain name: cyberciti.biz

Gateway IP: 192.168.1.254

DNS Server IP # 1: 192.168.1.254

DNS Server IP # 2: 8.8.8.8

DNS Server IP # 3: 202.54.2.5

           

For static IP configuration you need to edit the following files using a text editor such as vi.

Edit /etc/sysconfig/network as follows, enter:

# cat /etc/sysconfig/network

 

Sample static ip configuration:

NETWORKING=yes

HOSTNAME=server1.cyberciti.biz

GATEWAY=192.168.1.254

 

Edit /etc/sysconfig/network-scripts/ifcfg-eth0, enter:

# cat /etc/sysconfig/network-scripts/ifcfg-eth0

 

Sample static ip configuration:

# Intel Corporation 82573E Gigabit Ethernet Controller (Copper)

DEVICE=eth0

BOOTPROTO=static

DHCPCLASS=

HWADDR=00:30:48:56:A6:2E

IPADDR=192.168.1.10

NETMASK=255.255.255.0

ONBOOT=yes

 

Edit /etc/resolv.conf and setup DNS servers, enter:

# cat /etc/resolv.conf

 

Sample static IP configurations:

search cyberciti.biz

nameserver 192.168.1.254

nameserver 8.8.8.8

nameserver 202.54.2.5

 

Finally, you need to restart the networking service, enter:

# /etc/init.d/network restart

 

To verify new static ip configuration for eth0, enter:

# ifconfig eth0

# route -n

# ping 192.168.1.254

# ping google.com

 via Linux Static IP Address Configuration.