Question
iptables ssh not working
First I connected to server B’s vpn and ssh into server B from my local machine. Then I continue ssh into server A but fail.
Machine B with VPN and machine A both with private network setup. I’ve checked my ip when I connected to the vpn, the ip is machine B’s public ip.
The iptable rules are as follow:
(A)
sudo iptables -P INPUT ACCEPT
sudo iptables -P OUTPUT ACCEPT
sudo iptables -P FORWARD ACCEPT
sudo iptables -F
sudo iptables -A INPUT -p tcp -s <server B private ip> –dport 22 -i eth1 -j ACCEPT
sudo iptables -A OUTPUT -p tcp -d <server B private ip> –sport 22 -o eth1 -m state –state ESTABLISHED -j ACCEPT
sudo iptables -A INPUT -i lo -j ACCEPT
sudo iptables -A OUTPUT -o lo -j ACCEPT
(B) openvpn
sudo iptables -P INPUT ACCEPT
sudo iptables -P OUTPUT ACCEPT
sudo iptables -P FORWARD ACCEPT
sudo iptables -F
sudo iptables -A INPUT -p tcp -s <server A private ip> –dport 22 -i eth1 -j ACCEPT
sudo iptables -A OUTPUT -p tcp -d <server A private ip> –sport 22 -o eth1 -m state –state ESTABLISHED -j ACCEPT
sudo iptables -A INPUT -i lo -j ACCEPT
sudo iptables -A OUTPUT -o lo -j ACCEPT
sudo iptables -I OUTPUT -o eth0 -d 0.0.0.0/0 -j ACCEPT
sudo iptables -I INPUT -i eth0 -m state –state ESTABLISHED,RELATED -j ACCEPT
What I’m trying to achieve is ssh from machine B into machine A with private network ip while connecting to machine’s B openvpn.
No other firewall setup because I am testing the behavior of iptable with openvpn. Anyone can help to explain? Thanks.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×