Tutorial on Figuring out your server: IP Addresses

Name Service Queries
Routers
This tutorial has examples for four versions of UNIX: Linux, Oracle’s Solaris, Apple’s Macintosh OS X and IBM’s AIX
IP Addresses
The command ifconfig –a shows network interface information, particularly the IP address. The output from ifconfig -a can be verbose, notably in the OS X version, so only a portion of the output is shown in the examples, below. After the examples, some of the other information is discussed.

Note that in most of these examples, more than one network interface is be present. Also, output from the loopback interface is shown. The command ifconfig -a will also give you the hardware address (also known as the MAC or Ethernet address). There is a separate hardware address for each interface. Solaris has a setting called local-mac-address that will force one hardware address to be shared by all interfaces (yes, this is understandably confusing for the network guys).

The address 127.0.0.1 is the loopback address associated with the loopback interface and is reserved for traffic staying within the host. This is often used to define the loghost. The logs are sometimes kept on one computer so that there is a centralized location for logs. In that case, the loghost entry in /etc/hosts will be for the computer where the logs are kept. Otherwise, loghost will be set to 127.0.0.1, which is the default setting.

paloalto [1]> grep log /etc/hosts
127.0.0.1       localhost loghost

Linux:
penguin [1]> ifconfig -a | more
eth0                Link encap:Ethernet  HWaddr 00:13:21:1B:0A:80  
                inet addr: 192.168.22.104  Bcast: 192.168.22.255  Mask:255.255.255.0

eth1                Link encap:Ethernet  HWaddr 00:13:21:1B:0A:7F  
                inet addr:192.168.23.104  Bcast:192.168.23.255  Mask:255.255.255.0

lo                Link encap:Local Loopback  
                inet addr:127.0.0.1  Mask:255.0.0.0

In this example, the Linux server known as penguin is also on the subnet 192.168.23.0. It is connected to this subnet on the secondary network interface eth1. Note that the hardware address is slightly different for the two interfaces. Linux interface names will vary with the type of interface. Ethernet interfaces are called eth0, eth1, et cetera while FDDI interfaces are called fddi0, fddi1, and so on.


Solaris:
paloalto [1]> ifconfig -a | more
lo0: flags=1000849 mtu 8232 index 1
                inet 127.0.0.1 netmask ff000000
hme0: flags=1000843 mtu 1500 index 2
                inet 192.168.22.103  netmask ffffff00 broadcast 192.168.22.255
                ether 8:0:20:ec:da:66
qfe0: flags=1000843 mtu 1500 index 3
                inet 192.168.23.103  netmask ffffff00 broadcast 192.168.23.255
                ether 8:0:20:ec:da:66

In this example, the Solaris server known as paloalto is also on the subnet 192.168.23.0. It is connected to this subnet on the secondary network interface qfe0. Note that the MAC/ether address is the same for both interfaces. This is based on the Solaris system setting local-mac-address? which can be changed by the SAs.
paloalto [1]> eeprom | grep -i mac
local-mac-address?=false

Note that ifconfig –a in Solaris will display the hardware address only if you’re logged in as root (administrator).

OS X:
cupertino [1]> ifconfig -a | more
output
lo0: flags=8049 mtu 16384
        inet 127.0.0.1 netmask 0xff000000
en0: flags=8863 mtu 1500
        inet 192.168.22.101 netmask 0xffffffc0 broadcast 192.168.22.127
        ether 00:14:51:05:db:b6
        media: autoselect (100baseTX ) status: active
en1: flags=8822 mtu 1500
        ether 00:11:24:a2:d9:48
        media: autoselect () status: inactive

The easiest way to get OS X  network information is with system_profiler. The first section of the system_profiler output gives you a hardware overview. Immediately after that is the network section. Note that system_profiler gives you information on Airport (wireless) as well as Ethernet connections.

cupertino [1]> system_profiler | more
Network:
Built-in Ethernet:
        Type: Ethernet
        Hardware: Ethernet
        BSD Device Name: en0
        Has IP Assigned: No
        IPv4:
                Configuration Method: DHCP
        IPv6:
                Configuration Method: Automatic
        Ethernet:
                MAC Address: 00:14:51:05:db:b6
                Media Options:
                Media Subtype: none
AirPort:
        Type: AirPort
        Hardware: AirPort
        BSD Device Name: en1
        Has IP Assigned: Yes
        IPv4 Addresses: 192.168.22.101
        IPv4:
                Addresses: 192.168.22.101
                Configuration Method: DHCP
                Interface Name: en1
                Router: 192.168.22.1
                Subnet Masks: 255.255.255.0
     IPv6:
                Configuration Method: Automatic
     Ethernet:
                MAC Address: 00:11:24:a2:d9:48
Routers: 192.168.22.1
Subnet Mask: 255.255.255.0

In this example, there is a built-in ethernet network interface, known as en0, and an AirPort (wireless) network interface, en1. The AirPort interface is in use and the configuration method is DHCP. This means that a server on the network assigns the IP address (the D in DHCP stands for Dynamic). IPv4 is short for Internet protocol version 4. This is the version of TCP/IP used at most companies. IPv6 is a newer version that will, among other things, give us more addresses to work with.

The output from system_profiler also gives you information on which network interface is in use. The laptop in this example has two network interfaces, one of which is AirPort (wireless networking) and the other is a standard interface, known as Built-in Ethernet.

AIX:
endicott[1]> ifconfig -a | more
en2: flags=5e080863,c0
,64BIT,CHECKSUM_OFFLOAD,PSEG,CHAIN>
        inet 192.168.22.102 netmask 0xffffff00 broadcast 192.168.22.255
        tcp_sendspace 131072 tcp_recvspace 65536
lo0: flags=e08084b
inet 127.0.0.1 netmask 0xff000000 broadcast 127.255.255.255

If you are using AIX, you can also use prtconf to find your computer’s address:

endicott[1]> prtconf | more
output
Network Information
        Host Name: endicott
        IP Address: 192.168.22.102
        Sub Netmask: 255.255.255.0
        Gateway192.168.22.1

Once you are somewhat familiar with the output from ifconfig -a, use grep to get just the information that you want. For example, to see the IP address, try:
ifconfig -a | grep -i inet

You may hear about other methods of determining the IP Address, but these are essentially checking the same configuration files that are read at startup. The ifconfig command gives you the actual address being used. This should be a moot difference, but UNIX systems administrators will sometimes change and test network configuration on the fly before updating the configuration files.

Suggestions for Future Learning
More information on network-related configuration files and how IP addresses are assigned is provided  in UNIX For Application Support Staff Chapter 4



Tutorial Contents



Name Service queries with DNS and NIS



What Is My Server’s Configuration ?

Hardware Information : CPU and Memory

Environmental Variables : Your Configuration


Disk Usage  and Listing Directory Contents

Who Else  is Logged in?


Name Service Queries
Routers
Name Service Queries
Routers