putting jails on public addresses

James Gritton jamie at gritton.org
Thu Aug 21 03:11:57 UTC 2014


On 8/20/2014 9:02 PM, Littlefield, Tyler wrote:
> On 8/20/2014 10:50 PM, James Gritton wrote:
>> On 8/20/2014 5:20 PM, Littlefield, Tyler wrote:
>>> Hello:
>>> I'd really like to put a couple of jails on publically accessible IP 
>>> addresses. I have 5 that my provider has assigned to me. Could 
>>> anyone possibly shed
>>> some light on how to do this? I know of epairs, but I'm not sure 
>>> exactly how this works: does each interface (a and b) get an 
>>> address? I presume one would
>>> be 192.168.0.8 and the other would be x.x.x.x (where x.x.x.x is the 
>>> public address)? Which one should i set the gateway on?
>>> Thanks a lot for the help,
>>
>> You shouldn't need to mess with epair for most jails.  Just specify 
>> the jails' addresses (ip4.addr=x.x.x.x) in your jail.conf, and be 
>> sure to have an "interface=foo0" global line. The simplest jail setup 
>> is one using publicly available addresses on a single interface, 
>> which sounds like what you have.
>>
> Hello:
> Thanks a lot for the info. I guess I should have been a bit more 
> explicit: I want to be able to assign firewall rules to these separate 
> jails. I don't think I can assign rules based on address but have to 
> have some sort of interface. For example, port 80 will be open on two 
> jails, but one should have rate limiting applied to it.
> Thanks,

Ah yes, that is indeed more complicated :-).  I've never done any 
firewall rules involving interfaces, so I'm out of my depth there. I've 
had no problems with the simple things like restricting ports on 
different IP addresses on the same interface, but that doesn't mean I 
wouldn't have problems with rate limiting.

If it does indeed take its own interface, you have to connect the other 
end to somewhere.  The original Vimage work relied a lot on netgraph(4), 
but it sounds like you should be able to get by with at epair and an 
if_bridge.  Your physical interface would bridged with one side of all 
the epairs, and the bridge would have the server address and all the 
jail addresses.  Then each jail gets assigned the other half of one 
epair, and and internal IP address to go with it.

All that sounds good in theory, but take it as the advice of someone who 
hasn't typed a single test command in that area :-).

- Jamie


More information about the freebsd-questions mailing list