I have a virtual server with a single IP address on which I wish to set up jails using sysutils/ezjail. At present I'm testing the configuration on a VirtualBox VM install of FreeBSD.
The sysutils/ezjail page in the Handbook suggests setting up the jail with an alias to the external NIC (in my case em0) in the same subnet as the allocated IP, but that is visible from outside and would doubtless upset my hosting company if I started pinching IPs that aren't mine! The other option is to use the lo1 interface with NAT and redirection, but I understand that could expose local processes which should stay private.
I therefore decided to try a virtual bridge with NAT and redirection, but I'm not sure how that works in FreeBSD.
1. Do I need taps or can I use aliases directly on the bridge?
2. On the assumption I might need taps I have created some, though if I assign them IPs they remain with status "no carrier". What do I need to do to "connect" the tap?
3. If I assign an alias directly to the bridge I still can't forward it to my external NIC.
Here are the relevant parts of /etc/rc.conf:
,
/etc/pf.conf
,
/usr/local/etc/ezjail/sharedserver:
and, finally,
Any pointers welcome. Thanks.
The sysutils/ezjail page in the Handbook suggests setting up the jail with an alias to the external NIC (in my case em0) in the same subnet as the allocated IP, but that is visible from outside and would doubtless upset my hosting company if I started pinching IPs that aren't mine! The other option is to use the lo1 interface with NAT and redirection, but I understand that could expose local processes which should stay private.
I therefore decided to try a virtual bridge with NAT and redirection, but I'm not sure how that works in FreeBSD.
1. Do I need taps or can I use aliases directly on the bridge?
2. On the assumption I might need taps I have created some, though if I assign them IPs they remain with status "no carrier". What do I need to do to "connect" the tap?
3. If I assign an alias directly to the bridge I still can't forward it to my external NIC.
Here are the relevant parts of /etc/rc.conf:
Code:
ifconfig_em0="inet 10.0.2.141 netmask 255.255.255.0"
cloned_interfaces="${cloned_interfaces} lo1 bridge0 tap0 tap1 tap2 tap3 tap4"
ifconfig_bridge0="ether 10:00:00:00:00:06 addm tap0 addm tap1 addm tap2 addm tap3 addm tap4"
ifconfig_lo1_aliases="inet 127.0.1.1-5/32"
ifconfig_bridge0_aliases="inet 10.20.0.0-5/24"
/etc/pf.conf
Code:
ext_if = "em0"
int_if = "bridge0"
jails_out = "{ domain, auth, smtp, http, https, cvspserver, 5999, 8000, 8080 }"
localnet = $int_if:network
WEB_IN_ADDR="10.20.0.1"
nat on $ext_if from $localnet to any -> ($ext_if)
rdr pass on $ext_if inet proto tcp to port http -> $WEB_IN_ADDR port http
rdr pass on $ext_if inet proto tcp to port https -> $WEB_IN_ADDR port https
/usr/local/etc/ezjail/sharedserver:
Code:
export jail_sharedserver_ip="lo1|127.0.1.1,bridge0|10.20.0.1"
and, finally,
ifconfig:
Code:
em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=9b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM>
ether 08:00:27:4f:e9:cb
inet 10.0.2.141 netmask 0xffffff00 broadcast 10.0.2.255
inet6 fe80::a00:27ff:fe4f:e9cb%em0 prefixlen 64 scopeid 0x1
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
media: Ethernet autoselect (1000baseT <full-duplex>)
status: active
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x4
inet 127.0.0.1 netmask 0xff000000
nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
lo1: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
inet 127.0.1.2 netmask 0xffffffff
inet 127.0.1.3 netmask 0xffffffff
inet 127.0.1.4 netmask 0xffffffff
inet 127.0.1.5 netmask 0xffffffff
inet 127.0.1.1 netmask 0xffffffff
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
bridge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 10:00:00:00:00:06
inet 10.20.0.0 netmask 0xffffff00 broadcast 10.20.0.255
inet 10.20.0.1 netmask 0xffffffff broadcast 10.20.0.1
nd6 options=9<PERFORMNUD,IFDISABLED>
id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15
maxage 20 holdcnt 6 proto rstp maxaddr 2000 timeout 1200
root id 00:00:00:00:00:00 priority 32768 ifcost 0 port 0
member: tap4 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
ifmaxaddr 0 port 11 priority 128 path cost 2000000
member: tap3 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
ifmaxaddr 0 port 10 priority 128 path cost 2000000
member: tap2 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
ifmaxaddr 0 port 9 priority 128 path cost 2000000
member: tap1 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
ifmaxaddr 0 port 8 priority 128 path cost 2000000
member: tap0 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
ifmaxaddr 0 port 7 priority 128 path cost 2000000
tap0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=80000<LINKSTATE>
ether 00:bd:d0:05:00:00
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
media: Ethernet autoselect
status: no carrier
tap1: flags=8902<BROADCAST,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=80000<LINKSTATE>
ether 00:bd:d7:05:00:01
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
media: Ethernet autoselect
status: no carrier
tap2: flags=8902<BROADCAST,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=80000<LINKSTATE>
ether 00:bd:dd:05:00:02
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
media: Ethernet autoselect
status: no carrier
tap3: flags=8902<BROADCAST,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=80000<LINKSTATE>
ether 00:bd:e3:05:00:03
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
media: Ethernet autoselect
status: no carrier
tap4: flags=8902<BROADCAST,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=80000<LINKSTATE>
ether 00:bd:ea:05:00:04
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
media: Ethernet autoselect
status: no carrier
Any pointers welcome. Thanks.