I own a vps with Ubuntu 10.04 and i want to make it just accessible to me and one friend mine through dyndns hosts. It's possible block all others ips?

  • What type of connection protocols are you using?
    – Publiccert
    Commented Feb 19, 2012 at 19:03
  • ssh, http and ftp
    – Marcus
    Commented Feb 19, 2012 at 19:07

3 Answers 3


First of all, check out Denyhosts. Add his(and your IP) to it and that will prevent others from connecting. Also, set 'AllowUser hisname yourname in sshd_config.

I wouldn't recommend ftp. Check out sftp. If you're using ssh already, you might as well use sftp too.

Blocking http is going to be trickier. Check out .htaccess but even that isn't ideal.

Most of this is for naught if you're using dynamic ips(most home connections).


If you have a software firewall (and you should), I'd suggest using that. That way, you're blocking connections lower down on the stack and you're potentially reducing the scope of vulnerabilities. Plus, malicious users would be less likely to discover network services that you don't want them to know about.

I'm personally fond of iptables myself, but others such as shorewall and ufw should work fine too. Just be careful when setting stuff up. =)

  • Amen to being careful during setup. A good rule of thumb is to always keep an SSH session open when pushing your changes. Then try connecting with a DIFFERENT session. Failed? Use your existing session to roll-back changes.
    – Publiccert
    Commented Feb 25, 2012 at 22:22

If you have dynamic IPs from your ISPs, what I presume because you what to use dyndns, it's not possible afaik. Problem: in a firewall ruleset you have to specify your IPs and these change in your case.

If you have static IPs the other answers are good.

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