Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Configure the Network

Using Linux

Version 0.1 ● 8th May 2014

© 2014 Faisal Khan - www.FaysalKhan.org

licensed under the terms of the GNU Free Documentation License Version 1.3 or later
Configure the Network

Using Linux

VERSION: 0.1 REVISION DATE: 8th May 2014


www.FaysalKhan.Org
Table Of Contents
Overview.................................................................................................................................. 1

Linux Static TCP/IP Settings..................................................................................................... 2

Debian / Ubuntu Linux Static IP Configuration..........................................................................4

Configure the Network i


www.FaysalKhan.Org

Overview

How do we can configure the Internet Protocol version 4 (IPv4) properties of a network
connection with a static IP address for servers running Linux operating systems? How do we can
configure static IP address under Debian Linux or Redhat / RHEL / Fedora / Redhat Enterprise
Linux server?

If you need to update and/or edit the network configuration files. This manual provides
procedures to configure a static IP address on a computer running the following operating
systems:

RHEL / Red hat / Fedora / CentOS Linux eth0 config file - /etc/sysconfig/network-scripts/ifcfg-eth0

RHEL / Red hat / Fedora / CentOS Linux eth1 config file - /etc/sysconfig/network-scripts/ifcfg-eth1

Debian / Ubuntu Linux - /etc/network/interfaces

Configure the Network 1


www.FaysalKhan.Org

Linux Static TCP/IP Settings


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.faysalkhan.org

Domain name: faysalkhan.org

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

RHEL / Red hat / Fedora / CentOS Linux Static IP Configuration

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:

# vi /etc/sysconfig/network

Sample static ip configuration:

NETWORKING=yes

HOSTNAME=server1.faysalkhan.org

GATEWAY=192.168.1.254

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

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

Sample static ip configuration:

# Intel Corporation 82573E Gigabit Ethernet Controller (Copper)

DEVICE=eth0

Configure the Network 2


www.FaysalKhan.Org
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:

# vi /etc/resolv.conf

Sample static IP configurations:

search faysalkhan.org

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

Configure the Network 3


www.FaysalKhan.Org

Debian / Ubuntu Linux Static IP Configuration


Edit /etc/hostname, enter:

# vi /etc/hostname

Sample ip config:

server1.faysalkhan.org

Edit /etc/network/interfaces, enter:

# vi /etc/network/interfaces

Sample static ip config:

iface eth0 inet static

address 192.168.1.10

network 192.168.1.0

netmask 255.255.255.0

broadcast 192.168.1.255

gateway 192.168.1.254

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

# vi /etc/resolv.conf

Sample dns static IP configurations:

search faysalkhan.org

nameserver 192.168.1.254

nameserver 8.8.8.8

nameserver 202.54.2.5

Finally, you need to restart the networking service under Debian / Ubuntu Linux, enter:
Configure the Network 4
www.FaysalKhan.Org
# /etc/init.d/networking restart

Type the following commands to verify your new setup, enter:

# ifconfig eth0

# route -n

# ping google.com

Configure the Network 5

You might also like