The ifconfig Command Configuring the Network Interface

The ifconfig command, to configure network interface 1. The netstat command, to show network−related data 2.

15.4.1 The ifconfig Command

The ifconfig command sets, or checks, configuration values for network interfaces. It is used to set the IP address, the subnet mask, and the broadcast address for each interface. The format of the command is: ifconfig interface ipaddress netmask mask broadcast address The command arguments are shown in the following table: Argument Meaning interface The name of the network interface to be configured. ipaddress The IP address assigned to this interface. Enter an address as either an IP address in dotted numerical form or as a hostname; if the hostname is given, ifconfig must resolve the hostname − IP address. During system startup, ifconfig is usually executed before DNS is running, so the hostname must exist in etchosts file. SunOSSolaris uses the etchostname.ifname file for this purpose where ifname is the name of the interface. netmask mask The subnet mask for this interface. The mask value depends on the subnet local network address class for example, 255.255.0.0 for class B, or 255.255.255.0 for class C; it could be also specified in the etcnetmasks file. broadcast address The broadcast address for the network is defined by the address value; the default broadcast address network IP address, with all bits in the host part determined by the netmask, is set to 1. Each network interface must be configured before its use, and this task can be accomplished from the command line. However, to provide a proper setting during system startup, the ifconfig command is always included in the corresponding rc initialization script. The ifconfig command can also be used to check already−configured network interfaces, individually or all at once. Here are a few examples: ifconfig le0 SunOSSolaris le0: flags=63UP,BROADCAST,NOTRAILERS,RUNNING inet 146.95.1.11 netmask ffff0000 broadcast 146.95.0.0 ether 8:0:20:8:1e:f2 ifconfig lo0 lo0: flags=49UP,LOOPBACK,RUNNING inet 127.0.0.1 netmask ff000000 ifconfig −a le0: flags=63UP,BROADCAST,NOTRAILERS,RUNNING inet 146.95.1.11 netmask ffff0000 broadcast 146.95.0.0 ether 8:0:20:8:1e:f2 lo0: flags=49UP,LOOPBACK,RUNNING inet 127.0.0.1 netmask ff000000 ifconfig lan0 HP−UX lan0: flags=63UP,BROADCAST,NOTRAILERS,RUNNING inet 146.95.8.31 netmask ffff0000 broadcast 146.95.255.255 356 ifconfig lo0 lo0: flags=1049UP,LOOPBACK,RUNNING inet 127.0.0.1 netmask ff000000 When used to check the status of an interface, the ifconfig command displays two output lines. The first line shows the interface name and the flags that define the interfaces characteristics; the flags are displayed as both a numeric value and a set of keywords. The meanings of the flag keywords in the previous examples are: UP The interface is enabled for use. BROADCAST The interface supports broadcast, which means it is connected to the network that support broadcast in these cases Ethernet. NOTRAILER The interface does not support trailer encapsulation. Some systems such as SunOS completely ignored this possibility and never used it. RUNNING The interface is operational. LOOPBACK The interface supports local loopback. The second line of the ifconfig output displays information that directly relates to TCP IP. The meanings of the keywords used are: inet Keyword inet is followed by the IP address assigned to this interface. netmask Keyword netmask is followed by the subnet mask written in hexadecimal format. The mask specifies valid address bits of the network subnetwork part of the IP address assigned to the interface. broadcast Keyword broadcast is followed by the broadcast address assigned to this interface. The system figures out the broadcast address as the maximal available IP address within the defined network subnetwork.

15.4.2 The netstat Command