I have a vyos router where i want to configure the DNAT rules to access the ubuntu server which is behind the vyos router from my local host (computer outside).
Local host ip 192.168.18.10
ubuntu server Behind vyos connected - 172.16.10.2
topology
local host ------> router vyos —> ubuntu server
Vyos DNAT rule i added
set nat destination rule 1 destination address ‘172.16.10.2’
set nat destination rule 1 destination port ‘22’
set nat destination rule 1 inbound-interface ‘eth1’
set nat destination rule 1 protocol ‘tcp’
set nat destination rule 1 source address ‘192.168.18.10’
set nat destination rule 1 translation address ‘172.16.10.2’
interfaces in vyos:
outside interface : eth0
inside interface : eth1 (Ubuntu server connected)
I can’t access the Ubuntu server from my local machine. Is anything is missing from my side ?
You may have connected to port 22 of the vyos router.
Try configuring a different port for the ssh connection. For example: connect to port 222 and nat translate it to port 22 of ubuntu server.
Configuration:
set nat destination rule 1 destination address 192.168.18.131
set nat destination rule 1 destination port 222
set nat destination rule 1 inbound-interface eth1
set nat destination rule 1 protocol tcp
set nat destination rule 1 translation address 172.16.10.2
set nat destination rule 1 translation port 22
Command to connect: ssh ubuntu@192.168.18.131 -p 222
Is this possible to apply a dnat rule in vyos which have 2 VM ubuntu machine.
like
interface - eth1 (172.16.20.1/24)
Ubuntu1 172.16.20.12
Ubuntu2 172.16.20.13
How i ssh these two Ubuntu vm by other network?
Is following configuration for ssh is fine ?
I have configured rules
set nat destination rule 1 destination address ‘192.168.18.132/32’
set nat destination rule 1 destination port ‘223’
set nat destination rule 1 inbound-interface ‘eth1’
set nat destination rule 1 protocol ‘tcp’
set nat destination rule 1 translation address ‘172.16.20.12’
set nat destination rule 1 translation port ‘22’
set nat destination rule 2 destination address ‘192.168.18.132/32’
set nat destination rule 2 destination port ‘222’
set nat destination rule 2 inbound-interface ‘eth1’
set nat destination rule 2 protocol ‘tcp’
set nat destination rule 2 translation address ‘172.16.20.13’
set nat destination rule 2 translation port ‘22’