Ip route add example for Linux

I need to add a new route to my CentOS 7 and Ubuntu 18.04 LTS VM running inside VMWARE. I read ip man page but it confused me too much. Can anyone give me ip route add example?

Say you want to route traffic via gateway connected via eth0 network interface:

 ip route add dev eth0

Another example with gateway to add a static route:

ip route add via dev eth0

For more info see


Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki