Brief description  about Online courses   join in Online courses

How to Assign IP address?

Devesh  Goyal
Devesh Goyal
Technical Manager

Computers may be assiged a static IP addressor assigned one dynamically. Typically a server will require a static IP while
a workstation will use DHCP (dynamic IP assignment). The Linux server requiresa static IP so that those who wish to use
its resources can find the system. It is more easily found if the IP addressdoes not change and is static. This is not
important for the Linux client workstation and thus it is easier to use anautomated Dynamic Host Configuration Protocol
(DHCP) for IP address assignment.
Static IP address assignment:

Choose one of the following methods:

    Command Line:

        /sbin/ifconfig eth0 broadcast

    Network address by convention would be the lowest:
    Broadcast address by convention would be the highest:
    The gateway can be anything, but following convention:

    Note: the highest and lowest addresses are based on thenetmask. The previous example is based on a netmask of

    Red Hat / Fedora GUI tools:
        /usr/bin/neat Gnome GUI networkadministration tool. Handles all interfaces. Configure for Static IP or DHCPclient.
        (First available with Red Hat 7.2.)
        /usr/bin/netcfg (Handles allinterfaces) (last available in Red Hat 7.1)

    Red Hat / Fedora Console tools:
        /usr/sbin/system-config-network-tui(Text User Interface)
        /usr/sbin/netconfig (Only seems towork for the first network interface eth0 but not eth1,...)

    Directly edit configuration files/scripts. See format below.

The ifconfig command does NOT store this information permanently. Upon rebootthis information is lost. Manually add the
network configuration to /etc/sysconfig/network-scripts/ifcfg-eth0 (RedHat/Fedora/CentOS) for the first NIC, ifcfg-eth1
for the second, etc, or /etc/network/interfaces (Ubuntu) as shown below. Anyother commands you may want to add to the
system boot sequence can be added to the end of the file /etc/rc.d/rc.local.The commands netcfg and netconfig make
permanent changes to system network configuration files located in/etc/sysconfig/network-scripts/, so that this
information is retained and used upon system boot.

Command line IP Configuration: ifconfig

ifconfig interface [aftype] options |address ...


  • interface: eth0, eth1, eth2 represent the computer ethernet interfaces
  • aftype: inet (TCP/IP, default), inet6 (IPv6), ax25 (AMPR Packet Radio), ddp (Appletalk Phase 2), ipx (Novell IPX) or netrom (AMPR Packet radio)





Activate the interface. Implied if IP addresses are specified.


Shut down interface


Enable ARP protocol on this interface. Allow ARP to detect the addresses of computer hosts attached to the network.


Disable ARP protocol on this interface


Enable promiscuous mode. Receive all packets on the network not just those destined for this interface.


Disable promiscuous mode.

mtu ##

Specify the Maximum Transfer Unit (MTU) of the interface. The MTU is the maximum number of octets the interface is able to handle in a single transaction. Defaults: Ethernet: 1500 SLIP: 296

broadcast XXX.XXX.XXX.XXX

Set the network broadcast address for this interface.


Set the IP network mask for this interface.



Write your comment now