Alias Interfaces

As mentioned in Chapter 3, "Kernel Requirements for a Full-Featured Lab," alias interfaces provide a way to assign multiple IP addresses to one physical interface. These addresses can either be from the same network broadcast domain or a different address range. However, they do not provide Layer 2 separation as VLAN tagging does.

You will learn in Chapter 9, "Dynamic Routing Protocols?Interior Gateway Protocols," and Chapter 10, "ISP Connectivity with BGP4: An Exterior Gateway Path-Vector Routing Protocol for Interdomain Routing," how alias information can be transported via dynamic routing protocols and used for virtual servers, redundancy, and Dynamic Name Service (DNS) round-robin configurations. Examples 5-1, 5-2, and 5-3 show the configuration of alias/secondary interfaces on Linux, OpenBSD, and FreeBSD systems; the corresponding statistics; and their representation in the Address Resolution Protocol (ARP) and routing tables. Keep in mind that the "colon" notation (shaded text) of Linux interfaces in general is not exactly equivalent to Cisco IOS subinterfaces.

Example 5-1. Linux Alias Interface Example

[root@callisto:~#] ifconfig eth1:1 192.168.45.1



[root@callisto:~#] ifconfig eth0:0 192.168.14.14



[root@callisto:~#] ifconfig

eth0      Link encap:Ethernet  HWaddr 00:10:5A:D7:93:60

          inet addr:192.168.14.1  Bcast:192.168.14.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:1485 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:100

          RX bytes:0 (0.0 b)  TX bytes:122180 (119.3 Kb)

          Interrupt:5 Base address:0xd800



eth0:0    Link encap:Ethernet  HWaddr 00:10:5A:D7:93:60

          inet addr:192.168.14.14  Bcast:192.168.14.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          Interrupt:5 Base address:0xd800



eth1      Link encap:Ethernet  HWaddr 52:54:05:E3:51:87

          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:2604 errors:0 dropped:0 overruns:0 frame:0

          TX packets:3166 errors:0 dropped:0 overruns:0 carrier:0

          collisions:7 txqueuelen:100

          RX bytes:691838 (675.6 Kb)  TX bytes:307948 (300.7 Kb)

          Interrupt:9 Base address:0xd400



eth1:1    Link encap:Ethernet  HWaddr 52:54:05:E3:51:87

          inet addr:192.168.45.1  Bcast:192.168.45.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          Interrupt:9 Base address:0xd400



lo        Link encap:Local Loopback

          inet addr:127.0.0.1  Mask:255.0.0.0

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:489 errors:0 dropped:0 overruns:0 frame:0

          TX packets:489 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:54587 (53.3 Kb)  TX bytes:54587 (53.3 Kb)



[root@callisto:~#] arp -an

? (192.168.1.254) at 48:54:E8:8C:0A:3F [ether] on eth1

? (192.168.14.254) at 00:60:47:1E:AD:B5 [ether] on eth0

? (192.168.45.254) at 48:54:E8:8C:0A:3F [ether] on eth1



[root@callisto:~#] netstat -rn

Kernel IP routing table

Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface

192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth1

192.168.14.0    0.0.0.0         255.255.255.0   U         0 0          0 eth0

192.168.45.0    0.0.0.0         255.255.255.0   U         0 0          0 eth1

127.0.0.0       0.0.0.0         255.0.0.0       U         0 0          0 lo

0.0.0.0         192.168.1.254   0.0.0.0         UG        0 0          0 eth1



############################################################################

#     Alternative configuration via the Linux "ip" utility                 #

# Note that "ip" differentiates between "secondary" and "alias" addresses  #

############################################################################

[root@callisto:~#] ip address add 192.168.14.14/24 broadcast 255.255.255.0 label   eth0:0

graphics/ccc.gif dev eth0



[root@callisto:~#] ip address show eth0

2: eth0: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 100

    link/ether 00:10:5a:d7:93:60 brd ff:ff:ff:ff:ff:ff

    inet 192.168.14.1/24 brd 192.168.14.255 scope global eth0

    inet 192.168.14.14/24 brd 255.255.255.0 scope global secondary eth0:0



[root@callisto:~#] ip address add 192.168.45.1/24 broadcast 255.255.255.0 label   eth1:1

graphics/ccc.gif dev eth1



[root@callisto:~#] ip address show eth1

3: eth1: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 100

    link/ether 52:54:05:e3:51:87 brd ff:ff:ff:ff:ff:ff

    inet 192.168.1.1/24 brd 192.168.1.255 scope global eth1

    inet 192.168.45.1/24 brd 192.168.45.255 scope global eth1:1



[root@callisto:~#] ip route show

192.168.1.0/24 dev eth1  scope link

192.168.14.0/24 dev eth0  scope link

192.168.45.0/24 dev eth1  proto kernel  scope link  src 192.168.45.1

127.0.0.0/8 dev lo  scope link

default via 192.168.1.254 dev eth1


Example 5-2. OpenBSD Alias Interface Example

[root@ganymed:~#] ifconfig ne3 alias 192.168.45.254 netmask 255.255.255.0



[root@ganymed:~#] ifconfig -A

lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33224

        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x5

        inet6 ::1 prefixlen 128

        inet 127.0.0.1 netmask 0xff000000

lo1: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33224

        inet 192.168.44.1 netmask 0xffffff00

        inet6 fe80::1%lo1 prefixlen 64 scopeid 0x4

        inet6 ::1 prefixlen 128

ne3: flags=8b63<UP,BROADCAST,NOTRAILERS,RUNNING,PROMISC,ALLMULTI,SIMPLEX,MULTICAST>     

graphics/ccc.gif mtu 1500

        media: Ethernet manual

        inet 192.168.1.254 netmask 0xffffff00 broadcast 192.168.1.255

        inet6 fe80::4a54:e8ff:fe8c:a3f%ne3 prefixlen 64 scopeid 0x1

        inet 192.168.45.254 netmask 0xffffff00 broadcast 192.168.45.255

ne4: flags=8863<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST> mtu 1500

        media: Ethernet 10baseT full-duplex

        inet 192.168.2.254 netmask 0xffffff00 broadcast 192.168.2.255

        inet6 fe80::5054:5ff:fee3:e42f%ne4 prefixlen 64 scopeid 0x2

ne5: flags=8863<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST> mtu 1500

        media: Ethernet 10baseT full-duplex

        inet 111.11.117.206 netmask 0xffffff00 broadcast 111.11.117.255

        inet6 fe80::5054:5ff:fee3:5187%ne5 prefixlen 64 scopeid 0x3

ppp0: flags=8010<POINTOPOINT,MULTICAST> mtu 1500

ppp1: flags=8010<POINTOPOINT,MULTICAST> mtu 1500

tun0: flags=10<POINTOPOINT> mtu 3000

tun1: flags=10<POINTOPOINT> mtu 3000

enc0: flags=0<> mtu 1536

vlan0: flags=0<> mtu 1500

vlan1: flags=0<> mtu 1500

gre0: flags=8010<POINTOPOINT,MULTICAST> mtu 1450

gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280

gif1: flags=8010<POINTOPOINT,MULTICAST> mtu 1280

gif2: flags=8010<POINTOPOINT,MULTICAST> mtu 1280

gif3: flags=8010<POINTOPOINT,MULTICAST> mtu 1280

faith0: flags=8002<BROADCAST,MULTICAST> mtu 1500



[root@ganymed:~#] netstat -rn -f inet

Routing tables



Internet:

Destination        Gateway            Flags     Refs     Use    Mtu  Interface

default            111.11.117.1       UGS         1     3570   1500   ne5

127/8              127.0.0.1          UGRS        0        0  33224   lo0

127.0.0.1          127.0.0.1          UH          2       38  33224   lo0

192.168.1/24       link#1             UC          0        0   1500   ne3

192.168.1.1        52:54:5:e3:51:87   UHL         1     3387   1500   ne3

192.168.1.2        8:0:46:64:74:1b    UHL         1     3049   1500   ne3

192.168.2/24       link#2             UC          0        0   1500   ne4

192.168.2.7        0:10:5a:c4:2c:4    UHL         0     2150   1500   ne4

192.168.44.1       192.168.44.1       UH          0        0  33224   lo1

192.168.45/24      link#1             UC          0        0   1500   ne3

111.11.117/24      link#3             UC          0        0   1500   ne5

111.11.117.1       0:5:9a:5b:23:fc    UHL         1        0   1500   ne5

111.11.117.206     127.0.0.1          UGHS        0        0  33224   lo0


Example 5-3. FreeBSD Alias Interface Example

[root@castor:~#] ifconfig ed0 alias 192.168.7.77 netmask 255.255.255.255



[root@castor:~#] ifconfig

xl0: flags=8b43<UP,BROADCAST,RUNNING,PROMISC,ALLMULTI,SIMPLEX,MULTICAST> mtu 1500

        options=3<rxcsum,txcsum>

        inet 192.168.2.7 netmask 0xffffff00 broadcast 192.168.2.255

        inet6 fe80::210:5aff:fec4:2c04%xl0 prefixlen 64 scopeid 0x1

        ether 00:10:5a:c4:2c:04

        media: Ethernet autoselect (10baseT/UTP)

        status: active

ed0: flags=8a43<UP,BROADCAST,RUNNING,ALLMULTI,SIMPLEX,MULTICAST> mtu 1500

        inet 192.168.7.7 netmask 0xffffff00 broadcast 192.168.7.255

        inet6 fe80::5054:5ff:fee3:e488%ed0 prefixlen 64 scopeid 0x2

        inet 192.168.7.77 netmask 0xffffffff broadcast 192.168.7.77

        ether 52:54:05:e3:e4:88

lp0: flags=8810<POINTOPOINT,SIMPLEX,MULTICAST> mtu 1500

sl0: flags=c010<POINTOPOINT,LINK2,MULTICAST> mtu 552

sl1: flags=c010<POINTOPOINT,LINK2,MULTICAST> mtu 552

ds0: flags=8008<LOOPBACK,MULTICAST> mtu 65532

stf0: flags=0<> mtu 1280

faith0: flags=8002<BROADCAST,MULTICAST> mtu 1500

vlan0: flags=0<> mtu 1500

        ether 00:00:00:00:00:00

        vlan: 0 parent interface: <none>

vlan1: flags=0<> mtu 1500

        ether 00:00:00:00:00:00

        vlan: 0 parent interface: <none>

lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384

        inet6 ::1 prefixlen 128

        inet6 fe80::1%lo0 prefixlen 64 scopeid 0xb

        inet 127.0.0.1 netmask 0xff000000

ppp0: flags=8010<POINTOPOINT,MULTICAST> mtu 1500

ppp1: flags=8010<POINTOPOINT,MULTICAST> mtu 1500



[root@castor:~#] netstat -rn -f inet

Routing tables



Internet:

Destination        Gateway            Flags    Refs      Use  Netif Expire

default            192.168.2.254      UGSc        4     1836    xl0

127.0.0.1          127.0.0.1          UH          0        0    lo0

192.168.2          link#1             UC          1        0    xl0

192.168.2.254      52:54:05:e3:e4:2f  UHLW        4        0    xl0    592

192.168.7          link#2             UC          0        0    ed0

192.168.7.77/32    link#2             UC          0        0    ed0


NOTE

In contrast to "real" physical interfaces (and to BSD aliases), ifconfig down does not only shut down the interface, but entirely removes it; it cannot be brought up again with a mere ifconfig up, but has to be reassigned the IP address (thus created anew). This is true for several other pseudo-interfaces as well.


Example 5-4 demonstrates a secondary address assignment under Cisco IOS Software as emphasized via the shaded text. Note that Linux differentiates between a secondary address and an interface alias, as demonstrated with the ip tool in Example 5-1 (shaded text).

Example 5-4. Cisco IOS Secondary Interface Address Example

scar# show running-config

!

...

interface Ethernet1

 bandwidth 10000

 ip address 192.168.14.14 255.255.255.0 secondary

 ip address 192.168.14.254 255.255.255.0

 no ip proxy-arp

 media-type 10BaseT

!

...



scar# show ip route

Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP

       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP

       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2

       ia - IS-IS inter area, * - candidate default, U - per-user static route

       o - ODR, P - periodic downloaded static route



Gateway of last resort is 192.168.14.1 to network 0.0.0.0



C    192.168.14.0/24 is directly connected, Ethernet1

     10.0.0.0/32 is subnetted, 1 subnets

C       10.0.0.1 is directly connected, Loopback0

C    192.168.7.0/24 is directly connected, Ethernet0

S*   0.0.0.0/0 [1/0] via 192.168.14.1



scar# show arp

Protocol  Address          Age (min)  Hardware Addr   Type   Interface

Internet  192.168.14.1            0   0010.5ad7.9360  ARPA   Ethernet1

Internet  192.168.14.14           -   0060.471e.adb5  ARPA   Ethernet1

Internet  192.168.7.7            14   5254.05e3.e488  ARPA   Ethernet0

Internet  192.168.7.254           -   0060.471e.adb2  ARPA   Ethernet0

Internet  192.168.14.254          -   0060.471e.adb5  ARPA   Ethernet1