Antsle Forum

Welcome to our Antsle community! This forum is to connect all Antsle users to post experiences, make user-generated content available for the entire community and more. 

Please note: This forum is about discussing one specific issue at a time. No generalizations. No judgments. Please check the Forum Rules before posting. If you have specific questions about your Antsle and expect a response from our team directly, please continue to use the appropriate channels (email: [email protected]) so every inquiry is tracked. 

Please or Register to create posts and topics.

Fine I'll start | My Antsle Setup So Far

PreviousPage 3 of 3
Quote from lancem on January 22, 2020, 3:13 pm

Now I feel bad I've been restricting them all this time...

If I understand the article correctly, it's not that you can't restrict LXCs; it's just that tools like top, when run inside an LXC, won't show you the restricted view of the universe, but the system view.

Hello again, folks!

I just got my Antsle set up and running (YAY!). Trying to get Plex Media Server running in an Ubuntu LXC antlet. Port forwarding does not appear to work. When I set it up in Antman, I see what the attached image shows -- it does not actually show the target antlet. Hitting the port with a browser gets me Connection Refused (yes, the server is actually running).

So, TLDR: Those of you successfully running Plex, how'd you do it?

 

 

Uploaded files:
  • port-forward-problem.png

As far as port-forwarding to the plex antlet through the antsle, I'm currently using the lxc hook script as used to be described on the old docs (which now I can't find in the new docs).

A few months ago, I tried the software port forwarding, but couldn't get it to work.  I'll probably try again soon.

Below is the script I use for my plex (I can't seem ti upload it so it's in the post) -- save it to a file called lxc).  In addition to port 32400, I also forward ports for Samba as it also shares files.

I took their example script and procedure-ized it so I can more easily add additional antlets to it.

Note in the script the "host_ipaddr" is the ip address of your antsle.

You place this lxc script in  /etc/libvirt/hooks

And make sure it's executable (chmod 755  for example)

If the hooks directory doesn't exist, you'll have to create it.  If this is the case (or there isn't an lxc file there already), after putting the file there, you have to reboot the antsle.  Once this is done, you can add more sections without rebooting.

 

You can add more sections by copy/pasting the 12 lines starting at:

# copy 12 lines (including this one)

Then modify the antlet name, the antlet IP, and the host/antlet ports

When the antlet starts, the script enables port forwarding for the antlet.

When the antlet stops, it disables the forwarding.

To the same with a KVM antlet, you have to make a similar script called "qemu".  The structure is the same.

I can't take credit for the script.  The antsle folks had it in the old docs (before the antman port forwarding feature).

If I can ever get the antman method to work, I'll post what I did.

 

#!/bin/bash
# update: 11/16/2018

antlet_type=`basename "$0"`

function openPorts {
#######################################################################
# Perform actions
if [ "${1}" = "${antlet_name}" ]; then
echo `date` hook/${antlet_type} "antlet ${1}" "${2}" >>/var/log/libvirt/hook.log
fi
length=$(( ${#host_ports[@]} - 1 ))
if [ "${1}" = "${antlet_name}" ]; then
if [ "${2}" = "stopped" ] || [ "${2}" = "reconnect" ]; then
for i in `seq 0 $length`; do
echo "`date` hook/${antlet_type} antlet $antlet_name Closing port ${host_ports[$i]} -> ${antlet_ports[$i]} " >>/var/log/libvirt/hook.log
iptables -t nat -D PREROUTING -d ${host_ipaddr} -p udp --dport ${host_ports[$i]} -j DNAT --to ${antlet_ipaddr}:${antlet_ports[$i]}
iptables -D FORWARD -d ${antlet_ipaddr}/32 -p udp -m state --state NEW,ESTABLISHED,RELATED --dport ${antlet_ports[$i]} -j ACCEPT
iptables -t nat -D PREROUTING -d ${host_ipaddr} -p tcp --dport ${host_ports[$i]} -j DNAT --to ${antlet_ipaddr}:${antlet_ports[$i]}
iptables -D FORWARD -d ${antlet_ipaddr}/32 -p tcp -m state --state NEW,ESTABLISHED,RELATED --dport ${antlet_ports[$i]} -j ACCEPT
done
fi
if [ "${2}" = "start" ] || [ "${2}" = "reconnect" ]; then
for i in `seq 0 $length`; do
echo "`date` hook/${antlet_type} antlet $antlet_name Mapping port ${host_ports[$i]} -> ${antlet_ports[$i]} " >>/var/log/libvirt/hook.log
iptables -t nat -A PREROUTING -d ${host_ipaddr} -p tcp --dport ${host_ports[$i]} -j DNAT --to ${antlet_ipaddr}:${antlet_ports[$i]}
iptables -I FORWARD -d ${antlet_ipaddr}/32 -p tcp -m state --state NEW,ESTABLISHED,RELATED --dport ${antlet_ports[$i]} -j ACCEPT
iptables -t nat -A PREROUTING -d ${host_ipaddr} -p udp --dport ${host_ports[$i]} -j DNAT --to ${antlet_ipaddr}:${antlet_ports[$i]}
iptables -I FORWARD -d ${antlet_ipaddr}/32 -p udp -m state --state NEW,ESTABLISHED,RELATED --dport ${antlet_ports[$i]} -j ACCEPT
done
fi
fi
}

#######################################################################
#######################################################################
#######################################################################
#######################################################################
#######################################################################
# copy 12 lines (including this one)
# Update the following variables to fit your setup
# Use an equal number of host and guest ports
antlet_name=plex
antlet_ipaddr=10.1.1.13
host_ipaddr=192.168.86.7
host_ports=( '135' '137' '138' '139' '445' '32400' )
antlet_ports=( '135' '137' '138' '139' '445' '32400' )

openPorts "$1" "$2"

#######################################################################

Personally instead of ever relying on antsle's port forwarding or LXC hooks, I typically either use nginx as a proxy pass to my individual antlets or in the case of a few (Plex and some game servers), I bridge them to my local network with either static or reserved IPs and use my router's port forwarding to route to the antlet directly.

I remember Plex having some weirdness setting it up though...

I actually wound up using the bridging method--adding a virtual interface and setting it up to DHCP from my LAN, and then getting UPnP working through my router (which allows remote access as well). This is working well now.

One thing I had to do on this particular antlet, though, was not just ADD the bridged interface but REMOVE the default interface and the connection to the 10.x net. This was more a problem with Plex not being able to be told to bind to a specific interface than anything else, although it's possible I might have been able to solve it by setting routing metrics in the netplan config, instead. At any rate, it's working now with a fairly straightforward configuration.

Has anyone figured out how to pass through a gpu or video card to antlets?

PreviousPage 3 of 3