On CBSSports.com: Mike Tyson's daughter dies in accident

Set up Ethernet aliases in Linux

Tags: Network technology, NETWORKING, OPEN SOURCE, Vincent Danen, IP, IP address, Linux, network, Linux Tips Newsletter

  • Save
  • Print
  • Recommend
  • 18

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).

  • Save
  • Print
  • Recommend
  • 18

Print/View all Posts Comments on this article

WebMin alternative Roger | 03/03/05
frankly . . . apotheon | 03/03/05
I agree with Jaqui | 03/04/05
t'anks apotheon | 03/04/05
RE: Set up Ethernet aliases in Linux manuignatius | 11/24/08

What do you think?

White Papers, Webcasts, and Downloads

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

SmartPlanet

advertisement
Click Here