I have a Linux server with multiple VLANs configured on it. They are like:
- VLAN1 – 10.0.0.1/26 – GW: 10.0.0.62
- VLAN2 – 10.0.0.64/26 – GW: 10.0.0.126
- VLAN3 – 10.0.0.128/26 – GW: 10.0.0.190
- VLAN4 – 10.0.0.192/26 – GW: 10.0.0.254
And each network interface has an IP from the VLAN/network shown above.
I am trying to connect to VLAN4 over the Internet and the network port has a NAT to a public IP address, for example,
184.108.40.206 -> VLAN4 IP address (
eno4 – 10.0.0.193) and it is listening on port 80.
The server is listening on port 22 only on the interface belonging to VLAN1 –
I want to be able to access TCP port 80 over the public and private IP address on
eno4 from my PC which also has a private IP
10.0.2.153 and at the same time to be able to connect over SSH to my server over
eno1 which is not exposed to the Internet.
So my understanding is that in order to make the public IP address of the server reachable from outside, I need to define a default GW via
eno4. In order to be able to connect to the SSH, I need to make a custom routing over the
VLAN1 gateway but then I won’t be able to reach any more port 80 on
eno4 because my traffic will be re-routed over the custom routing over
eno1. So my setup is something like that.
ip r add default via 10.0.0.254 dev eno4 ip r add 10.0.0.0/24 via 10.0.0.62 dev eno1
How can I make the routing table more specific and when I try to reach
eno1 over the private IP to use
GW1 and when I try to reach the private IP of
eno4 from my PC the traffic to be routed over