I have a WAN router which is linked to isp over a /30
WAN subnet. But it also servers as a router to a /29
local public WAN subnet which is connected to few of my servers. The traffic from /29
gets routed to ISP via /30
subnet. For a wired reason I want to masqarade (NAT) the interface which has /30
ip. So the interface with /30
ip should appear as masquaraded for my 192.168.1.0/24
network and it also should act as a normal non-NAT router for my WAN public subnet /29
. Can this be done with iptables on a Linux machine?
EDIT1: How my firewall rules are at present:
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
#WAN Security
iptables -A INPUT -d 1.2.3.3 -m state --state INVALID -j DROP
iptables -A INPUT -d 1.2.3.3 -m state --state ESTABLISHED,RELATED -j ACCEPT
#NAT
iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth0 -j SNAT --to-source 1.2.3.3
#FORWARD
iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT
iptables -A INPUT -d 1.2.3.3 -j DROP