Community discussions

MikroTik App
 
immateriale
just joined
Topic Author
Posts: 7
Joined: Thu Feb 28, 2019 9:11 am

SSH access to default Gateway (Mikrotik) thru secondary gateway (non Mikrotik) port forwarding

Tue Oct 01, 2019 5:16 pm

Hi,

i’m a novice in Mikrotik router configuration, i need to access my Mikrotik default Gateway, using SSH thru another router with 22 port forwarding. Mikrotik (default gateway) and Fritz (secondary gateway are both connected in LAN.

Port forwarding works but i think that replay to the traffic goes to default gateway and not to secondary,

Someone has a solution?

Thanks a lot
Manu
 
Zacharias
Forum Guru
Forum Guru
Posts: 3459
Joined: Tue Dec 12, 2017 12:58 am
Location: Greece

Re: SSH access to default Gateway (Mikrotik) thru secondary gateway (non Mikrotik) port forwarding

Tue Oct 01, 2019 6:25 pm

You don't need to port forward anything. They are just two directly connected routers.
If you want to access a router behind another router then use its wan IP.
As simple as that.
 
immateriale
just joined
Topic Author
Posts: 7
Joined: Thu Feb 28, 2019 9:11 am

Re: SSH access to default Gateway (Mikrotik) thru secondary gateway (non Mikrotik) port forwarding

Tue Oct 01, 2019 7:47 pm

Sorry, but i need to connect via ssh to router2 when router1 pppoe hang-up, so i've opened on router2 2222 ext-port to 22 int-port on router1,
i do ssh to router2 ip port:2222, i'm expecting to go via terminal to router1 and perform a reboot or other troubleshooting operation,

bur as it is, it didn't work,

can you help me?

BR
You don't need to port forward anything. They are just two directly connected routers.
If you want to access a router behind another router then use its wan IP.
As simple as that.
 
Zacharias
Forum Guru
Forum Guru
Posts: 3459
Joined: Tue Dec 12, 2017 12:58 am
Location: Greece

Re: SSH access to default Gateway (Mikrotik) thru secondary gateway (non Mikrotik) port forwarding

Tue Oct 01, 2019 8:19 pm

Just use the WAN IP of the router you want to SSH to. As i already told you , they are directly connected routers. No need to portforward anything.
 
immateriale
just joined
Topic Author
Posts: 7
Joined: Thu Feb 28, 2019 9:11 am

Re: SSH access to default Gateway (Mikrotik) thru secondary gateway (non Mikrotik) port forwarding

Tue Oct 01, 2019 11:04 pm

Sorry, i can’t be able to explain what i need:
the only one time i needed to access router1 from ssh PF of router2, the router1 PPPoE was offline, i don’t know why, so i tried to reach it from Lan, from the router2. From the smartphone i configured the PF on router2, and so i tried to SSH in router1 lan IP from router2 IP 2222 port, but without success,

Ok?

Just use the WAN IP of the router you want to SSH to. As i already told you , they are directly connected routers. No need to portforward anything.
 
Sob
Forum Guru
Forum Guru
Posts: 9121
Joined: Mon Apr 20, 2009 9:11 pm

Re: SSH access to default Gateway (Mikrotik) thru secondary gateway (non Mikrotik) port forwarding

Thu Oct 03, 2019 3:57 am

Port forwarding works but i think that replay to the traffic goes to default gateway and not to secondary,
It needs a little help from you. You need another default route via second gateway, in different routing table. Then you have to mark incoming connections from there. Either by incoming interface, if second gateway is connected to dedicated one. Or by source MAC address if both are in same subnet. And then you just mark routing for outgoing packets belonging to marked connections.

If you have no idea what I mean, check https://wiki.mikrotik.com/wiki/Manual:PCC. It's about something else (so don't try to blindly use it as whole), but it does contain what I describe, marking some connections and then marking routing for responses. Try to understand it and I think you'll get it.
 
immateriale
just joined
Topic Author
Posts: 7
Joined: Thu Feb 28, 2019 9:11 am

Re: SSH access to default Gateway (Mikrotik) thru secondary gateway (non Mikrotik) port forwarding

Fri Oct 04, 2019 12:16 pm

Port forwarding works but i think that replay to the traffic goes to default gateway and not to secondary,
It needs a little help from you. You need another default route via second gateway, in different routing table. Then you have to mark incoming connections from there. Either by incoming interface, if second gateway is connected to dedicated one. Or by source MAC address if both are in same subnet. And then you just mark routing for outgoing packets belonging to marked connections.

If you have no idea what I mean, check https://wiki.mikrotik.com/wiki/Manual:PCC. It's about something else (so don't try to blindly use it as whole), but it does contain what I describe, marking some connections and then marking routing for responses. Try to understand it and I think you'll get it.
Solved! Thanks for your help, i marked connection in prerouting chain, marked routing in prerouting and output chains and finally set a new route for that routing mark and it works!

Who is online

Users browsing this forum: gigabyte091, majestic and 208 guests