How to DROP ip from behind NAT
Hi,
I have little network, server is connected by ADSL to internet with static IP. I`m shering connection to my two machines.
My firewall.sh
IPTAB=/usr/sbin/iptables
PIP=XXX.XXX.XXX.XXX <-ADSL MODEM IP
M1=10.1.1.1 <- LOCAL IPS
M2=10.1.1.2
M3=10.1.1.3
echo 1 > /proc/sys/net/ipv4/ip_forward
$IPTAB -F INPUT
$IPTAB -P INPUT ACCEPT
$IPTAB -F OUTPUT
$IPTAB -P OUTPUT ACCEPT
$IPTAB -F FORWARD
$IPTAB -P FORWARD ACCEPT
$IPTAB -t nat -F
$IPTAB -A FORWARD -i ppp0 -j ACCEPT
$IPTAB -A FORWARD -i eth0 -o ppp0 -j ACCEPT
$IPTAB -t nat -A POSTROUTING -o ppp0 -j SNAT --to-source $PIP -s $M2
$IPTAB -t nat -A POSTROUTING -o ppp0 -j SNAT --to-source $PIP -s $M3
$IPTAB -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128 <- for proxy
Now I want to block packets form 10.1.1.2 to IP YYY.YYY.YYY.YYY to PORT 22
and
Block all traffic on 10.1.1.3 but allow to connect IP YYY.YYY.YYY.YYY to PORT 80
I`m trying to do this but I dont know how, please help me!
---
Przemek < skyline.ltd.pl / przemek@ >
ICQ: 99511187 MSN: tommyindahla -at- hotmail.com
Quoted 25 lines · Przemek
Hi,
I have little network, server is connected by ADSL to internet with static IP. I`m shering connection to my two machines.
My
firewall.sh
IPTAB=/usr/sbin/iptables
PIP=XXX.XXX.XXX.XXX <-ADSL MODEM IP
M1=10.1.1.1 <- LOCAL IPS
M2=10.1.1.2
M3=10.1.1.3
echo 1 >/proc/sys/net/ipv4/ip_forward
$IPTAB -F INPUT
$IPTAB -P INPUT ACCEPT
$IPTAB -F OUTPUT
$IPTAB -P OUTPUT ACCEPT
$IPTAB -F FORWARD
$IPTAB -P FORWARD ACCEPT
$IPTAB -t nat -F
$IPTAB -A FORWARD -i ppp0 -j ACCEPT
$IPTAB -A FORWARD -i eth0 -o ppp0 -j ACCEPT
$IPTAB -t nat -A POSTROUTING -o ppp0 -j SNAT --to-source $PIP -s $M2
$IPTAB -t nat -A POSTROUTING -o ppp0 -j SNAT --to-source $PIP -s $M3
$IPTAB -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128 <- for proxy
Quoted 1 line
Now I want to block packets form 10.1.1.2 to IP YYY.YYY.YYY.YYY to PORT 22
can YYY.YYY.YYY.YYY be on the same network as M2 (10.1.1.2) ? if it is out on the internet, then block it in the FORWARD chain of the filter table on M1.
ps. your notation is a little confusing. perhaps use the following notation:
ip:port -> ip:port (absence of port denotes any port)
for example, what i think you meant above would be you want to block 10.1.1.2 -> YYY.YYY.YYY.YYY:22
is that correct?
Quoted 4 lines
and
Block all traffic on 10.1.1.3 but allow to connect IP YYY.YYY.YYY.YYY to PORT 80
again, i am confused. what i think you want is
allow 10.1.1.3 -> YYY.YYY.YYY.YYY:80
block everything else from 10.1.1.3
again, this would be done in the FORWARD chain of the filter table.
please verify what you want and if you need help writing the rules then we can help.
-matt zagrabelny
Quoted 7 lines · On Wed, 16 Nov 2005 15:05:57 -0600 Matt Zagrabelny <[email protected]> wrote:
can YYY.YYY.YYY.YYY be on the same network as M2 (10.1.1.2) ? if it is out on the internet, then block it in the FORWARD chain of the filter table on M1.
ps. your notation is a little confusing. perhaps use the following notation:
Quoted 6 lines
ip:port -> ip:port (absence of port denotes any port)
for example, what i think you meant above would be you want to block 10.1.1.2 -> YYY.YYY.YYY.YYY:22
is that correct?
YYY.YYY.YYY.YYY is a internet adres not at same network. I had try blocking on FORWARD but I this not work for me :(
Quoted 8 lines
again, i am confused. what i think you want is
allow 10.1.1.3 -> YYY.YYY.YYY.YYY:80
block everything else from 10.1.1.3again, this would be done in the FORWARD chain of the filter table.
please verify what you want and if you need help writing the rules then we can help.
Correct but YYY.YYY.YYY.YYY is outside of this network... I try:
iptables -A FORWARD -s 10.1.1.3 -j DROP
iptables -A FORWARD -s 10.1.1.3 -d 217.217.217.100 --dport 80 - j ACCEPT
but I can still access anything :(
---
Przemek < skyline.ltd.pl / przemek@ >
ICQ: 99511187 MSN: tommyindahla -at- hotmail.com