0

I need to make sure that a specific user only accesses my server from a certain ips example: the remoteadmin user, which can only access from the IP ranges 192.168.50. *, 192.168.80. *

Would it also be possible to specify access to certain ports only?

Thank you

1 Answer 1

0

When a TCP connection attempt comes in, you normally only know the standard TCP/IP quadlet: source IP, destination IP, source port and destination port. The source port is normally dynamically allocated at the source host, and generally not a reliable indicator of anything.

You don't know for sure who the connecting user might be: to find that out, you must initially accept the connection and perform the authentication procedure, which usually requires some amount of two-way communication. Then, if the username is acceptable and the user provided valid authentication credentials, access to the system can be granted. If not, the connection will be cut off after some small number of failed authentication attempts.

iptables can certainly restrict access from certain IP ranges to certain ports. But iptables cannot know the username associated with the incoming connection, as it must make its decision before the authentication procedure happens.

Any username-based access control decisions must happen within the actual service that handles the authentication for the connection. In other words, if the incoming connection is a SSH connection, then the first thing that will have the capability to make username-based access decisions will be the sshd daemon. If sshd is configured to use PAM, then PAM rules might also be usable; if sshd is compiled to use the libwrap library, then /etc/hosts.allow and/or /etc/hosts.deny might be useful too.

1
  • AFAIK there is a packet tagging facility that you can use. However you need to establish trust between the part-taking network devices in order to rule out that untagged or malicious packets are inserted. Commented Dec 16, 2017 at 0:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .