How to add ip route to route traffic through interface when destination is also that interface
Solution 1:
You have access deny
error which means that the routing works well.
Routing doesn't change source or destination ip addresses in ip packets. Use firewall to disallow access to postgres database on 192.168.1.2
ip address. When postgress client connect to your server's 192.168.1.3
ip address it use first ip address 192.168.1.2
on server's interface. This address doesn't allowed in pg_hba.conf
config file.
Also this network scenario isn't good because postgres and other software will answer from first ip address (which are in one network) on ens4
interface.
You don't need to add such routing rules, because all ip address in them are in one network 192.168.1.0/24
.