IceWalkers.com - Linux Software downloads and news
Name : Password :
Linux SoftwareLinux RPMLinux HowtosLink UsAboutAdvertise

HOWTOs

Search Howtos :Match :

2. Commands

  1. Load the IP Alias module (you can skip this step if you compiled the module into the kernel):

    /sbin/insmod /lib/modules/`uname -r`/ipv4/ip_alias.o
  2. Setup the loopback, eth0, and all the IP addresses beginning with the main IP address for the eth0 interface:

    /sbin/ifconfig lo 127.0.0.1
    /sbin/ifconfig eth0 up
    /sbin/ifconfig eth0 172.16.3.1
    /sbin/ifconfig eth0:0 172.16.3.10
    /sbin/ifconfig eth0:1 172.16.3.100

    172.16.3.1 is the main IP address, while .10 and .100 are the aliases. The magic is the eth0:x where x=0,1,2,...n for the different IP addresses. The main IP address does not need to be aliased.

  3. Setup the routes. First route the loopback, then the net, and finally, the various IP addresses starting with the default (originally allocated) one:

    /sbin/route add -net 127.0.0.0
    /sbin/route add -net 172.16.3.0 dev eth0
    /sbin/route add -host 172.16.3.1 dev eth0
    /sbin/route add -host 172.16.3.10 dev eth0:0
    /sbin/route add -host 172.16.3.100 dev eth0:1
    /sbin/route add default gw 172.16.3.200

    That's it.

In the example IP address above, I am using the Private IP addresses (RFC 1918) for illustrative purposes. Substitute them with your own official or private IP addresses.

The example shows only 3 IP addresses. The max is defined to be 256 in /usr/include/linux/net_alias.h. 256 IP addresses on ONE card is a lot :-)!

Here's what my /sbin/ifconfig looks like:

lo        Link encap:Local Loopback
	       inet addr:127.0.0.1  Bcast:127.255.255.255  Mask:255.0.0.0
			 UP BROADCAST LOOPBACK RUNNING  MTU:3584  Metric:1
		    RX packets:5088 errors:0 dropped:0 overruns:0
		    TX packets:5088 errors:0 dropped:0 overruns:0
		
eth0      Link encap:10Mbps Ethernet  HWaddr 00:8E:B8:83:19:20
		    inet addr:172.16.3.1  Bcast:172.16.3.255  Mask:255.255.255.0
		    UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1
		    RX packets:334036 errors:0 dropped:0 overruns:0
		    TX packets:11605 errors:0 dropped:0 overruns:0
		    Interrupt:7 Base address:0x378
		
eth0:0    Link encap:10Mbps Ethernet  HWaddr 00:8E:B8:83:19:20
		    inet addr:172.16.3.10  Bcast:172.16.3.255  Mask:255.255.255.0
		    UP BROADCAST RUNNING  MTU:1500  Metric:1
		    RX packets:0 errors:0 dropped:0 overruns:0
		    TX packets:0 errors:0 dropped:0 overruns:0
		
eth0:1    Link encap:10Mbps Ethernet  HWaddr 00:8E:B8:83:19:20
		    inet addr:172.16.3.100  Bcast:172.16.3.255  Mask:255.255.255.0
		    UP BROADCAST RUNNING  MTU:1500  Metric:1
		    RX packets:1 errors:0 dropped:0 overruns:0
		    TX packets:0 errors:0 dropped:0 overruns:0

And /proc/net/aliases:

device         family    address
eth0:0           2      172.16.3.10
eth0:1           2      172.16.3.100

And /proc/net/alias_types:

type    name            n_attach
2       ip              2

Of course, the stuff in /proc/net was created by the ifconfig command and not by hand!

Search Howtos :Match :
Safesquid proxy server 4.2.2.RC8.14B
Antivirus and content filtering proxy server
Thunderbird 2.0.0.18
An email and newsgroup client with powerful, new junk mail controls
JEdit 4.3pre16
Programmers text editor
Gdm 2.24.1
Reimplementation of the well known xdm program.
Damn Small Linux 4.4.10
Damn Small Linux, 50MB bootable Linux desktop LiveCD
PhpMyAdmin 3.1.0 rc1
Php front-end to MySQL administration
ImageMagick 6.4.5.8
ImageMagick image processing studio
KOffice 2.0 beta3
Integrated office suite for KDE
LimeWire 4.18.8
Gnutella Client
Trac 0.11.2.1
Integrates SCM, Wiki and Issue Tracker
Free IT Magazines, White Papers, eBooks, and more !
Oracle Magazine

Contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more.

eWeek

The essential technology information source for builders of e-business.

BusinessWeek (Digital Edition)

Provides readers a deeper understanding of the trends that drive growth, and what best practices keep them ahead of the competition.

Linux Software Map
Find Linux RPM
Best Rated Linux Software
Most Rated Linux Software
Linux Distributions
Linux Howtos
Quick Survey

Please take our survey and help us improve our website to serve you better.

Thank you.
Linux Software
Linux / IT Resources
Site Resources
Google
Privacy Policy
Contact Us
Submit Software
Advertising info