-1

Newbie question: I have set up a new Linux server. I have got SSH running on port 22. I have got Apache running on port 80.

I am told I should enable a firewall but why is that? 80 and 22 are the only two ports I'm using.

Is it just to make sure no other software starts using ports without my knowledge?

1 Answer 1

3

There's always some other software. If there's no such software now, you can always be sure it will appear in the future. So you really want to make sure no ports except 22 and 80 are opened - just in case.

You can check what's currently listening your server's ports by vieweing the netstat -an | grep LISTEN - for TCP ports. And for UDP - by viewing the netstat -an | grep udp output.

Also, to make sure - use nmap to scan your host from the outer world. If none except 22 and 80 is available - well, you can skip firewall configuration, and just use the ACCEPT policy for chains. But this is a dangerous approach. If not now, then in the future it can cause problems.

2
  • 2
    You don't need to grep, you just pass -t or -u options to netstat. Better, start using ss because netstat is going away. Feb 8, 2015 at 18:47
  • netstat is generic across all platforms. ss is linux-specific.
    – drookie
    Feb 8, 2015 at 20:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .