This is a routing issue.
Both routers provide access to the Internet. Hosts on the local network can use either router, but since outgoing traffic is NATed behind the public IP address of the router in question, any give host on the inside must choose one or the other; alternating between routers will not work due to NAT.
You've forwarded a port on Router 1 to the CentOS server, and it works. This means the server must be using Router 1 as its gateway. When you tried forwarding a port from Router 2 to the same server, it didn't work, as the server attempted to send replies via Router 1.
There are several ways to make this work, none of which very elegant or simple.
- You can have Router 2 and/or Router 1 perform source NAT for all inbound traffic. That way, the requests will seem to originate from the router itself rather than from an Internet host, and the server will reply directly to the Router's local address. Not all routers are able to do this, and it means extra work for the router as it has to keep track of an extra set of NAT entries. Also, all access logs on the local web/mail server becomes useless, as the only logged IP address will be that of the router.
- You can set up to separate IP networks, one for each router, and put an extra NIC in the server. By binding the service on the server to a specific IP address and setting up policy routing, you can force traffic to use a specific gateway based on the source IP address of the packet.
- You can replace Router 1 and Router 2 with a single router that supports multiple NATed WAN connections (such beasts do exist).
However, the ideal solution would be to eliminate the need for two NATed connections. Why does this organization have two Internet connections in the first place?