Set up Ethernet aliases in Linux
Takeaway: Learn to map multiple IP addresses to a single NIC by using IP aliasing.
Delivered each Tuesday, TechRepublic's free Linux NetNote provides tips, articles, and other resources to help you hone your Linux skills. Automatically sign up today!
When you set up a Linux system's network, you typically assign one IP address per network interface card (NIC). This serves as the primary address for the NIC. For example, a firewall may have one Ethernet interface (e.g., eth0) assigned an external ISP-supplied IP, whereas the other interface (e.g., eth1) would have a local IP used on the local LAN.
But in a situation that requires multiple IP addresses on a machine (all of which connect to the same network), you don't need one NIC per IP address. Linux is capable of mapping multiple IP addresses to a single NIC by using IP aliasing.
To set up an IP alias, execute the following:
# ifconfig eth0:0 192.168.5.12 netmask 255.255.255.0 up
This assigns the IP address 192.168.5.12 to eth0 as the first alias (noted as eth0:0) on eth0. If you look at the output of ifconfig, you'll see the distinct IP address for eth0 and another for eth0:0.
If you need to add another IP address, just run the same command as root, and increment the alias number. In this example, the next alias number would be eth0:1.
On Mandrakelinux, Red Hat, and similar systems, you can make aliases automatic by creating files in /etc/sysconfig/network-scripts/. In this directory, create a new file called ifcfg-eth0:0 that contains the following contents:
IPADDR="192.168.5.12"
NETMASK="255.255.255.0"
On systems that don't use these network scripts, just add the call to ifconfig directly in your startup script (usually /etc/rc.d/rc.local).
Print/View all Posts Comments on this article
|
|
|
|
|
|
|
|
|
|
White Papers, Webcasts, and Downloads
- Email Security and Archiving - Clearer in the Cloud Google The time is NOW for businesses and organizations of all sizes to implement ... Download Now
- Why Isn't Server Virtualization Saving Us More? A Few Small Changes May Dramatically Increase Your Efficiency VMware Ever wonder why your company isn't saving more from its server virtualization? Making a few small changes could dramatically increase your efficiency. Download Now
- Five Steps to Determine When to Virtualize YourServers VMware Thinking of virtualizing the servers at your company? Use this step-by-step guide to determine when's the best time to make your big move. Download Now
- Tom Davenport Study: Linking decisions and information for organizational performance IBM Tom Davenport's new client study looks at approaches to linking ... Download Now
- The Impact of Virtualization Software on Operating Environments VMware Today's use of virtualization technology allows IT professionals to ... Download Now
Article Categories
- Security
- Security Solutions, IT Locksmith
- Networking and Communications
- E-mail Administration NetNote, Cisco Routers and Switches
- CIO and IT Management
- Project Management, CIO Issues, Strategies that Scale
- Desktops, Laptops & OS
- Windows 2000 Professional, Microsoft Word, Microsoft Excel, Microsoft Access, Windows XP,
- Data Management
- Oracle, SQL Server
- Servers
- Windows NT, Linux NetNote, Windows Server 2003
- Career Development
- Geek Trivia
- Software/Web Development
- Web Development Zone, Visual Basic, .NET

