I've bought an unmanaged dedicated server. Mainly to help me learn.

My email isn't working and the host support have told me I that need to open port 25 to enable smtp. Note I can't send or receive email.

I've used SSH to login and I've tried a few of the sample snippets of code from this forum but I just get a command not found back.

My server is running centOS and it has a Plesk GUI.

I've connected to the server using ssh root@myipaddress

  • There are few questions to be asked here: How is your email not working ? What did you try and see failing ? Could you please explain ? Also, from another server on the internet, please run this command telnet your_ip_address 25 and update your original post with the output you see on the terminal window. – MelBurslan Jun 16 '16 at 15:57
  • Thanks! I just can't send or receive email. It just won't connect to the server. I have just used that telnet command and I have received back "Unable to connect to remote host" – Ricky55 Jun 17 '16 at 10:10
  • On the local host, i.e. your new centos system, please run this command and post the output: netstat -an | grep 25 this will show you if anything is listening on the smtp port, i.e. port 25, on your server. If it is not, this means you can not receive email on this server. – MelBurslan Jun 17 '16 at 13:19
  • I get the following: See code here – Ricky55 Jun 17 '16 at 19:00
  • You don't have anything listening on port 25, which is SMTP port. So, there is no way that someone can send an email to your server and you receive it. Answer below, assumes that you have a running mailserver and trying to help you let the SMTP traffic pass through the iptables server based firewall. But you are not at that stage yet. You need to configure a mail server. Unless your sole purpose it to send and receive email with this server, it is not a good start point, learning about Linux. A badly configured mail server can be a honey pot for spammers and you find yourself in hot water – MelBurslan Jun 17 '16 at 19:25

The command to check if 25 is open:

Telnet <your-IP> 25

If it allows it, the port is open and that's not your problem.

If connection is refused, do the following:

sudo vi /etc/iptables.test.rules

Check that there is an entry like this:

# Allows SMTP access -A INPUT -p tcp --dport 25 -j ACCEPT

If not, change it using vi commands. If you're new, remember i goes into insert mode to use standard keyboard and :wq! saves when you're done.

Next, apply the rules you just wrote.

sudo iptables-restore < /etc/iptables.test.rules

Check to make sure the rules are applied correctly.

sudo iptables -L

Next, save them permanently.

sudo iptables-save > /etc/iptables.up.rules

  • Thank you so much for helping me. When I use the iptables.test.rules command I get no entry and just the prompt "/etc/iptables.test.rules" [New File] – Ricky55 Jun 17 '16 at 10:12
  • Do I need to create this file and set up the ports I want open? – Ricky55 Jun 17 '16 at 10:13
  • Run this command and let me know what you get: netstat -a | grep 25 This will look for all ports then filter out just the lines that include "25" – SomeGuy Jun 17 '16 at 14:11
  • I get the following: See code here – Ricky55 Jun 17 '16 at 18:58
  • Doesn't look like anything is trying o connect creating a binding. Try nc -l 25 then from a remote computer either ssh to port 25 or nc <local $hostname> 25 – SomeGuy Jun 20 '16 at 15:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.