Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 153107 - Support for IP aliasing in /etc/conf.d/net seems incomplete
Summary: Support for IP aliasing in /etc/conf.d/net seems incomplete
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-27 17:48 UTC by Kevin
Modified: 2006-10-29 02:46 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin 2006-10-27 17:48:34 UTC
emerge --info output is N/A for this bug.

/usr/src/linux-2.6.12-gentoo-r10/Documentation/networking/alias.txt reads in part:

"IP-aliases are additional IP-addresses/masks hooked up to a base 
interface by adding a colon and a string when running ifconfig. 
This string is usually numeric, but this is not a must."

I'd like to be able to start up and tear down IP aliases in a logical place in a startup script along with real interfaces.

It's clear that /etc/conf.d/net is the logical place, and it seems from the comments in that file:
# If you need more than one address, you can use something like this
# NOTE: ifconfig creates an aliased device for each extra IPv4 address
#       (eth0:1, eth0:2, etc)
that support for IP aliases is intended, but...

How would I have this script bring up IP aliases of the form:
eth0:asdf
eth0:hjkl
eth0:zxcv

rather than (or in addition to) those of the form:
eth0:0
eth0:1
eth0:2

Based on the example in that file, I don't think I can do this, but I think it should be possible (based on the kernel documentation above).

If I'm missing something I apologize in advance for the bug report.
Comment 1 Roy Marples (RETIRED) gentoo-dev 2006-10-27 18:06:08 UTC
Aliases. The bane of linux networking!

You do not need them - period. Instead you simply add addresses to an interface

config_eth0=( "192.168.0.1/24" "192.168.0.2/24" )

Like so. Using ifconfig you get a default alias of eth0:1. But this could be eth:itireallydoesnotmatter for all intents and purposes.
Using iproute2 (default if installed) you don't get an alias and using the command "ip addr show" you can see the extra address on  the interface.
Comment 2 Kevin 2006-10-28 05:11:34 UTC
I'm not sure I communicated my thoughts effectively before:

You say:
> Aliases. The bane of linux networking!

Why?  Seems like a terrific feature to me.  Do you know another way to do multiple virtual hosts with Apache, each with it's own unique SSL certificate whose CN will uniquely match it's actual hostname, all on one physical server (and better yet, all on one physical interface)?  I'd love to know know about it if so...

> You do not need them - period.

Don't need what?  Aliases?  How else would I do the above?

> Instead you simply add addresses to an interface

I saw how to get aliases using /etc/conf.d/net in that file's comment mentioned before.  What I didn't see was how to get them in some form other than the default of eth0:x where x is a number.  I know how to get them from the command line using ifconfig (both eth0:x and eth0:TextString).  I don't know how to have them automatically brought up at boot time using a startup script.  I'm sure I could do it in /etc/conf.d/local.start with ifconfig but then I don't get the nice functionality of /etc/init.d/net.eth0 start bringing up the IP aliases in the form that I'd like.  Yes, I realize that I don't need the alias to be a TextString, that it can be a number x, but I'd prefer a TextString.  If I can't do that using /etc/conf.d/net then that's ok... Just say so and I'll go away.  I just thought I'd ask because it would be nice and if it's supported by the kernel---shouldn't it also be supported by Gentoo startup scripts? (rhetorical)  I'm sure I can do it some other way but it makes sense to do it in /etc/conf.d/net to me.

> Using iproute2 (default if installed) you don't get an alias

Yes, I read that too.

> and using the command "ip addr show" you can see the extra address on
> the interface.

Is that an iproute2 command?  I'm unfamiliar with iproute2.  Perhaps I should start using it instead of ifconfig?  Is that what you're saying?  But again, I go back to the Apache virtual host scenario above.  Is that possible with iproute2?

Thanks.
Comment 3 Jakub Moc (RETIRED) gentoo-dev 2006-10-28 09:12:03 UTC
(In reply to comment #2)
> Why?  Seems like a terrific feature to me.  Do you know another way to do
> multiple virtual hosts with Apache, each with it's own unique SSL certificate
> whose CN will uniquely match it's actual hostname, all on one physical server
> (and better yet, all on one physical interface)?  I'd love to know know about
> it if so...

Of course. Please read some iproute2 docs; you don't need any aliases, you assign all the IP addresses to the one eth0 interface that actually exists (and anything can use them, like apache e.g.). You don't need any broken aliases for non-existant interfaces, it's been deprecated since kernel 2.2 at least.


> sure I could do it in /etc/conf.d/local.start with ifconfig but then I don't
> get the nice functionality of /etc/init.d/net.eth0 start bringing up the IP
> aliases in the form that I'd like. 

Why would do it? You can do that just fine without local.start...

> I can't do that using /etc/conf.d/net then that's ok... 

Sure you can...

config_eth0=(
        "192.168.0.113/28 brd 192.168.0.127"
        "192.168.0.114/28 brd 192.168.0.127"
        "192.168.0.115/28 brd 192.168.0.127"
        "192.168.0.116/28 brd 192.168.0.127"
        "192.168.0.117/28 brd 192.168.0.127"
        "192.168.0.118/28 brd 192.168.0.127"
        "192.168.0.119/28 brd 192.168.0.127"
        "192.168.0.120/28 brd 192.168.0.127"
        "192.168.0.121/28 brd 192.168.0.127"
        "192.168.0.122/28 brd 192.168.0.127"
        "192.168.0.123/28 brd 192.168.0.127"
        "192.168.0.124/28 brd 192.168.0.127"
        "192.168.0.125/28 brd 192.168.0.127"
)

# ip addr show

eth0: <BROADCAST,MULTICAST,UP,10000> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:50:8d:d7:8c:0d brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.113/28 brd 192.168.0.127 scope global eth0
    inet 192.168.0.114/28 brd 192.168.0.127 scope global secondary eth0
    inet 192.168.0.115/28 brd 192.168.0.127 scope global secondary eth0
    inet 192.168.0.116/28 brd 192.168.0.127 scope global secondary eth0
    inet 192.168.0.117/28 brd 192.168.0.127 scope global secondary eth0
    inet 192.168.0.118/28 brd 192.168.0.127 scope global secondary eth0
    inet 192.168.0.119/28 brd 192.168.0.127 scope global secondary eth0
    inet 192.168.0.120/28 brd 192.168.0.127 scope global secondary eth0
    inet 192.168.0.121/28 brd 192.168.0.127 scope global secondary eth0
    inet 192.168.0.122/28 brd 192.168.0.127 scope global secondary eth0
    inet 192.168.0.123/28 brd 192.168.0.127 scope global secondary eth0
    inet 192.168.0.124/28 brd 192.168.0.127 scope global secondary eth0
    inet 192.168.0.125/28 brd 192.168.0.127 scope global secondary eth0

$ /sbin/ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:50:8D:D7:8C:0D  
          inet addr:192.168.0.113  Bcast:192.168.0.127  Mask:255.255.255.240

See? ifconfig plain sucks... doesn't see any of those addresses; don't use it. :P

Comment 4 Roy Marples (RETIRED) gentoo-dev 2006-10-29 02:46:57 UTC
(In reply to comment #2)
> I'm not sure I communicated my thoughts effectively before:
> 
> You say:
> > Aliases. The bane of linux networking!
> 
> Why?  Seems like a terrific feature to me.  Do you know another way to do
> multiple virtual hosts with Apache, each with it's own unique SSL certificate
> whose CN will uniquely match it's actual hostname, all on one physical server
> (and better yet, all on one physical interface)?  I'd love to know know about
> it if so...

All aliases do is allow ifconfig to add multiple ip addresses to the same interface. iproute2 does not have this limitation and neither do ifconfig implementations on other OS's such as FreeBSD.