Port forwarding Issue

Hello Guys!
I have an issue on my actual infrastructure, I post on this issue on photo to show my IT, the issue is I don’t know how to make port forwarding on my network. My router give 192.168.88.0/24 network and under VYOS I have 192.168.77.0/24 IP, so if I have for example one query coming on 192.168.88.10 on port 22 and I want to forward it to 192.168.77.1 for example on port 1022 so how can I forward it?

Thank you guys for help

Please refer to VyOS destination NAT docs

In your case:

set nat destination rule 10 description ‘Port Forward ssh to 192.168.77.1’
set nat destination rule 10 destination port ‘22’
set nat destination rule 10 inbound-interface ‘eth0’
set nat destination rule 10 protocol ‘tcp’
set nat destination rule 10 translation address ‘192.168.77.1’
set nat destination rule 10 translation port ‘1022’

Sure destination address is 192.168.77.1? I guess you mean IP address of some ssh servers, like 192.168.77.2 or 192.168.77.3

In My case 192.168.77.2 and 192.168.77.3 also have ssh server, so how to specify for this way? example 2022 port is use for ssh on 192.168.77.2 and 3022 for 192.168.77.3 for ssh?

Great thanks for the high response

Just add more rules, according to you needs:

set nat destination rule 20 description ‘Port Forward ssh to 192.168.77.2’
set nat destination rule 20 destination port ‘2022’
set nat destination rule 20 inbound-interface ‘eth0’
set nat destination rule 20 protocol ‘tcp’
set nat destination rule 20 translation address ‘192.168.77.2’
set nat destination rule 20 translation port ‘2022’
set nat destination rule 30 description ‘Port Forward ssh to 192.168.77.3’
set nat destination rule 30 destination port ‘3022’
set nat destination rule 30 inbound-interface ‘eth0’
set nat destination rule 30 protocol ‘tcp’
set nat destination rule 30 translation address ‘192.168.77.3’
set nat destination rule 30 translation port ‘3022’

Great thanks dude, I’ll test it and tell you :slight_smile:

Hi n.fort,
After trying add some rule, I’m facing to another issue.
In my VYOS server I’ve on eth0 192.168.88.91 and on eth1 192.168.77.254
when I add:
set nat destination rule 30 description ‘Port Forward ssh to 192.168.77.3’
set nat destination rule 30 destination port ‘22’
set nat destination rule 30 inbound-interface ‘eth0’
set nat destination rule 30 protocol ‘tcp’
set nat destination rule 30 translation address ‘192.168.77.3’
set nat destination rule 30 translation port ‘6022’
After commit & save.

I try to test telnet to 192.168.88.91 on 6022 and it say that connection is refused
Source IP 192.168.88.105, I try to get ssh on 192.168.77.3 on port 22
image

Can You help again please :slight_smile:

Hello @andoniaina , I guess you have to try to set properly translation and destination ports

set nat destination rule 30 destination port ‘6022’
set nat destination rule 30 translation port ‘22’
1 Like

Hello Dmitry,
Guy thank your comment, I don’t see that :smiley: this resolve definitively my isse and thank you very much;

One question, how can I remove all error configuration? when I commit all old error happen on the interface and say that I must do modification or any rollback?

Thanks a lot for you guys!

Hello @andoniaina ,

You can follow our KB:
https://support.vyos.io/en/kb/articles/how-to-load-the-default-configuration-2
(load, commit, save, reboot)

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.