virtual domains:
compiled by Rich Gircys - other credits within.
bsdusers,
thanks to all that sent me replies - i rec'd more than i thought and some quite detailed.
in fact people are using a number of different methods - this is a summary that i hope will make it's way into the FAQ - useful stuff.
my note: after doing ifconfig, sometimes you'll get -
ifconfig: ioctl (SIOCAIFADDR): File exists
as a number of people pointed out - this is really more of a warning and alias will end up working.
from what i see, there are 4 major methods people are using:
alias the loopback interface use 0 netmask alias the ip and add route straight alias
of these, i could not get the last method to work. the method i decided to use is 'alias the ip and add route' - seems very clean.
here's the 4 methods with credits - all make valid points and comments in general - hope this is a useful tidbit for people to squirrel away.
rich
----------------------------------------------------------------------------alias the loopback interface
From: Jeffrey C Honig
The method I prefer to get a system to respond to multiple addresses (on an existing subnet) is to add the aliases to the loopback interface and then add ``published'' ARP cache entries for them. One main reason for this is that it won't confuse gated into thinking that it needs to send updates on several logical interfaces.
On 1.1 I do this with the following code inserted into /etc/netstart after the loopback interface is configured:
# Configure our alternate addresses ef1_ether=`netstat -ian | awk '/ef1/ && /Link/ { print $4 }'` for addr in xx.yy.zz.64 xx.yy.zz..65; do ifconfig lo0 inet ${addr} netmask 255.255.255.255 alias arp -s ${addr} ${ef1_ether} pub done
Note that you have to select the Ethernet interface (ef1 in this case) and you need to duplicate this code to match up each Ethernet interface on which you want to add aliases (i.e. interface ef1 is primarily configured with xx.yy.zz.63/255.255.255.0 in this example case).
Under 2.0 it's very similar, but if you are only doing it on one (or only the primary) Ethernet interface you can take advantage of some of the script variables:
# Add aliases ether=`netstat -ian | awk "/^${iface} / && // { print \\\$4 }"` if [ ! -z "${ether}" ]; then for addr in xx.yy.zz.138; do ifconfig lo0 inet ${addr} netmask 255.255.255.255 alias arp -s ${addr} ${ether} pub done fi
Jeff --------------------------------------------------------------------------
use 0 netmask
From: Jim Hribnak
It works I have 5 aliases setup on our ef0 (3com card) IE
my main ifconfig is as follows:
ifconfig ef0 199.45.65.1 net 0 link1
my aliases are:
ifconfig ef0 199.45.65.?? # FTP
ifconfig ef0 199.45.65.?? # gopher
ifconfig ef0 199.45.65.?? # WWW (Apache)
works like a charm
Jim Hribnak | Manager Communication Services | Nucleus Information Service
alias the ip and add route
From: Vivek Khera
It works just fine under 2.0. Are you using 2.0 or 1.1?
Anyhow, here's my /etc/netstart snippet of where I alias a couple of IP
addresses on one of my webserver machines. I use it to run multiple domains
on a single host, each with a private http server:
--cut here--
# other WWW servers housed here.
ifconfig ne0 inet www.govcon.com alias
route add www.govcon.com localhost
ifconfig ne0 inet www.prizes.com alias
route add www.prizes.com localhost
ifconfig ne0 inet www.prizelink.com alias
route add www.prizelink.com localhost
--cut here--
everything works fine with just that. Try pinging them, visiting them via
Mosaic, whatever. They are all on the host lorax.kciLink.com using the
above aliases.
-----------------------------------------------------------------------------
straight alias
From: Michael Galassi
-michael
written by Rich Gircys
so on kitty you see lame delegation messages - to see what's up, do the
follwoing:
1. force name resolution - generate the lame message on the server - do ping
on kitty, a machine who with slave/forwarded dns to ns2
> ping oram.com
2. ns2 now reports in var/log/messages
Aug 3 22:44:04 ns2 named[39]: Lame delegation to 'ORAM.com' from
[137.82.1.1].53 (server for 'oram.com'?) on query on name 'oram.com'
3. kitty gets
ping: unknown host oram.com
4. now do whois on oram.com
> whois oram.com
John Oram (ORAM-DOM)
2339-6335 Thunderbird Circle
Vancouver, BC
V6N 2S2
CANADA
Domain Name: ORAM.COM
Administrative Contact, Technical Contact, Zone Contact:
Oram, John (JO82) oramy92@HALCYON.COM
(604) 228-2212
Record last updated on 14-Feb-95.
Domain servers in listed order:
NWNEXUS.WA.COM 192.135.191.1
HUB.UBC.CA 137.82.1.1
note that the lame report 'from' is the ip addr of HUB.UBC.CA
use nslookup; set server to 137.82.1.1 and:
> set q=a
> oram.com
Server: hub.ubc.ca
Address: 137.82.1.1
*** hub.ubc.ca can't find oram.com: Server failed
>
but using same server:
> oester.com
Server: hub.ubc.ca
Address: 137.82.1.1
Name: oester.com
Address: 206.25.136.13
so, you get lame delegation when a domain has root namservrs pointing to
nameservers that don't work.
-----------------------------------------------------------------------------
must be missing something simple; can't get ifconfig alias to work.
i need to have a host look like two ips for awhile - thought that's what
alias
is for.
...
if anyone knows who to alias an IP to a host with ifconfig - would
appreciate
this info much.
ou didn't mention what command you were using, specifically. I've
ot had any trouble with a sequence like this:
fconfig ef0 inet xxx.xxx.xxx.1 link0 # for first IP address
fconfig ef0 xxx.xxx.xxx.2 alias # alias for .2
fconfig ef0 xxx.xxx.xxx.3 alias # alias for .3
This is correct and works for me too. A couple of notes on the subject.
o You need to turn on IP forwarding in the kernel if you wish to route
between subnets on the same physical ether (I do this regularly).
o With BSD/OS v1.1 Mike Karels claimed there were problems removing
aliases with the ifconfig ... -alias command, they may still be there
in v2.0 (they don't always happen, just sometimes)
o If you add enough aliases you will take a performance hit, I've not
noticed this with 4 aliases.
o Remember to update your firewall machines if your packets need to
go through them.
------------------------------------
lame delegation: