I am making a bastion ssh server on CentOS 7 in an AWS EC2 instance. When I use the following rules in its ACL, I am able to connect to the server just fine:
Inbound Rules
- Allow traffic on port 22 from my client's IP
- Block all other traffic
Outbound Rules
- Allow all traffic to my client's IP
- Block all other traffic
AWS ACL rules are a crude parallel to iptables; they are probably nothing more than a simplified web interface to a set of iptable rules implemented in Amazon's cloud infrastructure.
My understanding is that the Outbound Rules set is applied to any packet going out of the server--regardless of which end of the connection initiated the connection.
Furthermore, my understanding is that when using a connection initiated by the client, my ssh server will only send ssh traffic over port 22.
But when I use the following rule set, I am no longer able to connect to my server via ssh:
Inbound Rules
- Allow traffic on port 22 from my client's IP
- Block all other traffic
Outbound Rules
- Allow traffic on port 22 to my client's IP
- Block all other traffic
All other features of AWS that can block traffic have been set to allow all traffic; iptables have been set to allow all traffic in the instance's operating system, as well.
Why can't my client establish an SSH connection when outbound traffic on the server is restricted to port 22?
iptables-saveoriptables -nLoutput) you have defined.