HP-UX Network Configuration
                        in a Nutshell

Interface Names
---------------
An interface name is the name used to refer to a network adapter.  On HP-UX,
this is typically "lan" followed by a number.  For example, "lan0".  The number
in the name is the physical point of attachment, or PPA.

The loopback interface is named "lo0", but there is no network adapter
associated with this interface.


Listing Network Adapters
------------------------
A network adapter is the card where a network cable connects to the computer.
The lanscan(1m) command can be used to list the network adapters installed in
the current system.  This command will print one line for each network adapter
that is present.

The sample output below shows there are four network adapters in this system.
The fifth column shows that their names are lan0, lan1, lan2, and lan3.

    $ lanscan
    Hardware Station        Crd Hdw   Net-Interface  NM  MAC       HP-DLPI DLPI
    Path     Address        In# State NamePPA        ID  Type      Support Mjr#
    0/0/3/0  0x00306E39C6A5 0   UP    lan0 snap0     1   ETHER     Yes     119
    0/1/2/0  0x00306E3946EA 1   UP    lan1 snap1     2   ETHER     Yes     119
    0/2/1/0  0x00306E37C782 2   UP    lan2 snap2     3   ETHER     Yes     119
    0/4/1/0  0x00306E3911C8 3   UP    lan3 snap3     4   ETHER     Yes     119

You can also use the ioscan(1m) command to list the network adapters as shown
below.  The descriptions in this output (last column) have been truncated so it
will fit on the page.

    $ ioscan -funC lan
    Class     I  H/W Path  Driver  S/W State   H/W Type     Description
    ====================================================================
    lan       0  0/0/3/0   intl100 CLAIMED     INTERFACE    Intel PCI Pro 10/10
    lan       1  0/1/2/0   igelan  CLAIMED     INTERFACE    HP PCI 1000Base-T C
    lan       2  0/2/1/0   btlan   CLAIMED     INTERFACE    HP A5230A/B5509BA P
    lan       3  0/4/1/0   igelan  CLAIMED     INTERFACE    HP A6825-60101 PCI


Configuring an Interface
------------------------
Configuring an interface means making the necessary entries in the system files
so that a network adapter can be used to communicate on the network.  To
configure a network interface, edit the following entries in the file
/etc/rc.config.d/netconf.

   INTERFACE_NAME[0]="lan0"
   IP_ADDRESS[0]="15.8.122.172"
   SUBNET_MASK[0]="255.255.255.0"
   BROADCAST_ADDRESS[0]="15.8.122.255"
   INTERFACE_STATE[0]="up"
   DHCP_ENABLE[0]=0

In the example above, the array index is set to 0.  For additional interfaces,
set the same variables with the appropriate values, but increment the array
index.

For these changes to take affect, the system must be rebooted.

To change the network configuration without rebooting the system, use the
ifconfig(1m) command.  However, changes made using the ifconfig(1m) command
will go away the next time the system is rebooted.

   $ ifconfig lan0 15.8.122.172 netmask 255.255.255.0 \
      broadcast 15.8.122.255 up


Show Interface Configuration
----------------------------
The netstat(1) command can be used to list the current network configurations.

   $ netstat -in
   Name   Mtu  Network     Address       Ipkts   Ierrs Opkts   Oerrs Coll
   lan0   1500 15.8.122.0  15.8.122.172  392890  0     402802  0     0  
   lo0   16424 127.0.0.0   127.0.0.1     11      0     11      0     0  

The configuration of a specific interface can be listed using the ifconfig(1m)
command.

   $ ifconfig lan0
   lan0: flags=843<UP,BROADCAST,RUNNING,MULTICAST>
      inet 15.8.122.172 netmask ffffff00 broadcast 15.8.122.255


Routing Tables
--------------
The netstat(1) command can be used to list the current network routing
information.

   $ netstat -rn
   Routing tables
   Destination      Gateway            Flags Refs       Interface  Pmtu
   127.0.0.1        127.0.0.1          UH    0          lo0       16424
   15.8.122.172     15.8.122.172       UH    0          lan0      16424
   15.8.122.0       15.8.122.172       U     2          lan0       1500
   127.0.0.0        127.0.0.1          U     0          lo0           0
   default          15.8.122.1         UG    0          lan0          0


Translating Host Name to IP Address
-----------------------------------
The nslookup(1m) command can be used to lookup an IP address given a host name
or vice-versa.  Depending on the "hosts" entry in the /etc/nsswitch.conf file,
the nslookup command will return different results.

   $ nslookup hpnfs172
   Default NIS Server:  hpnfs172
   Address:  15.8.122.172
   Aliases:  hpnfs172.cup.hp.com

   Trying NIS
   Name:    hpnfs172
   Address:  15.8.122.172
   Aliases:  hpnfs172.cup.hp.com


Translating IP Address to MAC Address
-------------------------------------
The arp(1m) command will show the MAC address that is being used for an IP
address.

   $ arp 15.8.122.172
   hpnfs172 (15.8.122.172) at 0:30:6e:39:c6:a5 ether permanent published

To find the MAC address for a local network adapter, you can also use the
lanscan(1m) command.


Deleting an Address
-------------------
To delete an interface, assign it IP address 0.

   $ ifconfig lan0 0


Miscellaneous
-------------
You can ping the entire network with the following command to see if an IP
address is already in use by another system.  All live systems will respond.

   $ ping 255.255.255.255

The netstat(1) command can return statistics about network activity.

   $  netstat -sv

The lanadmin(1m) can be used to examine and modify the LAN.

The ndd(1m) command can be used to modify network related kernel variables.

   $ ndd -h supported



                   Introduction to IPv6
                 --------------------

IP Addresses Notation
---------------------
An IPv4 address is a 32-bit value.  It is usually written as four decimal
numbers separated by periods (".")  Each number represents one byte of the IP
address, so each number can have a value from 0 to 255.  For example,

   127.0.0.1

An IPv6 address is a 128-bit value.  It is usually written as eight 16-bit
fields separated by colons (":").  Each field is written as a hexadecimal
number, so each field can be up to four digits, and leading zeros are optional.
For example,

   0:0:0:0:0:0:0:1

Consecutive fields of 0 can be replaced by ::, but only once.  For example,
the address above could be written as:

   ::1


Netmasks
--------
IP addresses are divided into two parts: the network part and the host part.
The network part is used to identify the network, and the host part is used to
identify the host within that network.

The dividing point can vary, but the bits on the left, or most significant
bits, are the network part, and the bits on the right are the host part.

In IPv4, the separation of the network part and host part of an IP address is
done with a netmask.  A netmask is a 32-bit value with each bit in the network
part set to one (1) and each bit in the host part set to zero (0).  The network
part and the host part cannot be interleaved.  For example, 255.255.255.0 is a
netmask that defines the leftmost 24 bits of an IPv4 address as the network
part and the rightmost 8 bits as the host part.

In IPv6, the number of bits in the network part of the IP address is appended
to the IP address as a decimal value following a slash (/).  For example,

   fe80::/10

In IPv6, this notation is used as a general notation for the length of the
prefix (left most bits), which is not always a reference to the network part of
the address.  For example, multicast addresses are defined by a fixed pattern
in the first 8 bits of an IPv6 address.  The example below shows how this is
written in IPv6 notation.

   ff00::/8


IPv6 Address Assignment
-----------------------
In IPv6, addresses are divided so that the network part of the address is the
first 64 bits and the host part is the last 64 bits.  The network part is
further divided so that the most significant 48 bits are used to identify a
site and the remaining 16 bits are used for subnetting.

The host part of an IPv6 address is usually generated automatically based on
the MAC address of the network adapter being used.  This means it is not
necessary for a system administrator to assign IP addresses to systems or
configure network interfaces when using IPv6; this happens automatically.

A MAC address is 48 bits.  When an IPv6 address is generated from a MAC
address, the hexadecimal number 0xfffe is inserted in the middle of the MAC
address to form the 64-bit host part of the IPv6 address.  For example,

   MAC Address    0x00306e39c6a5
   IPv6 Address   0x00306efffe39c6a5
                  ^^^^
When converted to IPv6 notation, the host part of the automatically generated
IPv6 address would be:

   ::30:6eff:fe39:c6a5

This value can be combined with a valid network prefix to form a valid IPv6
address.  There is a predefined link-local network prefix (discussed in
"Reserved IPv6 Addresses") that can be used with the address above to form a
link-local address, that is, an address that is only valid on the local subnet.

If there is no router on the local subnet, then the automatic configuration of
IPv6 can only create a link-local address.  However, if there is a router, it
will be contacted (using the link-local address) to get the network prefix of
the local subnet.  Then, this network prefix is combined with the host part of
the address to form globally unique IPv6 address (that is, an IPv6 address that
is valid everywhere).

In this way, IPv6 can automatically generate globally unique addresses for
every network adapter.  With IPv6, it is no longer necessary for the system
administrator to configure network interfaces.

Although not common, it is possible that the host part of the IPv6 address
based on a MAC address is not unique.  Therefore, an IPv6 address that is
generated automatically is tested by sending a message to it.  If a reply is
received, the address is not unique and an offset is added to the address, and
it is tried again.


Reserved IPv4 Addresses
-----------------------
The IPv4 loopback address is 127.0.0.1.

When the host part of an IPv4 address is all zeros, that IP address is the
address of the network, or "network address".  This address should not be
assigned to any host.  For example,

   IP Address     15.8.122.0
   Netmask        255.255.255.0

When the host part of an IPv4 address is all ones, that IP address is the
broadcast address for that network.  This address should not be assigned to any
host.  For example,

   IP Address     15.8.122.255
   Netmask        255.255.255.0

The first working address in an IPv4 network is typically assigned to the
router, but this is a convention, not a rule.  The first working address has
the host part equal to one (1).  For example,

   IP Address     15.8.122.1
   Netmask        255.255.255.0


Reserved IPv6 Addresses
-----------------------
There are several types of IPv6 addresses, which can be identified by the most
significant bits of the address.  (A unicast address is one that refers to a
specific interface; a multicast address may refer to more than one interface.)

   ::/128         Unspecified address (all zeros)
   ::1/128        Loopback
   ff00::/8 Multicast
   fe80::/10      Link-local, unicast
   fec0::/10      Site-local, unicast
   2000::/3 Global, unicast
   Other          Global, unicast, Currently not being used

The IPv6 loopback address is 0:0:0:0:0:0:0:1, or ::1.

In IPv6, broadcast addresses are called multicast addresses.  Some of the more
common multicast addresses are shown below.

   ff01::1        All nodes in the current interface (loopback).
   ff01::2        All routers in the current interface (loopback).

   ff02::1        All nodes in the current subnet (link-local).
   ff02::2        All routers in the current subnet (link-local).

   ff05::2        All routers in the current site.

The network prefix fe80::/10 identifies the current subnet (link-local).  For
example, when combined with the host part of the IPv6 address described in the
section "IPv6 Address Assignment", it can be used to access that host from
anywhere in the current subnet.  For example,

   fe80::30:6eff:fe39:c6a5

The network prefix fec0::/10 identifies a site-local network.  This is similar
to the 10.0.0.0/8 network in IPv4.  This network is typically not needed and
not used in IPv6.


Using IPv4 Addresses in an IPv6 Network
---------------------------------------
An IPv4 address can be expressed in IPv6 format.  When this is done, the most
significant 96 bits (leftmost) are all set to zero (0) and the remaining 32
bits are set to the IPv4 address.  To avoid the confusion of converting the
IPv4 address to IPv6 representation, the least significant 32 bits are
expressed in IPv4 format.  For example, the following IPv6 address is the IPv4
address 15.8.122.172 written in IPv6 format.

   0:0:0:0:0:0:15.8.122.172

which can also be written as:

   ::15.8.122.172


IPv6 Address to Name Resolution
-------------------------------
Depending upon the type of the host operating system, name to IPv6 address
mappings may be in the /etc/hosts file together with the name to IPv4 address
mappings.  Or, a separate file named /etc/inet/ipnodes may be used for the IPv6
entries.

   HP-UX          /etc/hosts
   Solaris        /etc/inet/ipnodes
   Linux          /etc/hosts

The network switch file, /etc/nsswitch.conf, has a new entry for ipnodes.  The
"ipnodes" entry specifies what method is used to resolve IPv4 and IPv6
addresses and host names.  This entry is used by the following functions:

   getnameinfo(3n)
   getaddrinfo(3n)
   getipnodebyname(3n)
   getipnodebyaddr(3n)

The "hosts" entry in /etc/nsswitch.conf continues to be used by the following
functions, which do not support IPv6 addresses.

   gethostbyname(3n)
   gethostbyaddr(3n)


Configuring an IPv6 Interface
-----------------------------
The file /etc/rc.config.d/netconf-ipv6 is used on HP-UX to configure IPv6
interfaces.  This file is analogous to /etc/rc.config.d/netconf for IPv4
interfaces.

IPv6 is included in HP-UX 11.31 and future releases of HP-UX. From HP-UX 11.11
to 11.23, IPv6 was available by installing a patch.

To configure an IPv6 interface, edit the following entries in the file
/etc/rc.config.d/netconf-ipv6.

   IPV6_INTERFACE[0]="lan0"
   IPV6_INTERFACE_STATE[0]="up"

For these changes to take affect, the system must be rebooted.

One interface can be used for both IPv4 and IPv6.  The output of the netstat(1)
command below shows both an IPv4 address and an IPv6 address assigned to the
interface lan0.

   $ netstat -in
   IPv4:
   Name   Mtu  Network     Address       Ipkts   Ierrs Opkts   Oerrs Coll
   lan0   1500 15.8.122.0  15.8.122.172  629892  0     590701  0     0  
   lo0   16424 127.0.0.0   127.0.0.1     17      0     17      0     0  

   IPv6:
   Name    Mtu Address/Prefix                    Ipkts Opkts
   lan0   1500 fe80::230:6eff:fe39:c6a5/10       7     16                
   lo0   16424 ::1/128                           1311  1311              

It is possible to configure an IPv6 network interface using the ifconfig(1m)
command just as with IPv4.  In fact, with IPv6, it is even easier because an
interface does not need to be configured before it is marked as "up".  If it is
not yet configured, the system will automatically configure the interface for
you.  As with IPv4, changes made using the ifconfig(1m) command will go away
the next time the system is rebooted.

   $ ifconfig lan0 inet6 up

It is not necessary to use the automatically generated IP address.  You can
also assign any other value as the host part of an IPv6 address if that value
is not being used anywhere else.  For example,

   $ ifconfig lan0 inet6 fe80::1 up

The /etc/hosts file on HP-UX contains entries for both IPv4 and IPv6 IP address
mappings.

The /etc/nsswitch.conf file on HP-UX contains entries for ipnodes.  This cannot
be set to NIS or NIS+.


Deleting an IPv6 Address
------------------------
To delete an IPv6 primary interface, assign it "unplumb".

   $ ifconfig lan0 inet6 unplumb

To delete an IPv6 secondary interface, assign it IP address 0, that is, "::".

   $ ifconfig lan0:1 inet6 ::