bin bash IPTABLES sbin iptables MAIL_PORT 25 UNLIM_IF eth1 PAY_IF eth2

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
IPTABLES="/sbin/iptables"
MAIL_PORT="25"
UNLIM_IF="eth1"
PAY_IF="eth2"
UNLIM_IP=`ifconfig $UNLIM_IF | awk '/inet addr:/{sub("addr:", "", $2); print $2}'`
PAY_IP=`ifconfig $PAY_IF | awk '/inet addr:/{sub("addr:", "", $2); print $2}'`
echo 1 > /proc/sys/net/ipv4/ip_forward
modprobe ip_tables
modprobe ipt_helper
modprobe ip_conntrack
modprobe ip_conntrack_ftp
modprobe ip_conntrack_irc
modprobe iptable_nat
modprobe ip_nat_ftp
modprobe ip_nat_irc
modprobe ip_gre
modprobe ip_nat_pptp
$IPTABLES -P INPUT ACCEPT
$IPTABLES -P OUTPUT ACCEPT
$IPTABLES -P FORWARD ACCEPT
$IPTABLES -F
$IPTABLES -X
$IPTABLES -t nat -F
$IPTABLES -t nat -A PREROUTING -p tcp -d $UNLIM_IP --dport $MAIL_PORT -j DNAT --to-destination ${PAY_IP}:${MAIL_PORT}
$IPTABLES -A FORWARD -i $UNLIM_IF -d $PAY_IP -p tcp --dport $MAIL_PORT -j ACCEPT