# ip aliasing and httpd.conf



## beesatmsu (Apr 19, 2010)

I have a computer I need to add a 2nd IP (because one domain name is not controlled by me, and it was pointing to a different IP, but I do not want to have 3 machines up, just 2 DNS which also run the web).

so I can add a 2nd IP through /etc/rc.conf, 

but not sure what do it in the httpd.conf:

do I do this?


```
NameVirtualHost *:80

<VirtualHost nic.1.ip:80>
    ServerAdmin webmaster@x.net
    DocumentRoot /usr/home/xyz
    ServerName x.net
    ErrorLog /usr/httplog/x.err
    CustomLog /usr/httplog/x.log common
</VirtualHost>

<VirtualHost nic.2.ip:80>
    ServerAdmin webmaster@y.com
    DocumentRoot /usr/home/123
    ServerName y.net
    ErrorLog /usr/httplog/y.err
    CustomLog /usr/httplog/y.log common
</VirtualHost>
```

do I have to set it to listen to both IPs before the virtualhost? how do I do that?


----------



## beesatmsu (Apr 19, 2010)

Ok, I got ip aliasing and httpd.conf to work together, however the /etc/rc.conf did not work:


```
1. ifconfig_re0="inet x.x.x.4 netmask 255.248.0.0"
ifconfig_re0_alias1="inet x.x.x.5 netmask 255.255.255.0"
```

but command line did work:

```
2. ifconfig re0 x.x.x.5 netmask 255.255.255.0 alias
```

can someone tell me why 2. works but not one? what is the correct command to put for freebsd? thanks.

for httpd.conf,
I listed both ips in first, then followed by what was in the first post.


```
NameVirtualHost x.x.x.4:80
NameVirtualHost x.x.x.5:80
```


----------



## anomie (Apr 19, 2010)

You skipped one.  I believe you need to start with _alias0.


----------



## beesatmsu (Apr 19, 2010)

I tried alias0, instead of alias1, still no luck after rebooting...

have to do it by hand after each reboot...


----------



## beesatmsu (Apr 19, 2010)

thanks. I realized that before reading your post...and tried..still wont work...


----------



## anomie (Apr 19, 2010)

Could you post your exact, updated rc.conf? 

Another thing I would point out is for aliases that are on the same subnet as the primary IP, the mask should actually be set to 255.255.255.255.


----------



## beesatmsu (Apr 19, 2010)

anomie, thanks! i was wondering if I should try .255 -- did not know it has to be the exact number. strangely the command line would work for .0. anyway I rebooted and now it works! the easiest problem so far for my boxes...


----------

