Solution :
Delete the source port in your rule, you will have a rule like :
iptables -A INPUT -p tcp -s 10.99.1.1 -d 10.66.1.1 -m tcp --dport 22 -j ACCEPT
Explanations:
First we will assume that there is no routing problem but only firewall configuration.
The computer 10.99.1.1 (client) want to open a SSH session on the 10.66.1.1 (server).
The server must:
- Have an operational & configured ssh server
- Have its firewall open for SSH port (22 by default) :
iptables -A INPUT -p tcp -s 10.99.1.1 -m tcp --dport 22 -j ACCEPT
The intermediate firewall should have a iptable rule like :
iptables -A INPUT -p tcp -s 10.99.1.1 -d 10.66.1.1 -m tcp --dport 22 -j ACCEPT
The error you have committed is to specify the source port. Only the destination port on the server is required.
The client do not use the 22 port as source port for the SSH connection. The client ask the server for a new ssh session on the port 22 but use a local random port.
You can check that with the netstat -taupenl|grep ':22'
, you should see at leat :
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 0 11242 540/sshd
tcp 0 0 ip.server:22 ip.client:35332 ESTABLISHED 0 570915 12917/0
The first line matche the listening port of the ssh server, the second line match the current ssh connection with the client you can see the used ports, 22 for the server, 35332 for the client.
[Client]:35332 <----> [Server]:22
As the client ports are used randomly depending on the availability on the client you should not specify the source port.