Tutorial on Figuring Out Your Server: Router/Gateway

IP Addresses
Server Config
This tutorial has examples for four versions of UNIX: Linux, Oracle’s Solaris, Apple’s Macintosh OS X and IBM’s AIX
Router/Gateway
All servers need fixed addresses so you know what address to connect to. In order for a computer with a fixed address to be on a network, it must be configured to communicate with a specific router. A router can only support a finite number of addresses within a finite area. Therefore, if you work with servers in several different data centers, gateway information will narrow down the location of your server. A network subnet (VLAN) is limited to one building, and more often, one floor or one data center in a building. So, a gateway/router can only be in a very limited number of places, such as a particular building or portion of a building such as a floor or data center.

The examples, above, also give you the router’s address. Note that the router is sometimes referred to as the gateway.

Routing information can be displayed with netstat –rn, including the default gateway/router. If you have network interfaces on two different subnets, netstat -rn or netstat - r will tell you which interface is used for which subnet. The n option shows address numbers rather than hostnames and network names, which most people will find easier to follow.

The flags mean the following:
•G: router uses a gateway
•U: interface is up
•H: only a single host can be reached (loopback interface will display H)
•D: dynamically created route

Gateway information is helpful when testing if a server is properly configured for the network. If you are logged in on a server’s console and you think there is a network issue, you will want to see if you can you ping the gateway/router. (Scroll down to end for information on finding more information on troubleshooting network issues).

Linux:
penguin [1]> netstat -rn | more
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.23.0    0.0.0.0         255.255.255.0   U         0 0          0 eth1
192.168.22.0    0.0.0.0         255.255.255.0   U         0 0          0 eth0
0.0.0.0         192.168.22.1    0.0.0.0         UG        0 0          0 eth0

In this example, the default router is 192.168.22.1 and is reached via the eth0 interface.

Solaris:
paloalto [1]> netstat -rn | more
Routing Table: IPv4
 Destination           Gateway           Flags  Ref   Use   Interface
-------------------- -------------------- ----- ----- ------ ---------
192.168.23.0        192.168.23.103         U        1   6250  qfe0
192.168.22.0        192.168.22.103         U        1   2942  hme0
default             192.168.22.1           UG       1  73523  
127.0.0.1            127.0.0.1             UH       5 100698  lo0

In this example, the default router is 192.168.22.1 and is reached via the hme0 interface. The address for that interface is 192.168.22.103 and is on the 192.168.22.0 network. The other interface is qfe0 and is on the 192.168.23.0 network. The address for the qfe0 interface is 192.168.23.103. Data for the 192.168.23.0 network will be routed through the qfe0 interface.

OS X:
cupertino [1]> netstat -rn | more
Routing tables
Internet:
Destination        Gateway            Flags    Refs      Use  Netif Expire
default            192.168.1.1        UGSc        5        8    en1
127.0.0.1          127.0.0.1          UH         10    33948    lo0

In this example, the default router is 192.168.1.1 and is reached via the en1 interface. The address 127.0.0.1 is the loopback address associated with the loopback interface lo0 and refers to the server.

AIX:
endicott[1]> netstat -rn
Routing tables
Destination      Gateway           Flags   Refs     Use  If   PMTU Exp Groups
Route Tree for Protocol Family 2 (Internet):
default          192.168.22.1     UG       26 188078097  en2     -   -      -  
127/8            127.0.0.1         U         7   641477  lo0     -   -      -  
192.168.22.0    192.168.22.102     UHSb      0        0  en2     -   -      -   =>
192.168.22/24   192.168.22.102     U         1 11545367  en2     -   -      -  
192.168.22.102    127.0.0.1         UGHS     0    22102  lo0     -   -      -  
192.168.22.255  192.168.22.102     UHSb      0        4  en2     -   -      -  

In this example, there is one network interface, which is en2. It is on the 192.168.22.0 network and the default router is 192.168.22.1

Suggestions for Future Learning
More information on interpreting output from netstat and ifconfig as well as networking in general is provided in UNIX For Application Support Staff Chapter 4



Tutorial Contents



Name Service queries with DNS and NIS

IP Addresses


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?


IP Addresses
Server Config