Limit total number of outgoing ports

Is it possible to limit the overall number of outgoing ports used?

I don’t want to block specific outgoing ports, just limited their overall number that are in use at a time. Our university network disconnects entirely machines that attempt to use too many ports at once, and I want to prevent these disconnects.

Alternatively, is it possible to block outgoing ports on a per application basis? In this case I could just block huge outgoing port ranges for the offending applications only (which do not allow these limitations in their settings), without disabling the well-behaved programs on my machine.

Our university network disconnects entirely machines that attempt to use too many ports at once, and I want to prevent these disconnects.

They do this for a reason. The solution could be not to use any programs using a lot of outgoing ports concurrently?

The applications in question are allowed. The admins suggest workarounds for Windows and MacOS, but not for Linux, which is why I am here.

The MacOS workaround is to block outgoing ports per application (for the applications known to cause trouble, e.g. Skype)

The reason for the network block is that the port scan detection, to identify infected machines inside the network, is a bit trigger happy. Also, the entire university network is placed behind NAT.

Maybe PeerGuardian (no openSUSE package known to me) or iplist ?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Use sysctl to set this. The option is the following:

net.ipv4.ip_local_port_range = 32768 61000

and you can see it like this:

cat /proc/sys/net/ipv4/ip_local_port_range

You can do restricting of outgoing ports by user s if you always ran
your scanner as a certain user you could limit it.

Good luck.


Want to yell at me in person?
Come to BrainShare 2011 in October: http://tinyurl.com/brainshare2011
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJOe0dxAAoJEF+XTK08PnB5ecsQALQaLzC7lG+iUCCDuEDkHv6d
GqqppMfpslK4pVk0ihGpuv9oM2BQFh+6AVVu+IMAVFn3O4ncmzbr1+KAa9Ir6bjm
wguk+46l8z73stAzx2CoMDTayeiA0A8vqqZFtbfilSeer4que3s54NOVuqYnRi3l
bs/KSjM3JQBj5nh/bfOVE/JJykYjeFmnWcnSq6a7rIBkyZJSKvAhkf0kr9PCvWAs
KJWiJ/8BQJ/JTTYYSbPMWluncecmPHqk3ti/IeYBh8h+0s5320P0cgSJg55YQlI+
KEMAowuUqknZ0FFfcA3XLWEEPrscfIiuWnC1cGSJvgzaXPs+KlNTPFSy0Eh1T7Gc
S7pe1eck7dWlhviqS/8tuSxCf1d4DxMtPXdkpf89Hfgwg4ow+0dStfw4f79525Sk
bg9EF/RWzqZusEYY8oENAs7ZPBBIQVk9YrUnLgREUaNDEwe8oETfGTfGJCmfqBDG
gBXvbafVygfOFxVh7GHxvJdBLwPBLun6bnnISgRhWXfTtioE8iNrvtb6Mq3ih7Bq
Ie3IRhI8KI862Azdxl37JcJj1G/g9zfhm6RsK+4vkY3I2Sn8vVC6PAnPanHgchI8
S6pyH7S5G4LkfAvOxEt6d3N6HsZ9D+Hpd7fthJOw6dalHIhaBqpZLieVOuX7z1ce
mPU9mbHntj0YbMGPCweM
=LWQL
-----END PGP SIGNATURE-----

I don’t think this will work. :frowning: The problem is when I am teleconferencing: I need VNC and the SmartBoard software to run, acting as client or server depending on the setup of my remote colleagues. If I block all outgoing port via sysctl, then those will stop working, won’t they?
On the other hand, I don’t think I can run my “scanner” as another user, since audio never works for programs started with “su -u” nor “kdesu -u”, and Skype without audio is rather pointless.

In general for <most> typical apps, I don’t see your question as very practical.

Ordinarily, after an initial connection by an application, the application typically will make any number of secondary connections in support of the primary connection and those aren’t easily controlled. The consequences of restricting numbers or port range can be unpredictable, you might experience only a slower session as connections are forcibly closed so a resource can be re-used, maybe worse.

The exception to this that immediately comes to mind of course is Peer to Peer File Sharing, but most decent apps will allow configuring connections and some will even close half-open connections for you. There are also other apps that are built with a Peer to Peer architecture but hardly ever try to sustain the massive number of half open connections P-P file sharing does, so they <could> be affected but wouldn’t be expected.

You mention “teleconferencing” using VNC and SmartBoard. I’m familiar with the former but not the latter. Do you really know that these apps will run afoul of your ISP? Unless you’re teleconferencing a number of others at once (eg as a Server to multiple clients or connecting to multiple Servers at once), VNC shouldn’t be an issue.

IMO,
Tony

No, my problem is just with Skype. VNC and the SmartBoard run just fine, but of course we want to discuss alongside our whiteboard scribbling. This works fine in principle, but once the Skype client decides to become a supernode, the port scan protection activates and disconnects the entire machine. And Skype almost always does this after 1-2 minutes after a call has started, since we have high bandwith, lots of Skype users and obviously no supernodes in our network. Our current solution is switching the SmartBoard server to Windows, since the Windows Skype-client can be prevented from supernode mode through registry keys. However, no such switch exists for the outdated Linux Skype client.

I would prefer to run Linux on our conferencing sever (especially since it needs open outside ports for partners to connect), but getting our partners more than 6 foreign universities to switch simultaneously to another VoIP software is hopeless from a practical viewpoint. So unless we can reign in Skype to behave nicely under Linxu, we’re stuck with windows.

On 2011-09-25 11:46, STurtle wrote:

> I would prefer to run Linux on our conferencing sever (especially since
> it needs open outside ports for partners to connect), but getting our
> partners more than 6 foreign universities to switch simultaneously to
> another VoIP software is hopeless from a practical viewpoint. So unless
> we can reign in Skype to behave nicely under Linxu, we’re stuck with
> windows.

Skype was forbidden on some universities precisely for that behaviour.

I know there are rules in iptables to block a user (or apps running under
some user or group) from connecting at all to outside, but I don’t know if
there is a similar trick to limit the number of ports. I’m no iptables
expert, so have a good read of the manuals, perhaps there is something.

A solution would be to virtualize a windows guest, and run skype in there.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

A quick search returns top entries from the Skype forums that say NAT and likely HTTP proxies automatically disable the Supernode function.

If that is the case, then

  • You must block Skype’s regular ports forcing Skype to fallback to running over HTTP.
  • You might want to verify you’re not already behind NAT, ie both IPv4 and IPv6 aren’t public addresses
  • If you must deploy an HTTP proxy, there should be a few you can run locally that’s lightweight enough not toaffect performance significantly.

HTH,
Tony