|Lesson 7|| Setting the IP address and netmask |
|Objective||Use ifconfig command to set IP address and netmask? |
Setting IP Address 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).
ifconfig command will set the IP address, netmask, and other flags on a device.
For example, to set IP address 18.104.22.168 and netmask 255.255.255.0, enter:
host# /sbin/ifconfig eth0 22.214.171.124
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]
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.
ifconfig is run by the ifup script, which is started from the run level 3 startup scripts.