Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Sep 1998 14:23:57 +0300
From:      Ruslan Ermilov <ru@ucb.crimea.ua>
To:        Graham Wheeler <gram@cdsec.com>, hackers@FreeBSD.ORG
Subject:   Re: ifconfig alias weirdness
Message-ID:  <19980921142357.A1023@relay.ucb.crimea.ua>
In-Reply-To: <199809210953.LAA04029@cdsec.com>; from Graham Wheeler on Mon, Sep 21, 1998 at 11:53:49AM %2B0200
References:  <199809210953.LAA04029@cdsec.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi!

On Mon, Sep 21, 1998 at 11:53:49AM +0200, Graham Wheeler wrote:
> Hi all
> 
> On a different note to the hang/reboot, I've noticed the following which
> may be a bug, or perhaps I'm just missing something (or maybe I'm just
> being pedantic!).

Yes, you are missing the FAQ article "How can I setup Ethernet aliases".

> 
> If I want to set up an alias on an interface with a subnet, there are 
> two different behaviours I observe depending on whether or not the 
> netmask is specified with the alias.
> 
> If I use:
> 
>   ifconfig ed0 inet 196.37.78.96 netmask 255.255.255.240 up
>   ifconfig ed0 inet 196.37.78.99 alias
> 
> then the routes get messed up. After the first ifconfig the routes
> are correct:
> 
>   196.37.78.96/26	link#1
                 ^^
Are you sure it is equal 26? if you use 255.255.255.240, it should be 28.

> 
> But after the alias we have:
> 
>   196.37.78		link#1
>   196.37.78.96/26	link#1
> 
> which indicates that an implicit netmask of 255.255.255.0 has been used.

Yes, you're absolutely right.
This is a class C address, so the default netmask for it will be 255.255.255.0.
Imagine, if you'd have 2 different class C networks hosted on your machine:

	ifconfig ed0 inet 192.168.1.1 netmask 255.255.255.0
	ifconfig ed0 inet 192.168.2.1 netmask 255.255.255.0 alias

> On the other hand, if I use:
> 
>   ifconfig ed0 inet 196.37.78.99 netmask 255.255.255.240 alias
> 
> then the alias is right, and the bad route doesn't get added; however,
> ifconfig prints an error: `SIOCIFADDR: file exists'.

This is what your kernel should do, because when you issue ``ifconfig''
command, your kernel implicitly adjusts its routing table with "interface"
route, which is marked as "link#N" in the ``netstat -r'' output.
In your case, when you issue

	ifconfig ed0 inet 196.37.78.99 netmask 255.255.255.240 alias

this "interface" route will be 196.37.78.96/28, and it's already exists.

> 
> I can live with the error message, but it is a bit disturbing.
> 

In your specific case, when you want an alias from an already defined
subnet, you should specify netmask as 255.255.255.255:

ifconfig ed0 inet 196.37.78.99 netmask 255.255.255.255 alias

Best regards,
-- 
Ruslan Ermilov		Sysadmin and DBA of the
ru@ucb.crimea.ua	United Commercial Bank
+380.652.247.647	Simferopol, Ukraine

http://www.FreeBSD.org	The Power To Serve
http://www.oracle.com	Enabling The Information Age

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19980921142357.A1023>