I. Introduction of Tcp_wrappers
Security detection and access control for a specific service with stateful connections, implemented as a library file, whether a process accepts LibWrap control depends on whether the program initiating the process compiles at compile time for libwrap, and whether the service is capable of being tcp_ Wrapper method of access control:
Ldd/path/to/program|grep libwrap.so
Strings Path/to/program|grep libwrap.so
Example sshd:
- [[email protected] 1372]# which sshd
- /usr/sbin/sshd
- [[email protected] 1372]# ldd/usr/sbin/sshd | grep libwrap
- Libwrap.so. 0 =/lib64/libwrap.so. 0 (0x00007f5659d39000)
- [[email protected] 1372]# strings/usr/sbin/sshd | grep libwrap
- Libwrap.so. 0
- LibWrap Refuse returns
It/etc/hosts.deny these two configuration files through/etc/hosts.allow to restrict access to the IP that is accessing the services that support the Tcp_warppers module.
The read order of the two profiles takes precedence, and if the Allow file is loaded, deny is no longer read.
Second, the basic syntax within the configuration file:
1. Syntax: Service group: Host
2. Client client_list format
List of clients separated by commas or spaces
Based on IP address: 192.168.10.1 192.168.1.
Based on host name: www.magedu.com. magedu.com less
Based on network/mask: 192.168.0.0/255.255.255.0
Based on NET/PREFIXLEN:192.168.1.0/24 (CENTOS7)
Based on network group (NIS domain): @mynetwork
Built-in Acl:all,local,known,unknown,paranoid
Cases:
- Edit/etc/host.allow under Editing
- In.telnetd,sshd:172.18. in.telnet and sshd two services allow 172.18. Ten
- Edit/etc/host.deny under Editing
- In.telentd:ALL indicates that all hosts are denied connection to in.telnetd
- If the above file exists at the same time, the expression is only allowed 172.18. intelnetd, other hosts inaccessible, all network segments can access sshd (if not on the whitelist, the default is to allow White list and blacklist at the same time, permission to take the whitelist)
3. Special usage spawn, EXCEPT, twist
Expect unless the meaning of:
Cases:
- VSFTPD: 172.16. EXCEPT 172.16.0/ EXCEPT 172.1
- If this configuration is within allow, all hosts are allowed access, except for the 172 of the 172.16.1. 0 network segment.
- If this configuration is within deny, the 172.16 is refused permission.0 network segment except 172.16.1 This address access, other addresses are denied access
Spawn start an external program to do the following:
Cases:
- Sshd:ALL:spawn echo "$ (date +%%f) login attempt from%c to%s,%d" >>/var/log/sshd.log
- Whenever there is a host visit will have a record output to the/var/log/sshd.log file, note spawn front: often lost
- %c Client Information
- %s Server-side information
- %d Service Name
- PID of%p Daemon process
- Percent percentage
Twist the actual action is to deny access, replace the current service with the specified operation, standard I/O and error sent to the client, default to/dev/null
Cases:
- Add the following within Host.allow:
- VSFTPD: 172.16.: Twist/bin/echo "connectionprohibited" the project will replace the action of successful access with/bin/echo " Connectionprohibited " , twist is the meaning of substitution.
Test tools:
Tcpdmatch [-d] daemon[@host] Client
-D test Hosts.allow and Hosts.deny in the current directory
Cases:
- tcpdmatch-d (test configuration file under current directory, not necessarily etc) sshd 192.168.5
0000000000000000000
Tcp_wrappers access Control