TiTex wrote10.37.0.0/24 is the subnet allocated to VPN clients conneting to VPNServer2 ?
If that's the case you could do something like this for a firewall rule
iptables -I FORWARD 1 -s 10.37.0.0/24 ! -d 192.168.1.5 -j DROP
which translates to drop the connection if the source is 10.37.0.0/24 and the destination is not 192.168.1.5 and add it as the first rule in the FORWARD chain, i have not specified the port ... it's better to take small steps in solving an issue
Your initial statement is true. I have now finalised that VM at port 5902. My problem is that I do not know what am I doing, so adding ports is a problem 🙁 I will learn iptables in detail as my next task but that can not be a quick job.
So, to replace my two rules which seem to work acceptably toward my VM server (only the router where the VPN2server is actually located can be accessed from VPN but that is not an issue)
iptables -I FORWARD -s 10.37.0.0/24 -j DROP
iptables -I FORWARD -s 10.37.0.0/24 -d 192.168.1.5 -p tcp --dport 5902 -j ACCEPT
Help shows negations are acceptable. If I enter, this is accepted by my router:
iptables -I FORWARD 1 -s 10.37.0.0/24 ! -d 192.168.1.5 -j DROP
But, when I try adding the port which is crucial (as I am using port 5900 for my own VM as the PC):
iptables -I FORWARD 1 -s 10.37.0.0/24 ! -d 192.168.1.5:5902 -j DROP
it is wrong and the router complains:
iptables v1.4.14: host/network `192.168.1.5:5902' not found
Or should it be like:
iptables -I FORWARD 1 -s 10.37.0.0/24 ! -d 192.168.1.5 ! -p tcp --dport 5902 -j DROP
Should that line be correct? Help on my router does not even mention --dport arg but it looks I can not use it without -p prior to it. When I run this last rule, I get response:
# iptables -I FORWARD 1 -s 10.37.0.0/24 ! -d 192.168.1.5 ! -p tcp --dport 5902 -j DROP
iptables: Invalid argument. Run `dmesg' for more information.
# dmesg | tail -n1
x_tables: ip_tables: tcp match: only valid for protocol 6
Just curious: Is it better if I use -i tun22 instead of -s 10.37.0.0/24 or is that not relevant? Both are the same VPNserver2. Shorter is better and more readable. So, if I can improve and learn, I am all for it 🙂
Problem is I can not fully test setup at my convenience but theirs.