Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to connect to my computer remotely(all ports), but that ip changes. I have everthing figured out on how the comp woukd know my current ip, but i don't know how to add an ip on all ports and remove that ip (dynamic ip so I'll remove one and add a new one). Don't i need to save the changes during commands?

For the people answering, i already have a no-ip account, and the computer checks that to see when it changes. All i have to do now is add the new ip and remove the old one. Also i have my router allow only the ports i need.Thanks for trying though.

share|improve this question
So you want to connect to your server from everywere? Just run no firewall! This will be very insecure. A slightly better way: - Run a SSH server on a fixed port, say 22 (default) - Check your actuall public ip address, for example let it be - Connect to your server via ssh your.servers.dns-name - Open your firewall in your ssh session: sudo iptables -I INPUT 1 -s -j ACCEPT - Maybe you must also open the reverse path on your server with: sudo iptables -I OUTPUT 1 -d -j ACCEPT - Do what you want with your open server. - Shut it down in your ssh session (close – k-bielke Mar 14 '13 at 16:50

To answer your question, the IP you get is assigned by your ISP. You have to contact them to get your IP to be held as "static" and that may cost you additional money.

As for access after that, you're looking at just having to port-forward relevant ports in your router. and open the firewall for those ports on the target machine.

share|improve this answer

The best way to go about doing this is with a system like No-Ip, I use this personally on my MediaPC here at the home. This automatically updates your IP when it changes to no-ip's system and sets the subdomain there to your new IP.

The initial account is free to setup, and some routers actually have no-ip in their config, so no need for software on PC.

Now for software on PC they do offer Daemon based software: Init.d startup script not working for No-IP

I had set this up myself as well. You can download their software from here:

Then setup the Daemon upstart script as I did in the post above and all works perfect at startup. I have it checking every 10 minutes myself.

The other thing that needs to be done is you need to go into your Modem or Router (depending on your ISP) and set Port Forwarding. For instance I use plex on my Media PC. So to connect from the outside I have to tell my router to forward port 32400 which is the plex default port to XXXX port on the outside world. I use another port than 32400 so it's not default.

This Port Forwading is crucial as it allows incoming access from the outside of our Router through the ISP.

Now for most Routers they do not have a * for port forwarding, you must do each port manually. They do this for security, the only real way to allow all ports is set your Router up with no firewall or on some routers DMZ zones will allow all port forwarding, other routers it does not, it only disables filtering. You would need to check your routers manual to know if DMZ allows all port forwarding for your model.

A few links on setting up basic port forwarding for a router.

Now a quick solution is in some routers they will allow port ranges, for this you would enter port 1 as the first port and 65534 as the end range, this would allow ALL ports to forward to X ip address from the outside. This is again on some routers only, the cheaper ones or routers locked down by your ISP will only allow single port forwards.

enter image description here

Once changes are done most routers do require you to restart your router for changes to take effect, most new routers will ask you to do this and restart using software. If not you must unplug your router for a few seconds then plug back in after saving changes.

share|improve this answer
up vote 0 down vote accepted
sudo iptables -I INPUT -i eth1 -s $currip -j ACCEPT

Adds an IP

sudo iptables -D INPUT -i eth1 -s $lastip -j ACCEPT

Removes an IP


Thanks to those who tried. I hope this helps someone.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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