I am working in a host in LAN segment of 192.168.148.X with subnet mask The LAN should be configured to use as default gateway. What I normally do is to issue following route commands

route add dev eth0

route add default gw dev eth0

to produce a routing table like this

enter image description here

But the problem is every time it boots up I have to issue the command manually. How to add those rules in network configuration?

My host is running with CentOS 6.6 X86_64

2 Answers 2


You'll need to add something like the following to your /etc/sysconfig/network-scripts/route-eth0 on CentOS:

 default via dev eth0

You set it with that method if you want to override, or don't already have a default setting in /etc/sysconfig/network, which has a slightly different syntax, as such:


Either method will work, but the first example provides you with additional layers of granular control.

After that, you need to restart your networking services. One method of doing so is to reboot your machine, while another is simply to issue the following as root:

service network restart

You can check by trying to ping a machine on another network like ping -c1 or by examining your routing tables with one of the following commands:

ip route show, or route -n, or netstat –nr


You will always have a default router on the same network on which the machine sits. It is where any non-local traffic is sent, to be forwarded somewhere else. Through that default traffic reaches another network, from which t might be forwarded further (but where to send it is a decision reserved to that remote network, it is no business of the local machine).

Your local network might have several connections to other networks, in which case you'll have routes through each of the connections, one of them (the one that leads "outwards" to the Internet) will be designed "default".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .