Distributed Networks Home   Tweet
DBWebApplications eWebProgrammer


Lesson 7 Setting the IP address and netmask
Objective Use ifconfig command to set IP address and netmask?
How do you use the ifconfig command to set the IP address and netmask?
This use of the ifconfig command is almost always part of the boot procedure (or, in the case of PPP, part of the dial-up procedure).
The ifconfig command will set the IP address, netmask, and other flags on a device.
For example, to set IP address 131.197.25.13 and netmask 255.255.255.0, enter:
host# /sbin/ifconfig eth0 131.197.25.13 
   netmask 255.255.255.0
The ifconfig command may also be used to configure interfaces for different networking protocols, and may be used to set other parameters on the interface (though doing so is rarely necessary). In addition, ifconfig will often take a host name, rather than an IP address, as an argument:
host# /sbin/ifconfig eth0 [machine_name] 
   netmask 255.255.255.0
In this situation, the IP address will be extracted from the /etc/hosts file.
IP Address and Netmask
The assignment of the IP address and netmask is part of the boot process.
Red Hat© Linux uses a directory of scripts called /etc/sysconfig/network-scripts to configure interfaces. Each interface has a file called if-interface (if-eth0, for example), where the basic parameters for the interface are set.
Then ifconfig is run by the ifup script, which is started from the run level 3 startup scripts.