How Do I Add a Static Route in CentOS
-
@hobbit666 said in Random Thread - Anything Goes:
How do I add a Static route to CentOS to a specific IP/Host but leave the reminder "network" as is?
E.g. I want to ping a host on 192.168.16.254 via a router on 10.0.1.242 BUT the rest of the network needs to ping via 10.0.1.220 (which is the default gateway on the server)ip route add 192.168.16.254/32 via 10.0.1.242 dev eth0
You might be able to drop the /32 because you've already specified an exact host, but I'm not sure on Linux routing command.
-
@dashrender said in Random Thread - Anything Goes:
@hobbit666 said in Random Thread - Anything Goes:
How do I add a Static route to CentOS to a specific IP/Host but leave the reminder "network" as is?
E.g. I want to ping a host on 192.168.16.254 via a router on 10.0.1.242 BUT the rest of the network needs to ping via 10.0.1.220 (which is the default gateway on the server)ip route add 192.168.16.254/32 via 10.0.1.242 dev eth0
You might be able to drop the /32 because you've already specified an exact host, but I'm not sure on Linux routing command.
You can definitely skip the connection info, unless for some reason it is not implied.
-
Just keep getting this
RTNETLINK answers: Network is unreachable
-
Ah I can't do it as the router is on a different IP to the CentOS machine
-
@hobbit666 said in How Do I Add a Static Route in CentOS:
Ah I can't do it as the router is on a different IP to the CentOS machine
What do you mean?
-
Should of made my 1st post a bit clearer.
Server is on a VLAN 172.20.0.0/24 (CentOS Machine 172.20.0.212) with a default gateway of 172.20.0.220 (Cisco Core switch - Also 10.0.1.220 on VLAN1)
So all traffic goes to the Cisco switch and that routes to the gateway needed either the MPLS or a Draytek.
What I needed was the keep traffic going to 10.0.2.1 - 10.0.2.253 going through the default Core route,
But
10.0.2.254 going through the Draytek on 10.0.1.242. But as it's a different IP I get the error.So maybe I need to add the 172.20. VLAN as a 2nd LAN connection on the Draytek or give the CentOS machine a 2nd NIC on the VLAN1 network.
-
You can only route to your immediate router.
-
Your roting logic has to be at the point o fhte route, not earlier.
-
Got this working now by adding an adaptor to the VM on the VLAN1 network and doing some stuff with route and rules on the config of each adaptor in CentOS7
-
Did you only get any of his one VM affected?
If so, I’ll his solution is good. But if you don’t anted this for anyone looking for that network, you should add a command to the default router on the subnet in question
-
@dashrender
It's a one off issue we have. We have all 50+ Sites running of an MPLS, if something happens and we need BT to look at a line issue then we are subject to OpenReach SLA's. So while they are down most stores have monitored CCTV on a separate BB line, so we use this as a temp VPN connection to a Draytek here that is on a different sub net range to my VM infrastructure. So when they are using the VPN and the route has been changed on the Core switch zabbix can't ping the MPLS Cisco router as the route now goes through the Draytek. So I need to static the route through the MPLS router so zabbix tells me the connection is up once BT have visited.