Question Locked

Routing a WAN IP to a LAN IP

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hello everyone, at the company I work for I have the following set up: a wireless Linksys WRT54GL access point which serves as a DHCP and network server for a bunch of desktop PCs and sometimes laptops. There is also a mail server which works both on WAN or LAN (the LAN ip is used by desktops to connect to it)

The laptops use the WAN IP for obvious reasons. My question is this:

Can I set up my Linksys router to send all the requests to the mail server's WAN IP to it's LAN IP 192.168.1.100 ? I'd like this because of much faster mail usage for the laptops obviously. I looked at the routing table but have no idea how I could set it up, some help would be much apreciated.

I should also mention the router is running Tomato 1.21

5 replies

by robo_dev

what do you mean the 'laptops use the WAN IP'?

Can you explain your topology more clearly?

When you say 'WAN IP', do you mean the IP addresses assigned from your corporate WAN DHCP servers or do you mean the public IP address assigned by your ISP?

If that is the case, why do you need a router/dhcp server?

by cardplayer

Sorry for not being too clear. By WAN ip I mean a regular public IP, which the router uses and all the laptops connecting to it use DHCP to get online, the simple classic scenario.

The mail server has another public IP on another DSL line, but also has 2 network cards and is connected to the router as well.

I want those laptops to be routed to the mail server's LAN ip when they send a request through outlook or whatever to connect to the mail server's public IP.

I guess it can be done by some DNS tweaking, the Tomato firmware on the router has DNSmasq installed but I don't know how to use it to perform that setting....

Hope all is clear now, thanks for your reply!

by jmil

maybe you should consider making a site-to-site vpn between 2 places so clients from the one side can connect directly to lan if of mail server.
Also you should allow on your mail server clients subnet so they can connect to it.

by cardplayer

Ok guys I solved it with some help from other forums, using iptables PREROUTING and POSTROUTING like this

iptables -t nat -A PREROUTING -s 192.168.1.0/24 -d 89.xxx.xxx.xxx -j DNAT --to 192.168.1.100

and

iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -d 192.168.1.100 -j SNAT --to 192.168.1.1

So now all the network clients are routed to the LAN IP of the mail server when they send a request to it's internet IP. Which is what I wanted! :) Thanks for your posts!

This discussion is closed to new replies.