Limit outbound SOCKS proxy requests with pf

Hi everyone,

For a very special use case of mine, I need to allow users to connect over SSH to my server to setup a SOCKS proxy:

<pre style="background-color:#ffffff;">
<span style="color:#323232;">ssh -D localhost:1080 -N my.server.domain.tld
</span>

However, I only want them to be able to reach 127.0.0.1 through this proxy (so, my server itself).

Is that even possible ?

otl,
@otl@lemmy.sdf.org avatar

You may be able to do this by specifying a rule with a user. For example, say I connect to puffy.example.org with user otl:

<pre style="background-color:#ffffff;">
<span style="color:#323232;">ssh -D 127.0.0.1:6969 otl@puffy.example.org
</span>

On the remote side, in pf.conf:

<pre style="background-color:#ffffff;">
<span style="color:#323232;">block out proto tcp all from self user otl
</span>

Untested. Curious to see what you come up with! See also pf.conf(5)

wgs,
@wgs@lemmy.sdf.org avatar

That’s awesome, I didn’t know you could filter by user ID ! I just tried and it works perfectly. I use the following:

<pre style="background-color:#ffffff;">
<span style="color:#323232;">block out proto { tcp udp } from self to port != domain user otl
</span>

This effectively blocks all outgoing connections for the given user (except DNS, as I want to allow forwarding DNS over SOCKS). Thanks a lot for the quick guidance !

otl,
@otl@lemmy.sdf.org avatar

No worries! I assume you’re the same z3bra who posted on /r/unixporn? If so answering your question quickly is the least I could do; your posts got me back into Linux/Unix for fun during university (studying medical science) in 2014. That got me a job in IT straight out of uni then into software dev. It’s been a wild ride the past 9 years living in both Australia and the Netherlands. So big, big thanks to you!

wgs,
@wgs@lemmy.sdf.org avatar

Yeah that’s me, though that was a very long time ago haha. That’s an awesome story, I could never guess simple posts like mines could be that much inspirational ^^ Thanks for sharing !

  • All
  • Subscribed
  • Moderated
  • Favorites
  • openbsd@lemmy.sdf.org
  • tacticalgear
  • DreamBathrooms
  • InstantRegret
  • magazineikmin
  • khanakhh
  • Youngstown
  • ngwrru68w68
  • slotface
  • everett
  • rosin
  • thenastyranch
  • kavyap
  • GTA5RPClips
  • cisconetworking
  • JUstTest
  • normalnudes
  • osvaldo12
  • ethstaker
  • mdbf
  • modclub
  • Durango
  • tester
  • provamag3
  • cubers
  • Leos
  • anitta
  • megavids
  • lostlight
  • All magazines