IP Addressing And Configuration In LINUX - Online Article

Assigning an IP address

Computers may be assiged a static IP address or assigned one dynamically.

 

Static IP address assignment

Choose one of the following methods:

  • Command Line:
    /sbin/ifconfig eth0 192.168.10.12 
    netmask 255.255.255.0
    broadcast 192.168.10.255

    Network address by convention would be the lowest: 192.168.10.0

  • Broadcast address by convention would be the highest: 192.168.10.255
  • The gateway can be anything, but following convention: 192.168.10.1
  • Note: the highest and lowest addresses are based on the netmask. The previous example is based on a netmask of 255.255.255.0
  • Red Hat / Fedora GUI tools:
    • /usr/bin/neat Gnome GUI network administration tool. Handles all interfaces. Configure for Static IP or DHCP client. (First available with Red Hat 7.2.)
    • /usr/bin/netcfg (Handles all interfaces) (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 to work 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 reboot this information is lost. (Manually add the commands to the end of the file /etc/rc.d/rc.local to execute them upon boot.) 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.

The IANA has allocated IP addresses in the range of 192.168.0.0 to 192.168.255.255 for private Ubuntu / Debian IP Configuration Files:

File: /etc/network/interfaces

Static IP Example

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 208.88.34.106
netmask 255.255.255.248
broadcast 208.88.34.111
network 208.88.34.104
gateway 208.88.34.110

Dynamic IP (DHCP) Example

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto eth1
iface eth1 inet dhcp

auto eth2
iface eth2 inet dhcp

auto ath0
iface ath0 inet dhcp

auto wlan0
iface wlan0 inet dhcp

Interfaces

  • lo: Loopback interface (network within your system without slowing down for the real ethernet based network)
  • eth0: First ethernet interface card
  • wlan0: First wireless network interface

Red Hat / Fedora Core IP Configuration Files

The Red Hat configuration tools store the configuration information in the file /etc/sysconfig/network.

They will also allow one to configure routing information.File: /etc/sysconfig/network.

Static IP address Configuration: (Configure gateway address)

NETWORKING=yes
HOSTNAME=my-hostname - Hostname is defined here and by command hostname
FORWARD_IPV4=true - True for NAT firewall gateways and linux routers.
False for everyone else - desktops and servers.

GATEWAY="XXX.XXX.XXX.YYY" - Used if your network is connected to another network or the internet.
Static IP configuration. Gateway not defined here for DHCP client.

OR for DHCP client configuration

NETWORKING=yes
HOSTNAME=my-hostname - Hostname is defined here and by command hostname

Gateway is assigned by DHCP server.) OR for NIS client configuration:

NETWORKING=yes
HOSTNAME=my-hostname - Hostname is defined here and by command hostname
NISDOMAIN=NISProject1 - NIS domain to attach

File (Red Hat/Fedora)

/etc/sysconfig/network-scripts/ifcfg-eth0
  (S.u.s.e.: /etc/sysconfig/network/ifcfg-eth-id-XX:XX:XX:XX:XX) This file used by the command scripts ifup and ifdown.

About the Author:

No further information.




Comments

No comment yet. Be the first to post a comment.