0

I have an local network with two local server, other side i have a mikrotik router to share internet on that network. I can access my mikrotik route by its ip anywhere in internet. Is there is any way by that i can access my all those server remotely from anywhere by internet connection (I can access my local server in my local network)?

I am using ubuntu server 14.04.

1
  • Look for something called port forwarding in your router. May 2, 2014 at 13:11

1 Answer 1

1

First, I'm going to assume you're using IPv4 with NAT, and not IPv6. (IPv6 makes it easy. In fact, if you had IPv6, it would probably already work for you by default. Actually, it's probably more fair to just say doing stuff without NAT makes it easy, but that's usually not an option on IPv4.)

Assuming your router is using IPv4 NAT, you will need to set up something commonly referred to as port forwarding. It allows you to map a port on your Mikrotik router to be passed on to a server's port.

In essence, you will be setting up a rule that tells the Mikrotik router that if it sees traffic address to it on port X, re-write that traffic on the fly to be addressed to your server's internal IP (usually starts with 10. or 172.16. or 192.168.) address on port Y.

Here's how it's done on a Mikrotik router: First, go to the IP menu on the left, and then Firewall. Then make sure you are on the NAT tab, and then click the "Add New" button. Mikrotik WebFig v6 IPv4 firewall NAT page

You will be taken to a screen like this: Mikrotik WebFig v6 IPv4 firewall rule setting screen For chain, pick dstnat. Clik the arrow pointing down next to Dst. Address and then enter the address that you can access your Mikrotik router by from the internet. Unless you know you are using UDP ports, click the down arrow next to protocol and leave it at 6 (tcp). For the Dst. Port, again, click the down arrow, and enter the port you want to use on the internet to access your server.

Now scroll down the page: Bottom of Mikrotik WebFig v6 IPv4 firewall rule setting screen For action, select dst-nat. Change the "To Address" to the internal IP address of your server (again, this should start with 10. or 172.16. or 192.168.). Change the "To Port" to the port of the service on your server.

Mikrotik WebFig v6 IPv4 firewall rule setting screen OK, Cancel, & Apply buttons

Finally, click OK (if you want to leave the page and put the settings in place) or Apply (if you want to put the settings in place and stay on the page to tweak them).

Oh, and if you prefer the command line way, you can do something along the lines of this:

/ip firewall nat add chain=dstnat dst-address=69.69.69.69 protocol=tcp dst-port=5900 \
action=dst-nat to-addresses=192.168.1.101 to-ports=5900

Based of the Mikrotik wiki page on port forwarding.

7
  • Thank you for your answer. I do what u tell me to do, now Can you please tell me how should i access my server (172.16.0.5 and port 22, ssh port, router ip is xxx.xx.xx.xxx) from ubuntu terminal from another pc?
    – zxprince
    May 3, 2014 at 2:56
  • If the other ubuntu PC is using the same connection (behind the Mikrotik router/uses the Mikrotik router to get to the internet), then just do ssh [email protected]. If the other Ubuntu PC is not on the same connection/doesn't use the Mikrotik to get to the internet, use the Mikrotik's address: ssh [email protected].
    – Azendale
    May 3, 2014 at 4:55
  • (I am on out of my local netwark..) It's doing nothing just waiting and waiting !? how that could be access my 172.16.0.5 server by using only ssh username@mikrotikip ? no port call !?
    – zxprince
    May 3, 2014 at 5:27
  • If you set a port other than 22 for the internet facing side, try ssh -p portnumber username@mikrotikip
    – Azendale
    May 3, 2014 at 6:17
  • By ssh -p portnumber username@mikrotikip I can access my mikrotik terminal but can't access my local server terminal (Local server IP 172.16.0.5)!!! My main target to access my Local server.
    – zxprince
    May 3, 2014 at 7:05

You must log in to answer this question.

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