I have a web server with installation of Cent OS 5.6, cPanel/WHM. Currently the server have 2 ethernet and the configuration for both is listed below:
--------------------------------------------------------------
| IP | Subnet Mask | Gateway
--------------------------------------------------------------
eth0 | XXX.XX.XXX.150 | 255.255.255.252 | XXX.XX.XXX.149
--------------------------------------------------------------
eth1 | 192.168.86.2 | 255.255.255.252 | 192.168.86.1
--------------------------------------------------------------
Current default route is eth1 with gateway 192.168.86.1
Now what I need is to set eth0 as a default route for all connection except for 3 IPs (10.10.6.2, 10.10.6.3 and 10.10.6.4). I also need to set route for those 3 IPs from eth1.
eth0 is connected to optical fiber for internet connection whereas eth1 is connected to a DSL router for intranet connection
so can anyone help me to set this properly and permanently?
There are a few things you need to configure. First of all, a router attached to the 192.168.86.2/30 interface must be configured to route traffic destined for this network to it. Assuming you're in some hosted environment where this has already been completed, you only have to configure the routing table on the server.
You can specify a default route for all traffic in
/etc/sysconfig/network
by setting the GATEWAY option:Next, you'll need custom routing for the IPs you specified. You do this with the
/etc/sysconfig/network-scripts/route-eth1
file by adding:(I'm making the assumption that the router listed as 'Gateway' next to eth1 will get you there, of course.)
You should be able to restart networking (
service network restart
) and verify the routing table withroute -n
.