Привет всем!
есть два интерфеса в Инет ppp0 и pentanet0
как запрос отправить по ppp0, а прием сделать по pentanet0
вот мой файл.
#!/bin/sh
INET_IP="195.5.7.246"
INET_IFACE="ppp0"
INET_BROADCAST="195.5.255.255"
INET_IP_1="192.168.189.2"
INET_IFACE_1="pentanet0"
INET_BROADCAST_1="255.255.255.255"
LAN_IP="192.168.1.1"
LAN_IP_RANGE="192.168.1.0/16"
LAN_BROADCAST_ADDRESS="192.168.255.255"
LAN_IFACE="eth0"
#PPP
PPP_IP="10.0.0.1"
PPP_IP_RANGE="10.0.0.1/10"
PPP_IFACE="ppp1"
# 1.4 Localhost Configuration.
LO_IFACE="lo"
LO_IP="127.0.0.1"
# 1.5 IPTables Configuration.
IPTABLES="/sbin/iptables"
# Needed to initially load modules
#/sbin/depmod -a
# 3.1 Required proc configuration
echo "1" > /proc/sys/net/ipv4/ip_forward
# 4.1.1 Set policies
$IPTABLES -P INPUT DROP
$IPTABLES -P OUTPUT DROP
$IPTABLES -P FORWARD DROP
# 4.1.2 Create userspecified chains
# Create chain for bad tcp packets
$IPTABLES -N bad_tcp_packets
# Create separate chains for ICMP, TCP and UDP to traverse
$IPTABLES -N allowed
$IPTABLES -N tcp_packets
$IPTABLES -N udp_packets
$IPTABLES -N icmp_packets
# 4.1.3 Create content in userspecified chains
# bad_tcp_packets chain
$IPTABLES -A bad_tcp_packets -p tcp ! --syn -m state --state NEW -j LOG \
--log-prefix "New not syn:"
$IPTABLES -A bad_tcp_packets -p tcp ! --syn -m state --state NEW -j DROP
# allowed chain
$IPTABLES -A allowed -p TCP --syn -j ACCEPT
$IPTABLES -A allowed -p TCP -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A allowed -p TCP -j DROP
# ICMP rules
$IPTABLES -A icmp_packets -p ICMP -s 0/0 --icmp-type 8 -j ACCEPT
$IPTABLES -A icmp_packets -p ICMP -s 0/0 --icmp-type 11 -j ACCEPT
# 4.1.4 INPUT chain
# Bad TCP packets we don't want.
$IPTABLES -A INPUT -p tcp -j bad_tcp_packets
#ppp1
$IPTABLES -A INPUT -p ALL -i $PPP_IFACE -s $PPP_IP_RANGE -j ACCEPT
# Rules for special networks not part of the Internet
$IPTABLES -A INPUT -p ALL -i $LAN_IFACE -s $LAN_IP_RANGE -j ACCEPT
$IPTABLES -A INPUT -p ALL -i $LO_IFACE -s $LO_IP -j ACCEPT
$IPTABLES -A INPUT -p ALL -i $LO_IFACE -s $LAN_IP -j ACCEPT
$IPTABLES -A INPUT -p ALL -i $LO_IFACE -s $INET_IP -j ACCEPT
$IPTABLES -A INPUT -p ALL -i $LAN_IFACE -d $LAN_BROADCAST_ADDRESS -j ACCEPT
# Special rule for DHCP requests from LAN, which are not caught properly
# otherwise.
$IPTABLES -A INPUT -p UDP -i $LAN_IFACE --dport 67 --sport 68 -j ACCEPT
# Rules for incoming packets from the internet.
$IPTABLES -A INPUT -p ALL -d $INET_IP -m state --state ESTABLISHED,RELATED \
-j ACCEPT
$IPTABLES -A INPUT -m limit --limit 3/minute --limit-burst 3 -j LOG \
--log-level DEBUG --log-prefix "IPT INPUT packet died: "
# 4.1.5 FORWARD chain
$IPTABLES -A FORWARD -p tcp -j bad_tcp_packets
#
#General rules
#
$IPTABLES -A FORWARD -i $PPP_IFACE -o $INET_IFACE -j ACCEPT
$IPTABLES -A FORWARD -i $LAN_IFACE -o $PPP_IFACE -j ACCEPT
$IPTABLES -A FORWARD -i $PPP_IFACE -o $LAN_IFACE -j ACCEPT
# Accept the packets we actually want to forward
$IPTABLES -A FORWARD -p TCP -i $INET_IFACE -o $PPP_IFACE -d $PPP_IP --dport 3128 -j allowed
$IPTABLES -A FORWARD -i $LAN_IFACE -j ACCEPT
$IPTABLES -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
# Log weird packets that don't match the above.
$IPTABLES -A FORWARD -m limit --limit 3/minute --limit-burst 3 -j LOG \
--log-level DEBUG --log-prefix "IPT FORWARD packet died: "
# 4.1.6 OUTPUT chain
# Bad TCP packets we don't want.
$IPTABLES -A OUTPUT -p tcp -j bad_tcp_packets
# Special OUTPUT rules to decide which IP's to allow.
$IPTABLES -A OUTPUT -p ALL -s $LO_IP -j ACCEPT
$IPTABLES -A OUTPUT -p ALL -s $LAN_IP -j ACCEPT
$IPTABLES -A OUTPUT -p ALL -s $INET_IP -j ACCEPT
# Log weird packets that don't match the above.
$IPTABLES -A OUTPUT -m limit --limit 3/minute --limit-burst 3 -j LOG \
--log-level DEBUG --log-prefix "IPT OUTPUT packet died: "
# 4.2.4 PREROUTING chain
#$IPTABLES -t nat -A PREROUTING -p TCP -i $PPP_IFACE -d $PPP_IP --dport 3128 -j DNAT --to-destination $LAN_IP
$IPTABLES -t nat -A PREROUTING -p ALL -i $PPP_IFACE -d $PPP_IP -j DNAT --to-destination $LAN_IP
$IPTABLES -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 3128
$IPTABLES -t nat -A PREROUTING -p tcp --dport 21 -j REDIRECT --to-port 3128
# 4.2.5 POSTROUTING chain
$IPTABLES -t nat -A POSTROUTING -o $INET_IFACE -j SNAT --to-source $INET_IP