Do IP's have to be bound to NICs

Hi,

Does an IP address have to bound to a NIC for apache virtualhosts? I.E. if a /24 is routed to your port on a switch, and from the switch to your NIC.

Lets say for the purpose of understanding, your Server is given 192.168.20.1/24. And further you are going to use 192.168.20.50-100 for web sites. Would an alias have to be made (presuming your NIC is igb0) for each IP in /etc/start_if.igb0 as:

Code:
ifconfig_igb0_alias0="inet 192.168.20.50 netmask 255.255.255.255" #site 1
.
.
.
ifconfig_igb0_alias50="inet 192.168.20.100 netmask 255.255.255.255" site 50

Or do you not add the IP's to /etc/start_if.igb0?

Depending if the answer is no, not for apache conf's, then when must the IP(s) be bound to a NIC?
 
FreeBSD does not use /etc/start_if stuff.

rc.conf(5):

Code:
                 One can configure more than one IPv4 address with the
		 ipv4_addrs_<interface> variable.  One or more IP addresses
		 must be provided in Classless Inter-Domain Routing (CIDR)
		 address notation, whose last byte can be a range like
		 192.0.2.5-23/24.  In this case the address 192.0.2.5 will be
		 configured with the netmask /24 and the addresses 192.0.2.6
		 to 192.0.2.23 with the non-conflicting netmask /32 as
		 explained in the ifconfig(8) alias section.  With the inter-
		 face in question being ed0, an example could look like:

		 ipv4_addrs_ed0="192.0.2.129/27 192.0.2.1-5/28"
 
pauljames said:
Lets say for the purpose of understanding, your Server is given 192.168.20.1/24. And further you are going to use 192.168.20.50-100 for web sites. Would an alias have to be made (presuming your NIC is igb0) for each IP...

The answer is "yes", and a method for doing so is described in DutchDaemon's post. (Apparently ranges are OK.)
 
Depends on your network configuration. If your IP addresses are part of a subnet, and this subnet must reach some 'default gateway', then each IP address must participate to ARP [address resolution protocol].

Figure
Code:
router [subnet 192.168.1.0/24, no other routes]
  +- (virtual)host 1 [192.168.1.2]
  +- (virtual)host 2 [192.168.1.3] 
  ...
  `- (virtual)host N [192.168.1.n+1]

On another case, if you have a /28 subnet for example, and the router uses an explicit route to some of your machine IP addresses, then you do not need to bind the ip address to the physical interface, you can use the loopback for this purpose.

Figure
Code:
router [subnet 192.168.1.0/24, route to 192.168.2.0/24 configured via 192.168.1.2]
  +- host 1 [192.168.1.2]
       +- virtual host 1 - 192.168.2.1
       +- virtual host 2 - 192.168.2.2
       ...
       `- virtual host 254 - 192.168.1.254

On the first example, the router uses ARP to find individually what MAC address has the next hop when sending packets, we speak of 'direct route'.
The server using these ip addresses must respond to ARP requests, and this can't be done too easy if the IP addresses aren't bound to the physical interface.

On the second example, the router always uses the MAC address of 'host 1' to send packets to the destination network, and in this case we have a indirect route. The router won't send arp requests to find what MAC address has the host 192.168.2.x.
 
Thank you all for replying :)

I know if one is going to have a site on a host server, http://www.blah.com 1.2.3.3, the Server must have have 1.2.3.3 bound to the (outside) NIC.

However if one is running something like VirtualBox, and lets say one install a FreeBSD guest and used bridging, then the IP address must be bound to the FreeBSD Virtual Machine, and cannot be bound to the FreeBSD Host. Unless of course the packets are going to be forwarded to an inside NIC via something like PF and then the IP is bound to the host server's NIC.

So here is my confusion. If the VM has em0 configured with a routeable IP and not the Host Server with that same routeable IP, why does the Host Server's httpd.conf or /extra/httpd-vhosts.conf have IPs configured but those IP addresses still have be configured on the host server?
 
When you use 'bridging', you can't share the IP address between the host and the VM without problems. It's better to use NAT using
- VirtualBox's NAT mechanism or
- by using host's NAT mechanism (pf, etc), IP forwarding and a VM configured with a private network.
 
Hi Ecazamir,

We put on routeable IP's on VM's and they work just fine. Naturally, you cannot bind those IPs bound on the VM to the Host Server.
 
Back
Top