Search code examples
linuxnetwork-programmingamazon-ec2routesip

How to set routes on a linux EC2


how do I set the below values in linux?

I'm able to set destination and gateway, but I can't find anything in the docs RE passing a flag for genmask, flags, metric, ref, use or Iface.

Can anyone provide the value to pass? I've been able to construct the below

sudo route add -net 0.0.0.0 gw 192.168.96.0 tun0

But I need the full command to add the below;

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.96.0    0.0.0.0         UG    0      0        0 eth0

Thanks


Solution

  • In this case, I'd suggest using the ip route command. It's a more modern way of managing routes on Linux.

    e.g.,: sudo ip route add default via 192.168.96.0 dev eth0 metric 0

    Flags, Ref and Use are automatically determined and setting them manually makes little sense.