Howdy folks
I have a small and very basic question about Jail Networking in FreeBSD.
TLDR; What's the approach to make Jails communicate with each other.
Here's the situation:
I have the following two jails:
On 'web', i have nginx is running. Nginx serves my personal homepage as well as an instance of nextcloud.
Both jails get their ips via an alias of lo1.
Ifconfig in case it matters:
The web jail is accessed via a port forwarding rule in my pf.conf:
This all works fine and dandy.
But the nextcloud instance has an SQLite backend (the default), which of course isn't optimal for larger file collections.
So I made the second jail 'db'. It has an instance of postgresql running, ready to be used as my nextcloud backend.
Now here's the question: What's the best way of making 'web' talk to 'db'?
I guess I COULD take the same 'port forwarding' approach to make 'db' accessible from the outside, but I feel like that would be an uneccessary round trip across the internet.
I'm not expecting you guys to tell me all the necessary commands...
I can (and should have to) look them up myself, since 'aguy in the forum told me' is not the way to learn things IMHO.
But what IS the correct approach? Do I need to read up on VLANs and make my jails use VLAN? Do I need to make the roundtrip accross the internet? Is the solution even easier than I thought and I'm just not seeing it?
I did google around, and I found multiple blog posts and tutorials that MAYBE would be a solution, but again: I don't want to parrot other people's stuff, without knowing what I'm ACTUALLY doing
Thanks in advance!
[edit]I even have mwl's book on Jails, but it skips exactly this because it assumes that people now their tcp/ip stuff in detail already. I do have a CCNA, but I made it 8 years ago and since then worked as a developer. So my networking skills aren't exactly top notch anymore
[/edit]
I have a small and very basic question about Jail Networking in FreeBSD.
TLDR; What's the approach to make Jails communicate with each other.
Here's the situation:
I have the following two jails:
Code:
+-----+------+-------+--------------+------------+
| JID | NAME | STATE | RELEASE | IP4 |
+=====+======+=======+==============+============+
| 6 | db | up | 12.1-RELEASE | 172.16.2.1 |
+-----+------+-------+--------------+------------+
| 1 | web | up | 12.1-RELEASE | 172.16.1.1 |
+-----+------+-------+--------------+------------+
On 'web', i have nginx is running. Nginx serves my personal homepage as well as an instance of nextcloud.
Both jails get their ips via an alias of lo1.
Ifconfig in case it matters:
Code:
lo1: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
inet 172.16.1.1 netmask 0xffffff00
inet 172.16.2.1 netmask 0xffffff00
groups: lo
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
The web jail is accessed via a port forwarding rule in my pf.conf:
Code:
ext_if="vtnet0"
ext_addr=$ext_if:0
int_if="lo1"
jail_net=$int_if:network
web_addr="172.16.1.1"
web_ports="{ 80, 443 }"
scrub all
# Define the NAT for the web jail
nat on $ext_if from $jail_net to any -> $ext_addr port 1024:65535 static-port
# redirect http traffic to web jail
rdr pass on $ext_if inet proto tcp to port $web_ports -> $web_addr
# Set the default: block everything
block all
# blacklistd
anchor "blacklistd/*" in on $ext_if
block in
pass out
# Allow the jail traffic to be translated
pass from { lo0, $jail_net } to any keep state
# Allow SSH in to the host
pass in inet proto tcp to $ext_if port ssh
# Allow outbound traffic
pass out all keep state
This all works fine and dandy.
But the nextcloud instance has an SQLite backend (the default), which of course isn't optimal for larger file collections.
So I made the second jail 'db'. It has an instance of postgresql running, ready to be used as my nextcloud backend.
Now here's the question: What's the best way of making 'web' talk to 'db'?
I guess I COULD take the same 'port forwarding' approach to make 'db' accessible from the outside, but I feel like that would be an uneccessary round trip across the internet.
I'm not expecting you guys to tell me all the necessary commands...
I can (and should have to) look them up myself, since 'aguy in the forum told me' is not the way to learn things IMHO.
But what IS the correct approach? Do I need to read up on VLANs and make my jails use VLAN? Do I need to make the roundtrip accross the internet? Is the solution even easier than I thought and I'm just not seeing it?
I did google around, and I found multiple blog posts and tutorials that MAYBE would be a solution, but again: I don't want to parrot other people's stuff, without knowing what I'm ACTUALLY doing
Thanks in advance!
[edit]I even have mwl's book on Jails, but it skips exactly this because it assumes that people now their tcp/ip stuff in detail already. I do have a CCNA, but I made it 8 years ago and since then worked as a developer. So my networking skills aren't exactly top notch anymore