Hi there, I'm having a trouble with my NAT box. Here is the code i'm using now...
#!/bin/bash
# Script for iptables NAT and port forwarding
# Ext IF = eth0, WAN IP = X.X.X.X
# Int IF = eth1, LAN IP range = a.a.a.a/24
# Here is the NAT Table
# Soucre Dest Remarks
# LAN 0/0 Let them go to 0/0
# 0/0:25 a.a.a.b:25 Let the ppl access the mail server
#
# Deleting and flushing the default and existing chains.
iptables -F
iptables -t nat -F
iptables -X
# Setting the counters to zero
iptables -Z
iptables -t nat -Z
# The default important rules, blocking malicious ports
iptables -A INPUT -p tcp -m multiport --destination-port 111,135,139,199,445,587,593,631,4444,6000 -j DROP
iptables -A INPUT -p udp -m multiport --destination-port 69,135,137,138 -j DROP
# Setting up for Port forwarding
iptables -t nat -A PREROUTING -p tcp -i eth0 -d X.X.X.X. --dport 25 -j DNAT --to a.a.a.b:25
iptables -t nat -A PREROUTING -p tcp -i eth0 -d X.X.X.X --dport 110 -j DNAT --to a.a.a.b:110
iptables -t nat -A PREROUTING -p tcp -i eth0 -d X.X.X.X --dport 80 -j DNAT --to a.a.a.b:80
iptables -t nat -A PREROUTING -p tcp -i eth0 -d X.X.X.X --dport 443 -j DNAT --to a.a.a.b:443
iptables -A FORWARD -p tcp -i eth0 -d a.a.a.b -j ACCEPT
# Some rules important
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -m state --state NEW -i ! eth0 -j ACCEPT
# Setting NAT for local users
iptables -A FORWARD -i eth0 -o eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to X.X.X.X
#iptables -A FORWARD -i eth0 -o eth0 -j DROP
# Saving and restarting iptables
service iptables save
service iptables restart
# End of codes...
Now here is my questions and problems... With this, I can make my servers behind the NAT and it works fine. One thing I can not do... If I type webmail.mydomain.com from my desktop (That is behind the NAT too), I can't connect. I need to use the LAN ip to connect. My DNS server is out of the LAN. And I do not want to use any other DNS except it. I have no chance to config any DNS for the LAN. Now what can I do??
Please somebody give me a suggestion...
