How do I add route (router IP 192.168.1.254) 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 192.168.1.254 using eth0, enter:
# route add default gw 192.168.1.254 eth0
And ip command can be used as follows
# ip route add 192.168.1.0/24 dev eth0
Edit /etc/sysconfig/network and make route persistence after reboot:
# vi /etc/sysconfig/network
Add / edit GATEWAY line as follows
GATEWAY=192.168.1.254
Further readings:
- Red Hat / CentOS Linux Setting a Default Gateway
- CentOS / Red hat enterprise Linux 5 configure the network card
- CentOS / Red Hat Linux Static Routing Configuration
Featured Articles:
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- My 10 UNIX Command Line Mistakes
- Linux: 20 Iptables Examples For New SysAdmins

- 25 PHP Security Best Practices For Sys Admins
- The Novice Guide To Buying A Linux Laptop
- 10 Greatest Open Source Software Of 2009
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- Top 20 OpenSSH Server Best Security Practices
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Linux Video Editor Software
Facebook it - Tweet it - Print it -

