LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   iptables - SSH works fine after connecting but takes ages to connect (https://www.linuxquestions.org/questions/linux-newbie-8/iptables-ssh-works-fine-after-connecting-but-takes-ages-to-connect-906948/)

veeruk101 10-07-2011 09:26 AM

iptables - SSH works fine after connecting but takes ages to connect
 
I want only one remote machine to be able to access a server, so I've run the following commands on the server so that only a machine with the IP address 11.22.33.44 can connect to it in any way:

Code:

  iptables -F
  iptables -N LOGDROP
  iptables -A LOGDROP -j LOG -m limit --limit 5/min
  iptables -A LOGDROP -j DROP
  iptables -A INPUT -s 11.22.33.44 -j ACCEPT
  iptables -A INPUT -j LOGDROP
  iptables -A OUTPUT -j ACCEPT

However, this is causing it to take ages for me to connect to it from SSH. But then finally when it does connect, I can execute commands through SSH at the expected speed and responsiveness through. So I'm doing something wrong when setting up the iptables rules to make things go very slowly upon connecting. If you have any suggestions of how to fix this or can see my error, please let me know. Thanks.

Lexus45 10-07-2011 09:28 AM

Are you sure this depends on iptables?

Try to add this line to /etc/ssh/sshd_config:
Code:

UseDNS no
Quote:

UseDNS Specifies whether sshd(8) should look up the remote host name and check that the resolved host name for the remote IP address maps back to the very same IP address. The
default is “yes”.
or
Code:

AddressFamily inet

veeruk101 10-07-2011 10:01 AM

The problem did only appear when iptables was enabled, and your suggestions solved the problem. Thanks!


All times are GMT -5. The time now is 04:11 AM.