Page 1 of 1

Multi-Port Trick - iptables

Posted: Wed Mar 20, 2019 10:39 pm
by Pedulla
Okay, multi port is cool.
By setting Options.Server.MIN_STREAMING_PORT to some value (in this example 30000) you turn it on.
Its discussed here https://medium.com/zmninja/multi-port-s ... 836a336c93

So you can configure your web server (Apache/NGINX) to listen to all those ports but that's a bit of a pain and if you are constantly adding and deleting monitors the Monitor ID (MID) can quickly go beyond the range of your listened to ports.

So I found this iptables trick to route ports to the single listening port on the server and mult-port works.

The below line

Code: Select all

iptables -t nat -A PREROUTING -p tcp --dport 30000:30200 -j REDIRECT --to-ports 443
redirects ports 30000 thru 30200 to port 443 where the zm webserver is listening. Adjust the range to what what you are comfortable with or that meets your needs.

Use

Code: Select all

iptables -L -n -t nat  --line-number
to list the rule

Don't forget to save the rules according to your distro's method so that it's persistent after reboot.

Tested with zm 1.33.4 but should work for 1.32.x
Works with zmninja
I'm running this on UB18.04 LEMP stack.

Re: Multi-Port Trick - iptables

Posted: Fri Feb 14, 2020 8:51 pm
by n8klayko
Can you give more specifics to how to do this? What files needs edited?

Re: Multi-Port Trick - iptables

Posted: Tue Feb 18, 2020 10:01 pm
by iconnor
That's actually very cool, I hadn't thought of that. Makes apache config a lot easier.

Re: Multi-Port Trick - iptables

Posted: Fri Jun 26, 2020 6:47 pm
by spammy
For those who have moved to nftables, an equivalent block in nftables.conf might look like:

Code: Select all

table ip nat {
        chain prerouting {
                type nat hook prerouting priority 0; policy accept;
                tcp dport 30000-30050 redirect to 80
        }

        chain postrouting {
                type nat hook postrouting priority 0; policy accept;
        }
}