864cf34e80bc7c5a9133c8cf2aee239f71e26885
[ikiwiki.git] / docs / handbook / handbook-configtuning-virtual-hosts.mdwn
1 \r
2 \r
3 ## 6.9 Virtual Hosts \r
4 \r
5 A very common use of DragonFly is virtual site hosting, where one server appears to the network as many servers. This is achieved by assigning multiple network addresses to a single interface.\r
6 \r
7 A given network interface has one ***real*** address, and may have any number of ***alias*** addresses. These aliases are normally added by placing alias entries in `/etc/rc.conf`.\r
8 \r
9 An alias entry for the interface `fxp0` looks like:\r
10 \r
11     \r
12     ifconfig_fxp0_alias0="inet xxx.xxx.xxx.xxx netmask xxx.xxx.xxx.xxx"\r
13 \r
14 \r
15 Note that alias entries must start with `alias0` and proceed upwards in order, (for example, `_alias1`, `_alias2`, and so on). The configuration process will stop at the first missing number.\r
16 \r
17 The calculation of alias netmasks is important, but fortunately quite simple. For a given interface, there must be one address which correctly represents the network's netmask. Any other addresses which fall within this network must have a netmask of all `1`s (expressed as either `255.255.255.255` or `0xffffffff`).\r
18 \r
19 For example, consider the case where the `fxp0` interface is connected to two networks, the `10.1.1.0` network with a netmask of `255.255.255.0` and the `202.0.75.16` network with a netmask of `255.255.255.240`. We want the system to appear at `10.1.1.1` through `10.1.1.5` and at `202.0.75.17` through `202.0.75.20`. As noted above, only the first address in a given network range (in this case, `10.0.1.1` and `202.0.75.17`) should have a real netmask; all the rest (`10.1.1.2` through `10.1.1.5` and `202.0.75.18` through `202.0.75.20`) must be configured with a netmask of `255.255.255.255`.\r
20 \r
21 The following entries configure the adapter correctly for this arrangement:\r
22 \r
23     \r
24      ifconfig_fxp0="inet 10.1.1.1 netmask 255.255.255.0"\r
25      ifconfig_fxp0_alias0="inet 10.1.1.2 netmask 255.255.255.255"\r
26      ifconfig_fxp0_alias1="inet 10.1.1.3 netmask 255.255.255.255"\r
27      ifconfig_fxp0_alias2="inet 10.1.1.4 netmask 255.255.255.255"\r
28      ifconfig_fxp0_alias3="inet 10.1.1.5 netmask 255.255.255.255"\r
29      ifconfig_fxp0_alias4="inet 202.0.75.17 netmask 255.255.255.240"\r
30      ifconfig_fxp0_alias5="inet 202.0.75.18 netmask 255.255.255.255"\r
31      ifconfig_fxp0_alias6="inet 202.0.75.19 netmask 255.255.255.255"\r
32      ifconfig_fxp0_alias7="inet 202.0.75.20 netmask 255.255.255.255"\r
33 \r
34 \r
35 \r
36 \r
37 CategoryHandbook\r
38 CategoryHandbook-configuration\r