Port forwarding from command line

Any questions about the Command Line Interface can be placed here!
Forum rules
We've moved! Head over to Synology Community (community.synology.com) to meet up with our team and other Synology enthusiasts!
Kl3my
I'm New!
I'm New!
Posts: 9
Joined: Sun Aug 05, 2018 1:10 am

Port forwarding from command line

Unread post by Kl3my » Fri Sep 21, 2018 6:53 pm

Hello,

I'm on DS414j, and I'm in China for a long time.

I can access my NAS via SSH (putty) and SFTP (Filezilla), but I can't access it via quickconnect (the engineers of the Great Firewall must must have found me).

To be able to dl things properly, I tried to install a commandline download station, which doesn't work because of the CPU...

I'd like to change the ports of https and http (which are already not 443 and 80 anymore, changed via the GUI) but via command line !

Could someone tell me where the files are ? Because the grep command to try to find the right file take many days and finds nothing...

Thanks anyway.

sincarne
Guru
Guru
Posts: 1578
Joined: Wed Feb 15, 2017 9:57 pm

Re: Port forwarding from command line

Unread post by sincarne » Sat Sep 22, 2018 10:34 am

you forward port on router.... you change port in dsm... wat you mean?

Kl3my
I'm New!
I'm New!
Posts: 9
Joined: Sun Aug 05, 2018 1:10 am

Re: Port forwarding from command line

Unread post by Kl3my » Sat Sep 22, 2018 3:20 pm

Change https and http ports on DSM, so that I can forward them in my router afterward.

But without access to GUI.

User avatar
akahan
Navigator
Navigator
Posts: 995
Joined: Sat Jul 14, 2012 6:52 pm

Re: Port forwarding from command line

Unread post by akahan » Sat Sep 22, 2018 3:38 pm

DS214play, DS216play, DS216, DS212J, DS414, DS816, rt2600ac

Kl3my
I'm New!
I'm New!
Posts: 9
Joined: Sun Aug 05, 2018 1:10 am

Re: Port forwarding from command line

Unread post by Kl3my » Sat Sep 22, 2018 7:29 pm

Thanks for the link, but I already tried this, and it changes nothing really. Plus, you need to use the GUi at one step.

To explicit what I'm looking for : I want to find the file(s?) that are modified buy the GUI "change DNS" option where you can set different ports for http and https. I'm sure there must be files where this is written.

Thanks anyway.

gokky
Versed
Versed
Posts: 220
Joined: Fri Sep 13, 2013 9:34 pm

Re: Port forwarding from command line

Unread post by gokky » Sat Sep 22, 2018 8:23 pm

As you have access to SSH, there is an ancient technique to tunnel any traffic over SSH. We used it to make a secure tunnel to mailservers in old days when Outlook Express didn't support SSL/TLS.

The idea is, that your SSH client makes tunnel to different ports on server side, and - while such SSH session is alive - you use localhost:{port_number} as address of service being put on server.

http://realprogrammers.com/how_to/set_u ... putty.html

I am not sure, whether SSH tunneling is enabled on Synology by default as it might be a security issue.

Some hints might be here: https://forum.synology.com/enu/viewtopic.php?t=134758

lpG

User avatar
akahan
Navigator
Navigator
Posts: 995
Joined: Sat Jul 14, 2012 6:52 pm

Re: Port forwarding from command line

Unread post by akahan » Sat Sep 22, 2018 8:34 pm

Why do you need to do this?
Why wouldn't you just forward the ports you want http and https to be found at on the router to the standard ports on the NAS?

So for example, if you want to access http at port 1290 from outside your network, forward port 1290 on the router to port 80 on the NAS.

I'm having trouble understanding why you would need to change the port on the NAS itself when you can change the port on the router.
DS214play, DS216play, DS216, DS212J, DS414, DS816, rt2600ac

Kl3my
I'm New!
I'm New!
Posts: 9
Joined: Sun Aug 05, 2018 1:10 am

Re: Port forwarding from command line

Unread post by Kl3my » Tue Sep 25, 2018 9:38 am

Thanks.

So, here is the situation.
I'm in China. My server is in France.

At first, I could access my server on ports 443 and 80, then I couldn't, guess I was found by the technicians of the GFW.
So I decided to faorwaed the ports I already gave to option on in my GUI. Worked for 2 weeks, and now I'm blocked again.

It might be a game of hide and seek, but I'd like to be able to access my GUI from time to time, at least to dl things I can't access here in China (VPN I have doesn't work).

So, in order to do that, I need to change the ports in the server from the only access I have : SSH.

User avatar
akahan
Navigator
Navigator
Posts: 995
Joined: Sat Jul 14, 2012 6:52 pm

Re: Port forwarding from command line

Unread post by akahan » Tue Sep 25, 2018 2:40 pm

Still not understanding why you can't just change the router ports. You can log into your router, right?

So if you want to access the NAS GUI at port 23452, and it is currently set to 5000, for example, you'd log into the router and set port 23452 to forward to port 5000. From the point of view of the national firewall, this would be exactly the same as changing the NAS GUI port to 23452.
DS214play, DS216play, DS216, DS212J, DS414, DS816, rt2600ac

Kl3my
I'm New!
I'm New!
Posts: 9
Joined: Sun Aug 05, 2018 1:10 am

Re: Port forwarding from command line

Unread post by Kl3my » Wed Sep 26, 2018 3:20 am

Of course I can change my router ports, but that doesn't mean that my station will accept these ports as the http and https ones, or does it ?

I get what you mean, but it doesn't work.

@gokki.
thanks for the links.
unfortunately, my NAS doesn't support ipkg.

User avatar
akahan
Navigator
Navigator
Posts: 995
Joined: Sat Jul 14, 2012 6:52 pm

Re: Port forwarding from command line

Unread post by akahan » Wed Sep 26, 2018 3:33 am

Of course. You change the incoming port on the router to point to the desired port on the NAS.

Change port Xxxx to point to the http port you set on the nas (you mentioned it is no longer port 80.)

For example: if you have set http to port 125 on the nas, then point port 54321 on the router to port 125 on the nas. Then, http://youripaddress:54321 will get you to http on the NAS.
DS214play, DS216play, DS216, DS212J, DS414, DS816, rt2600ac

Locked

Return to “Command Line Interface”