When to use static route on server?

Hi guys,

sorry for asking noob question.

When do we really need to add a static route on the server?
I encounter this situation whereby a client trigger a network packet to the destination but the destination does not know how to return the traffic back to the client (source).
The issue was resolved after adding a static route at the destination server.

Ain't it suppose to be the gateway job to redirect traffic to other subnet gateways?

Thanks in advance.

Hello, I hope it's not too late. I thought I was going to go deeply into the network layers, and so on, but as always, wikipedia has better words than me and my poor English. Please read this short article and let us know if this is insufficient.

Hi sysgate,

thanks for the link.

However, it only mentioned to do it on the route.
What about my case which happened to be a server?

Thanks in advance.

I thought the original question is a general one, namely : "When do we really need to add a static route on the server?" - hence the wikipedia article. If in your case you have packet loss between client and server software, you should rather debug at network level with tcpdump or other packet traffic / sniffing instrument. If that's not the case, please describe the situation more clearly.

Your server needs to have a valid route back to a client whenever you want communication to occur between the two devices.

Your servers and hosts have routing tables which tell them where to send packets that *they* create, just like gateway devices use routing tables to forward other devices' traffic (and also for traffic the gateways create themselves). A gateway could forward a packet just fine, but if your server does not have a valid route, your server will never send the packet to the gateway in the first place. Type "ip route" at the command line to see the kernel IP routing table.

The most common static route you'll have on a server or a client is the default route. A default route tells a host to send all packets that do not match any other routes to a particular destination. This saves you from setting static routes to every host or network you want your server to be able to reply to; it covers everything in one route table entry. To set a default route, you can use the command:

ip route add default dev <interface> via <next hop IP address>