≡ Menu

CentOS Add Route Command

How do I add route (router IP to my Centos Linux systems from the command line?

You need to use the route command or ip command to add a new route to your kernel routing table.

  • route command – show / manipulate the IP routing table
  • ip command – show / manipulate routing, devices, policy routing and tunnels

To add default gateway IP using eth0, enter:
# route add default gw eth0
And ip command can be used as follows
# ip route add dev eth0
Edit /etc/sysconfig/network and make route persistence after reboot:
# vi /etc/sysconfig/network
Add / edit GATEWAY line as follows

Further readings:

Share this tutorial on:
{ 2 comments… add one }
  • Rizwan April 29, 2013, 3:28 am

    Bundle of Thanks

  • Nick August 3, 2016, 6:46 am

    # ip route add dev eth0
    It’s not correct for Centos 6.8, because add not default route

    But this is OK
    # ip route add via dev eth0

Security: Are you a robot or human?

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: , , , , , , , , , , , , ,