Cannot connect to OSMC from outside network - iptables not working


My Pi2 is behind a router with the proper ports forwarded (I can ssh to Pi2 using my public IP from within my network). I can also access raspbmc on my Pi with port forwarding and the proper iptables rules. The following is the iptables rule I have used

sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT

The rule works perfectly fine on my Pi with raspbmc and I am able to remotely ssh to my Pi. Not the Pi2 with OSMC however. I also tried disabling iptables altogether by setting the policy to ACCEPT entirely, to no avail. I am convinced this is an OSMC issue since the forwarding is done properly. I even exposed the Pi2 directly to the internet using DMZ (again, works with the raspbmc/Pi). I am out of ideas. Help would be much appreciated.

Thanks in advance

PS. Needless to say, I also tried porting the table as-they-were in my Pi to Pi2 using iptables-save and iptable-restore, no luck.

PPS. My apologies for the misleading thread. Things were not working because I was connecting to the internet using openvpn. Once openvpn is stopped and a direct connection is established everything works fine. Now the question is, how do I get it to work WITH the VPN connection. Thanks again.

No need to add any iptables rules - OSMC does not have any firewall rules enabled by default.

Check the log file for any entries from the ssh server after making a connection attempt.

By the way, testing connecting to the public IP address from inside the same network does not actually test your port forward is set up correctly on the router, in fact this doesn’t work with most routers even if the port forward is working correctly externally.

If you have a static IP on OSMC also make sure you have the correct default gateway and full internet connectivity from the device.

Thanks for your comments.

It is not just ssh however, I am unable to establish other connections to Pi2 as well. The one thing I failed to mention in my other post (and quite honestly, just forgot while troubleshooting) is that the Pi2 is connected using openvpn. This probably is somehow causing problems. Any way I can get around this?

OSMC does have static IP. Internet connectivity is as good as it can be.

It is indeed the case that everything works fine when VPN is disconnected. Any help on how I can make this work while being connected to the VPN.

I Don’t think so OpenVPN will hinder the port forward behaviour,
It opens up another device tun0, for openvpn traffic, your traffic flows through that, but you should still be able to access the network using IP assigned by the Wlan/eth0