- Oracle 11g Anti-hacker's Cookbook
- Adrian Neagu
- 393字
- 2021-08-05 18:41:32
Using TCP wrappers to allow and deny remote connections
By using TCP wrappers you can control the accepting or denying of incoming connections from specified servers and networks. You may use this capability to protect your network in conjunction with a firewall. In the following recipe, we will allow connections opened through ssh
only from the nodeorcl5
host and deny from all others by using TCP wrappers.
Getting ready
All steps will be performed on nodeorcl1
as root.
How to do it...
TCP wrappers at host level are controlled by two files located in the /etc
directory called hosts.allow
and hosts.deny
.
- First we will start to deny all incoming connections from all hosts using all services by adding the following line into
/etc/hosts.deny
:# hosts.deny This file describes the names of the hosts which are # *not* allowed to use the local INET services, as decided # by the '/usr/sbin/tcpd' server. # # The portmap line is redundant, but it is left to remind you that # the new secure portmap uses hosts.deny and hosts.allow. In particular # you should know that NFS uses portmap! ALL:ALL ................................................................
- In this moment if we try to establish a connection from
nodeorcl5
it will be denied:[oraclient@nodeorcl5 ~]$ ssh -l oracle nodeorcl1 ssh_exchange_identification: Connection closed by remote host [oraclient@nodeorcl5 .ssh]$ ssh -l oracle nodeorcl1 oracle@nodeorcl1's password: Last login: Sun Aug 12 19:47:21 2012 from nodeorcl5 [oracle@nodeorcl1 ~]$
- To allow incoming connections only with
ssh
include the following in/etc/hosts.allow
:# # # hosts.allow This file describes the names of the hosts which are # allowed to use the local INET services, as decided # by the '/usr/sbin/tcpd' server. # sshd: nodeorcl5 ……………………………………………………………………………………
How it works...
All changes to hosts.deny
and hosts.allow
takes immediately in effect; hosts.allow
has precedence over the hosts.deny
file.
The format for rules is composed by a service or daemon, and host name or IP address. In our examples, we denied all services from all hosts and allowed only ssh
connections from nodeorcl5
.
There is more...
You can set rules for an entire network as follows:
Sshd :10.241.132.0/225.255.255.0 Exceptions can be set by using the EXCEPT clause: Sshd : ALL EXCEPT 10.241.132.122
- Java編程全能詞典
- 輕松學C語言
- JavaScript實例自學手冊
- 21天學通PHP
- MicroPython Projects
- STM32G4入門與電機控制實戰:基于X-CUBE-MCSDK的無刷直流電機與永磁同步電機控制實現
- OpenStack Cloud Computing Cookbook(Second Edition)
- 西門子S7-200 SMART PLC實例指導學與用
- AWS Administration Cookbook
- 網絡化分布式系統預測控制
- 中國戰略性新興產業研究與發展·工業機器人
- Windows Server 2003系統安全管理
- 嵌入式Linux系統實用開發
- Hands-On SAS for Data Analysis
- 基于人工免疫原理的檢測系統模型及其應用