Configuring Multiple IP Addresses on a single Network Interface Card (NIC)

Category: Software and Systems Engineering
Author: Sean O'Donnell
Thu, Feb. 20th, 2003 @ 2:20:22 (MST)

There are many logical and justifiable purposes for utilizing open source software on your current hardware resources, rather than buying expensive proprietary products to essentially provide with what you already have (but aren't utilizing). This is an endless decision process, and mostly subjective to your project, budget, and many other factors that I won't acknowledge, or disacknowledge, but you're here now, so you're obviously a DIY kinda guy/gal, and that is more fun, and often logical, if you ask me.

Virtual Network Adapters are most advantageous for development of Linux/Apache-based Web Applications on a local workstations/laptops (for example), and configuring multiple projects/web sites to specific virtual host addresses, in your local workspace or LAN staging area. There are also many other types of applications that require the use of 'virtual' network adapters, such as "Virtualization Software" (i.e. Xen, VMware, OpenVZ, etc.), or network appliances that utilize embedded linux kernel ip routing matrices, such as Firewalls, Routers, and Ethernet Switches.

To assign Multiple IP addresses to eth1, we would modify the Interface Configuration (ifconfig), as seen below...

#!/usr/bin/env bash 
# Assign the initial 'physical' address of the NIC
ifconfig eth1 netmask &
ifconfig eth1 up

# assign to eth1:1
ifconfig eth1:1 netmask &
ifconfig eth1:1 up

# assign to eth1:2
ifconfig eth1:2 netmask &
ifconfig eth1:2 up

# assign to eth1:3
ifconfig eth1:3 netmask &
ifconfig eth1:3 up

Now you will be able to access the same NIC from any of the following IP Addresses (Locally, within your own LAN)...


Copyleft (<) 1998-2019