• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login
Netgate Discussion Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login

Restrict SSH access within subnet

Scheduled Pinned Locked Moved Firewalling
9 Posts 4 Posters 2.3k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J
    jao
    last edited by Feb 29, 2016, 7:28 AM

    Hi Guys

    Is this possible? To restrict SSH access where Source and Desti IPs are in the same subnet and interface?

    Thanks
    Jao

    1 Reply Last reply Reply Quote 0
    • D
      Derelict LAYER 8 Netgate
      last edited by Feb 29, 2016, 8:46 AM

      Not with your Layer 3 firewall since the traffic isn't routed but is on the LAN directly between nodes. You might be able to do it with a decent switch and switch port ACLs.

      eg.

      ip access-list extended "Block SSH"
      deny tcp any any eq ssh
      permit ip any any

      interface ethernet 1/1/4
      ip access-group "Block SSH" in

      Chattanooga, Tennessee, USA
      A comprehensive network diagram is worth 10,000 words and 15 conference calls.
      DO NOT set a source address/port in a port forward or firewall rule unless you KNOW you need it!
      Do Not Chat For Help! NO_WAN_EGRESS(TM)

      1 Reply Last reply Reply Quote 0
      • J
        jao
        last edited by Feb 29, 2016, 9:07 AM

        Hi Derelict

        I'm using pfsense 2.1.5 as firewall

        ip access-list extended "Block SSH"
        deny tcp any any eq ssh
        permit ip any any

        interface ethernet 1/1/4
        ip access-group "Block SSH" in

        Are this pfsense option/command?

        What I'm trying to say is I have LAN interface and both my servers and clients are in the same interface (LAN) and segment (192.168.0.x). I try to create a rule where clients (192.168.0.150) are not allowed to ssh to my server (192.168.0.9) except me (92.168.0.55).  See attached file

        Thanks!

        screenshot.png
        screenshot.png_thumb

        1 Reply Last reply Reply Quote 0
        • D
          Derelict LAYER 8 Netgate
          last edited by Feb 29, 2016, 9:31 AM Feb 29, 2016, 9:26 AM

          No You can't filter traffic between subnet hosts with a firewall/router like pfSense because same-subnet traffic isn't routed.

          Your LAN host 192.168.0.150 will not send traffic destined for 192.168.0.9 to pfSense, so those rules will do you no good. It will, instead, ARP on LAN for the MAC address of 192.168.0.9 and send the traffic directly to the destination host. pfSense will not be involved at all. That's how same-subnet traffic works.

          Those commands show you how to do it in a decent switch. That is for a Brocade ICX if host 192.168.0.150 was plugged into switch port 1/1/4.

          Chattanooga, Tennessee, USA
          A comprehensive network diagram is worth 10,000 words and 15 conference calls.
          DO NOT set a source address/port in a port forward or firewall rule unless you KNOW you need it!
          Do Not Chat For Help! NO_WAN_EGRESS(TM)

          1 Reply Last reply Reply Quote 0
          • J
            jao
            last edited by Feb 29, 2016, 9:40 AM

            ow I see, so to make this work I need to have separate interface  for my Server and my client to filter SSH access and other traffic? Is that right?

            Thanks!

            1 Reply Last reply Reply Quote 0
            • D
              Derelict LAYER 8 Netgate
              last edited by Feb 29, 2016, 9:47 AM

              Yes. If you want your router to be able to filter such traffic the server and host need to be on separate router interfaces.

              Chattanooga, Tennessee, USA
              A comprehensive network diagram is worth 10,000 words and 15 conference calls.
              DO NOT set a source address/port in a port forward or firewall rule unless you KNOW you need it!
              Do Not Chat For Help! NO_WAN_EGRESS(TM)

              1 Reply Last reply Reply Quote 0
              • J
                jao
                last edited by Feb 29, 2016, 9:49 AM

                Ok got it Derelict

                Thanks a lot!

                1 Thank/s for you :)

                1 Reply Last reply Reply Quote 0
                • J
                  johnpoz LAYER 8 Global Moderator
                  last edited by Feb 29, 2016, 3:03 PM

                  I think your missing the point.. If you want to block client A from going to B that are all in the same network 192.168.1.0/24 for example..  Pfsense would have nothing to do with this traffic… You would have to route the traffic using pfsense as the router if you wanted it to firewall that traffic.  So A would have to be in say 192.168.1.0/24 and B would have to be in 192.168.2.0/24 where pfsense is the router between those segments.

                  An intelligent man is sometimes forced to be drunk to spend time with his fools
                  If you get confused: Listen to the Music Play
                  Please don't Chat/PM me for help, unless mod related
                  SG-4860 24.11 | Lab VMs 2.8, 24.11

                  1 Reply Last reply Reply Quote 0
                  • K
                    KOM
                    last edited by Feb 29, 2016, 4:25 PM

                    You can do it via ssh_config:

                    AllowUsers jao@172.16.1.2
                    
                    AllowUsers kom@192.168.1.*
                    
                    1 Reply Last reply Reply Quote 0
                    9 out of 9
                    • First post
                      9/9
                      Last post
                    Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
                      This community forum collects and processes your personal information.
                      consent.not_received