Select Language:
If you’re having trouble connecting to ports other than SSH (port 22) on your EC2 instance, don’t worry—there are some common issues that could be causing this. Here’s a simple guide to help you troubleshoot and fix the problem.
First, check your firewall rules on the server. The most common mistake is the order of rules in iptables. If a general reject rule is listed before your specific rules to allow OpenVPN traffic, all incoming connections are rejected before they get a chance to be accepted. To fix this, you need to move your accept rule for UDP port 1194 above the reject rule. You can do this with these commands:
sudo iptables -D INPUT -j REJECT –reject-with icmp-host-prohibited
sudo iptables -A INPUT -p udp –dport 1194 -j ACCEPT
sudo iptables -A INPUT -j REJECT –reject-with icmp-host-prohibited
Next, when testing your OpenVPN port with netcat, make sure you’re using UDP. Many people try to connect with TCP, which won’t work if your server is listening for UDP traffic. To test UDP ports with netcat, run this command on your server:
nc -u -v -l 0.0.0.0 1194
And on your client, use:
nc -u -v
It’s also important to verify your AWS security groups. Sometimes, security groups only allow TCP traffic, or they might not have a rule for UDP port 1194. Double-check that your security group explicitly allows inbound and outbound UDP traffic on port 1194.
Lastly, if you’re still facing issues, consider temporarily turning off your server’s firewall to see if it’s causing the problem. Just remember to turn it back on after testing. Here are the commands:
– For RHEL, CentOS, or Fedora:
sudo systemctl stop firewalld
– For Ubuntu or Debian:
sudo ufw disable
By following these steps, you should be able to identify where the connection is being blocked and fix it. If problems persist, reviewing your configurations or reaching out for further support can help.