0

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

route add 192.168.128.1/32 dev eth0

route add default gw 192.168.128.1 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

0

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

 default via 192.168.128.1 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:

GATEWAY=192.168.128.1

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 8.8.8.8 or by examining your routing tables with one of the following commands:

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

| improve this answer | |
0

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".

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.