Professional Documents
Culture Documents
version 1
Gianluca Sironi
( save paper! use double-sided )
Table of Contents
1 Introduction........................................................................................................................................3
2 FDL (Free Documentation License)..................................................................................................4
3 Configure IP alias...............................................................................................................................5
4 UNIX: AIX..........................................................................................................................................6
5 UNIX: Solaris....................................................................................................................................10
6 UNIX: HP-UX...................................................................................................................................13
7 Linux..................................................................................................................................................15
8 Windows............................................................................................................................................19
9 References.........................................................................................................................................22
1 Introduction
Aim of this document is to show how to configure IP alias (logical interfaces) on various
Operating Systems.
In this document we deal mainly with UNIX Operating Systems (AIX, Solaris, HP-UX) and
Linux;.we give also information how to configure IP alias with Microsoft Windows.
The goal is to show which are the configuration files and the commands related to IP alia-
sing.
Some notes about the differences between the variuos UNIX flavours and Linux are shown.
3 Configure IP alias
“IP Aliasing” is the process and the procedure that let to add one (or more) logical interface,
each with its own IP address, to a physical interface.
Examples ar IP alias for web server Virtual Host (Apache, IIS, ...); it is necessary for HTTPS
Virtual Host.
Another example is to “bind” a logical interface (an IP alias) for J2EE Application Server
(Tomcat, WebSphere, …) or for other services (mail relay, name service, … ).
Our best practice is, whenever possible, to bind different TCP/UDP services on different IP
addresses and to configure acl and rules at layer 3.
For IP alias we user private IP addressing and the reference is RFC 1918 “Address
Allocation for Private Internets”.
In this document we show commands and procedure for UNIX (AIX, Solaris, HP-UX), Linux
and Windows.
4 UNIX: AIX
#ifconfig -a
en0: flags=4e080863<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,PSEG>
inet 172.18.76.1 netmask 0xfffff800 broadcast 172.18.79.255
lo0: flags=e08084b<UP,BROADCAST,LOOPBACK,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT>
inet 127.0.0.1 netmask 0xff000000 broadcast 127.255.255.255
inet6 ::1/0
#
To configure an IP alias we use SMIT (SMITTY with a terminal); for example “smitty” with
the shortcut for IP configuration:
#smitty tcpip
We get :
TCP/IP
Further Configuration
Hostname
Static Routes
Network Interfaces
Name Resolution
Client Network Services
Server Network Services
Manage Print Server
Select BSD style rc Configuration
Start Configured TCPIP Daemons
Stop TCPIP Daemons
Authentication Configuration
Network Interfaces
Configure Aliases
Next screen :
[Entry Fields]
Network INTERFACE en0
We insert an IP address and the relative subnet mask; in our example 172.18.76.5 and
255.255.248.0
At the end of configuration commands we get the status (“OK” if everything is ok)
COMMAND STATUS
en0 changed
we can exit from “smitty” and we can check the new IP configuration (IP alias) with
ifconfig and the switch “-a”
#ifconfig -a
en0: flags=4e080863<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,PSEG>
inet 172.18.76.1 netmask 0xfffff800 broadcast 172.18.79.255
inet 172.18.76.5 netmask 0xfffff800 broadcast 172.18.79.255
lo0: flags=e08084b<UP,BROADCAST,LOOPBACK,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT>
inet 127.0.0.1 netmask 0xff000000 broadcast 127.255.255.255
inet6 ::1/0
#
/etc/hosts file has to be edited with the correct entries for the IP aliases.
It is possible also to use ifconfig command with the switch “alias”, but it is better
to use “smitty tcpip” to check and verify configuration and interfaces (physical and logical).
5 UNIX: Solaris
#ifconfig -a
lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
hme0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet 192.168.28.28 netmask ffffff00 broadcast 192.168.28.255
ether 8:0:20:b3:41:13
To configure a new logical interface (to the physical interface hme0), as first step we have to
“plumb” the new interface (hme0:1)
With the ifconfig command we configure IP address (associated to this new logical
interface hme0:1), and netmask and broadcast:
#ifconfig hme0:1 up
These three steps (plumb, IP configuration, interface activation), can also be performed
with a single command:
#ifconfig -a
lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
hme0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet 192.168.28.28 netmask ffffff00 broadcast 192.168.28.255
ether 8:0:20:b3:41:13
hme0:1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet 192.168.28.29 netmask ffffff00 broadcast 192.168.28.255
Note: it is not possibile to use the logical interface “hme0:0” which is considered the same
as hme0.
Solaris permits to use the switch “addif” to the command ifconfig, which makes an “implicit
plumb” and assing to the logical interface the next lower available “number”:
#ifconfig -a
lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
hme0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet 192.168.28.28 netmask ffffff00 broadcast 192.168.28.255
ether 8:0:20:b3:41:13
hme0:1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet 192.168.28.29 netmask ffffff00 broadcast 192.168.28.255
hme0:2: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet 192.168.28.30 netmask ffffff00 broadcast 192.168.28.255
Note: when not specified, netmask and broadcast are taken “classful” /24 (for
192.168.x.y) , /16 e /8 etc ...; in our example we could use :
/etc/hosts file (hard link to file /etc/inet/hosts) has to be edited with the correct entries
for the IP aliases.
/etc/hostname.<interface> files have to be created and configurated (in our example files
/etc/hostname.hme0:1 e /etc/hostname.hme0:2).
6 UNIX: HP-UX
Logical configuration in HP-UX is similar to Sun Solaris, with some differences shown af-
ter.
In HP-UX it does not exist the switch “–a” for ifconfig command; so to check IP configura-
tion we use lanscan command
#lanscan
Hardware Station Crd Hdw Net-Interface NM MAC HP-DLPI DLPI
Path Address In# State NamePPA ID Type Support Mjr#
0/0/0/0 0x000F201DCD7D 0 UP lan0 snap0 1 ETHER Yes 119
0/8/0/0 0x00306EEAB4B5 1 UP lan1 snap1 2 ETHER Yes 119
0/9/0/0 0x00306EEAF49C 2 UP lan2 snap2 3 ETHER Yes 119
#
Known the interfaces (physical and eventually logical), all the information about an
interface can be obtained with the ifconfig <interface> command :
#ifconfig lan1
lan1: flags=843<UP,BROADCAST,RUNNING,MULTICAST>
inet 192.168.9.3 netmask ffffff00 broadcast 192.168.9.255
#
#ifconfig lan2
lan2: flags=842<BROADCAST,RUNNING,MULTICAST>
inet 0.0.0.0 netmask 0
#
Nell’esempio sopra riportato l’interfaccia lan2 non ha una configurazione IP
INTERFACE_NAME[0]=lan0
IP_ADDRESS[0]=192.168.5.8
SUBNET_MASK[0]=255.255.255.0
BROADCAST_ADDRESS[0]=192.168.5.255
INTERFACE_STATE[0]=up
DHCP_ENABLE[0]=0
INTERFACE_NAME[1]=lan1
IP_ADDRESS[1]=192.168.9.3
SUBNET_MASK[1]=255.255.255.0
BROADCAST_ADDRESS[1]=192.168.9.255
INTERFACE_STATE[1]=up
INTERFACE_NAME[2]="lan2"
IP_ADDRESS[2]=""
SUBNET_MASK[2]=""
INTERFACE_NAME[3]="lan1:1"
IP_ADDRESS[3]=192.168.9.5
SUBNET_MASK[3]=255.255.255.0
BROADCAST_ADDRESS[3]=192.168.9.255
INTERFACE_STATE[3]=up
DHCP_ENABLE[3]=0
#ifconfig lan1:1 up
IP configuration can be checked with lanscan command, and the specific IP configuration
for this new logical interface can be checked with the ifconfig command:
#ifconfig lan1:1
/etc/hosts file has to be edited with the correct entries for the IP aliases.
7 Linux
With Linux (RedHat e derivates distribution like Fedora Core, CentOS, …) configuration
files and commands are in /etc/sysconfig/network-scripts/ folder
Logical interfaces, as in Solarsi, are indicated with <interface>:n (for example eth0:1).
Different from Solaris, with Linux it is possibile to configure a logical interface “:0”
(eth0:n con n=0,1,2,...); but we prefer, as in Solaris and HP-UX, to use “1” as first logical
interface.
# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:30:6E:11:62:D1
inet addr:192.168.206.241 Bcast:192.168.206.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:711872730 errors:0 dropped:0 overruns:0 frame:0
TX packets:777208669 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:3334306770 (3179.8 Mb) TX bytes:3592472187 (3426.0 Mb)
Interrupt:11 Base address:0xf000
The content of the configuration files (eth0 physical, eth0:1 logical) are shown :
# more ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.206.241
NETMASK=255.255.255.0
TYPE=Ethernet
USERCTL=no
NETWORK=192.168.206.0
BROADCAST=192.168.206.255
PEERDNS=no
#
#
# more ifcfg-eth0:1
DEVICE=eth0:1
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.206.242
NETMASK=255.255.255.0
TYPE=Ethernet
USERCTL=no
BROADCAST=192.168.206.255
#
To configure a new logical interface (for example eth0:2) ifcfg-eth0:2 file has to be created
and configured.
It is possibile (and it is an easy way) to copy the file ifcfg-eth0:1 and to modify only some
parameters (device name, IP address, ...)
DEVICE=eth0:2
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.206.243
NETMASK=255.255.255.0
TYPE=Ethernet
USERCTL=no
BROADCAST=192.168.206.255
This new logical interface “eht0:2” has to be activated with ifup command (which is a
symbolic link to /etc/sbin/ifup command )
# ifup eth0:2
# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:30:6E:11:62:D1
inet addr:192.168.206.241 Bcast:192.168.206.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:711872730 errors:0 dropped:0 overruns:0 frame:0
TX packets:777208669 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:3334306770 (3179.8 Mb) TX bytes:3592472187 (3426.0 Mb)
Interrupt:11 Base address:0xf000
/etc/hosts file has to be edited with the correct entries for the IP aliases.
Note: it is possibile to configure a new logical interface (for example eth0:2) with the follo-
wing command :
but with this way the configuration file ifcfg-eth0:2 is not created and with a shutdown of
the server, at the next restart the IP alias configuration is lost.
8 Windows
With Microsoft Windows there are several differences, starting from the commands to
check IP configuration (“ipconfig” instead of “ifconfig” as in UNIX and Linux).
Insert IP address and Subnet mask (in our example 192.168.197.159 and 255.255.255.0)
9 References