Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Apr 1996 13:10:51 +0200 (GMT)
From:      Robin Lunn <robin@is.co.za>
To:        Eric.Berenguier@sycomore.fr (Eric Berenguier)
Cc:        questions@freebsd.org
Subject:   Re: 2 differents IP on the same interface ?
Message-ID:  <199604251110.NAA18815@admin.is.co.za>
In-Reply-To: <v01530502ada4fe7e0f65@[192.134.92.34]> from "Eric Berenguier" at Apr 25, 96 12:12:46 pm

next in thread | previous in thread | raw e-mail | index | archive | help
Eric Berenguier wrote:
>         Is it possible to give several adresses to a single network
> interface on a FreeBSD system ?
>         (I know it's possible to do this with latest Linux kernel (IP_ALIAS))

I have no idea how this might be done with ppp or slip, but on ethernet the
following:

ifconfig <device> alias <ip alias>
route add <ip alias> 127.0.0.1

Lazy way to make this permanent: Add these commands to /etc/rc.local

More scalable way to permanency:
Add the following to /etc/sysconfig: (put them with like config options)
--
# network interface aliases
interface_aliases="ed1"
alias_ed1="alias x.x.x.x"
route_alias1="x.x.x.x 127.0.0.1"
--
Add the word alias1 to the static_routes= definition.
Add the following to /etc/netstart:
--
# Set up any aliases to network interfaces.
for device in ${interface_aliases}; do
        eval ifconfig_args=\$alias_${device}
        ifconfig ${device} ${ifconfig_args}
done
--
This way if you have more than one alias on an interface you just have:
alias_ed1="alias x.x.x.x alias y.y.y.y alias z.z.z.z"
route_alias1="x.x.x.x 127.0.0.1"
route_alias2="y.y.y.y 127.0.0.1"
route_alias3="z.z.z.z 127.0.0.1"
static_routes="multicast alias1 alias2 alias3 loopback"

All of your network config info is still in one file this way and you can
easily see the aliases assigned to an interface.
-- 
_ __                  | Only my ideas here unless I say otherwise...
' )  )     /          | (BeamJack@IRC)                 
 /--' ____/___o  __   | "Nondum amabam, et amare amabam...  quaerebam quid
/  \_(_) /_) (__/) )_ |  amarem, amans amare." - St Augustine



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