I niestety nie działa.
To mój skrypt zapory i dostęp do terminala. Za nic nie chce działać, może coś jest nie tak?
Jeśli macie jakieś sugestie odnośnie tych reguł to proszę o nie.
W ogóle to dziwna rzecz bo blokowanie po mac adresie nie działa, komputer ma dalej dostęp.
Kod: Zaznacz cały
## czyszczenie tablic
/sbin/iptables -F
/sbin/iptables -X
/sbin/iptables -F -t nat
/sbin/iptables -Z
####################### polaczenia zasady
## interfejsy
LAN0_ADDR="10.0.0.254"
LAN0_NET="10.0.0.0/24"
LAN0_DEV="eth0"
LAN1_ADDR="1.2.3.4"
LAN1_NET="1.2.3.4/255.255.255.248"
LAN1_DEV="eth1"
LAN2_ADDR="5.6.7.8"
LAN2_NET="5.6.7.8/255.255.255.252"
LAN2_DEV="eth2"
## KERNEL TUNNING
echo 1 >/proc/sys/net/ipv4/ip_forward
echo 1 >/proc/sys/net/ipv4/conf/all/rp_filter
echo 1 >/proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
echo 0 >/proc/sys/net/ipv4/conf/all/accept_source_route
echo 0 >/proc/sys/net/ipv4/icmp_ignore_bogus_error_responses
echo 1 >/proc/sys/net/ipv4/conf/all/log_martians
echo 0 >/proc/sys/net/ipv4/conf/all/accept_redirects
echo 1 >/proc/sys/net/ipv4/tcp_syncookies
echo 1 >/proc/sys/net/ipv4/tcp_timestamps
echo 0 >/proc/sys/net/ipv4/conf/all/send_redirects
##sesje
echo 30 >/proc/sys/net/ipv4/tcp_fin_timeout
echo 2400 >/proc/sys/net/ipv4/tcp_keepalive_time
echo 0 >/proc/sys/net/ipv4/tcp_window_scaling
echo 0 >/proc/sys/net/ipv4/tcp_sack
echo 20 >/proc/sys/net/ipv4/ipfrag_time
echo 1280 >/proc/sys/net/ipv4/tcp_max_syn_backlog
#### DNSY
DNS0="10.0.0.1"
DNS1="194.204.159.1"
DNS2="194.204.152.34"
DNS3="88.202.127.200"
DNS4="88.202.127.201"
####################################################################
## Domyslna polityka sieci #########################################
/sbin/iptables -P INPUT DROP
/sbin/iptables -P OUTPUT DROP
/sbin/iptables -P FORWARD DROP
####################################################################
#### INPUT
/sbin/iptables -A INPUT -p tcp -j ACCEPT -m state --state ESTABLISHED
/sbin/iptables -A INPUT -p udp -j ACCEPT -m state --state ESTABLISHED
/sbin/iptables -A INPUT -p icmp -j ACCEPT -m state --state ESTABLISHED
/sbin/iptables -A INPUT -p icmp -j ACCEPT -m state --state RELATED
#/sbin/iptables -A INPUT -m state --state INVALID -j LOG --log-prefix "INPUT DROP INVALID " --log-ip-options --log-tcp-options
#/sbin/iptables -A INPUT -m state --state INVALID -j DROP
# wykrywanie spoofingu ip adr na eth0 i odrzucanie + log
/sbin/iptables -A INPUT -i $LAN0_DEV -s ! $LAN0_NET -j LOG --log-prefix "INPUT SPOOFED PKT "
/sbin/iptables -A INPUT -i $LAN0_DEV -s ! $LAN0_NET -j DROP
#/sbin/iptables -A INPUT -j LOG --log-ip-options
#/sbin/iptables -A INPUT -i ! lo -j LOG --log-prefix "INPUT DROP " --log-ip-options --log-tcp-options
## FORWARD
/sbin/iptables -A FORWARD -p tcp -j ACCEPT -m state --state ESTABLISHED
/sbin/iptables -A FORWARD -p tcp -j ACCEPT -m state --state RELATED
/sbin/iptables -A FORWARD -p udp -j ACCEPT -m state --state ESTABLISHED
/sbin/iptables -A FORWARD -p icmp -j ACCEPT -m state --state ESTABLISHED
/sbin/iptables -A FORWARD -p icmp -j ACCEPT -m state --state RELATED
# wykrywanie spoofingu ip adr na eth0 i odrzucanie + log
/sbin/iptables -A FORWARD -m state --state INVALID -j LOG --log-prefix "FORWARD DROP INVALID " --log-ip-options --log-tcp-options
/sbin/iptables -A FORWARD -m state --state INVALID -j DROP
/sbin/iptables -A FORWARD -i $LAN0_DEV -s ! $LAN0_NET -j LOG --log-prefix "FORWARD SPOOFED PKT "
/sbin/iptables -A FORWARD -i $LAN0_DEV -s ! $LAN0_NET -j DROP
#/sbin/iptables -A FORWARD -i ! lo -j LOG --log-prefix "FORWARD DROP " --log-ip-options --log-tcp-options
## OUTPUT
/sbin/iptables -A OUTPUT -p tcp -j ACCEPT -m state --state ESTABLISHED
/sbin/iptables -A OUTPUT -p tcp -j ACCEPT -m state --state RELATED
/sbin/iptables -A OUTPUT -p udp -j ACCEPT -m state --state ESTABLISHED
/sbin/iptables -A OUTPUT -p icmp -j ACCEPT -m state --state ESTABLISHED
/sbin/iptables -A OUTPUT -p icmp -j ACCEPT -m state --state RELATED
/sbin/iptables -A OUTPUT -m state --state INVALID -j LOG --log-prefix "OUTPUT DROP INVALID " --log-ip-options --log-tcp-options
/sbin/iptables -A OUTPUT -m state --state INVALID -j DROP
## maska
/sbin/iptables -t nat -A POSTROUTING -s $LAN0_NET -o eth1 -j SNAT --to-source $LAN1_ADDR
####################################################
## RULESY DLA routera ###########################
## loopback
/sbin/iptables -A INPUT -i lo -j ACCEPT
/sbin/iptables -A OUTPUT -o lo -j ACCEPT
/sbin/iptables -A INPUT -i $LAN1_DEV -d 127.0.0.0/8 -j DROP
## broadcasty
##/sbin/iptables -A INPUT -i $LAN1_DEV -d $BROADCAST -j DROP
## dns dla routera
/sbin/iptables -A INPUT -i $LAN1_DEV -p udp -s $DNS0 --sport 53 -m state --state ESTABLISHED -j ACCEPT
/sbin/iptables -A OUTPUT -o $LAN1_DEV -p udp -d $DNS0 --dport 53 -m state --state NEW,ESTABLISHED -j ACCEPT
/sbin/iptables -A INPUT -i $LAN1_DEV -p udp -s $DNS1 --sport 53 -m state --state ESTABLISHED -j ACCEPT
/sbin/iptables -A OUTPUT -o $LAN1_DEV -p udp -d $DNS1 --dport 53 -m state --state NEW,ESTABLISHED -j ACCEPT
/sbin/iptables -A INPUT -i $LAN1_DEV -p udp -s $DNS2 --sport 53 -m state --state ESTABLISHED -j ACCEPT
/sbin/iptables -A OUTPUT -o $LAN1_DEV -p udp -d $DNS2 --dport 53 -m state --state NEW,ESTABLISHED -j ACCEPT
/sbin/iptables -A INPUT -i $LAN1_DEV -p udp -s $DNS3 --sport 53 -m state --state ESTABLISHED -j ACCEPT
/sbin/iptables -A OUTPUT -o $LAN1_DEV -p udp -d $DNS3 --dport 53 -m state --state NEW,ESTABLISHED -j ACCEPT
/sbin/iptables -A INPUT -i $LAN1_DEV -p udp -s $DNS4 --sport 53 -m state --state ESTABLISHED -j ACCEPT
/sbin/iptables -A OUTPUT -o $LAN1_DEV -p udp -d $DNS4 --dport 53 -m state --state NEW,ESTABLISHED -j ACCEPT
## www z routera na zewnatrz
/sbin/iptables -A INPUT -i $LAN1_DEV -p tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT
/sbin/iptables -A OUTPUT -o $LAN1_DEV -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
## ftp z routera na zewnatrz
/sbin/iptables -A INPUT -i $LAN1_DEV -p tcp --sport 21 -m state --state ESTABLISHED -j ACCEPT
/sbin/iptables -A OUTPUT -o $LAN1_DEV -p tcp --dport 21 -m state --state NEW,ESTABLISHED -j ACCEPT
# 1) Active ftp.
/sbin/iptables -A INPUT -i $LAN1_DEV -p tcp --sport 20 -m state --state ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables -A OUTPUT -o $LAN1_DEV -p tcp --dport 20 -m state --state ESTABLISHED -j ACCEPT
# 2) Passive ftp.
/sbin/iptables -A INPUT -i $LAN1_DEV -p tcp --sport 1024:65535 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT
/sbin/iptables -A OUTPUT -o $LAN1_DEV -p tcp --sport 1024:65535 --dport 1024:65535 -m state --state ESTABLISHED,RELATED -j ACCEPT
## traceroute
/sbin/iptables -A OUTPUT -o $LAN1_DEV -p udp --sport 32769:65535 --dport 33434:33523 -m state --state NEW -j ACCEPT
## ping
/sbin/iptables -A OUTPUT -o $LAN0_DEV -p icmp -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables -A OUTPUT -o $LAN1_DEV -p icmp -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
## ident
/sbin/iptables -A INPUT --protocol udp --source-port 113 -j DROP
/sbin/iptables -A INPUT --protocol udp --destination-port 113 -j DROP
## squid
/sbin/iptables -A INPUT -i $LAN0_DEV -p tcp --destination-port 3128 -m state --state NEW -j ACCEPT
/sbin/iptables -A OUTPUT -o $LAN1_DEV -p tcp --destination-port 80 -m state --state NEW -j ACCEPT
################################################
## Reguly dla LAN0 #############################
## dns dla lanu
/sbin/iptables -A FORWARD -p ! icmp -s $LAN0_NET -d $DNS0 -j ACCEPT
/sbin/iptables -A FORWARD -p ! icmp -s $DNS0 -d $LAN0_NET -j ACCEPT
/sbin/iptables -A FORWARD -p ! icmp -s $LAN0_NET -d $DNS1 -j ACCEPT
/sbin/iptables -A FORWARD -p ! icmp -s $DNS1 -d $LAN0_NET -j ACCEPT
/sbin/iptables -A FORWARD -p ! icmp -s $LAN0_NET -d $DNS2 -j ACCEPT
/sbin/iptables -A FORWARD -p ! icmp -s $DNS2 -d $LAN0_NET -j ACCEPT
/sbin/iptables -A FORWARD -p ! icmp -s $LAN0_NET -d $DNS3 -j ACCEPT
/sbin/iptables -A FORWARD -p ! icmp -s $DNS3 -d $LAN0_NET -j ACCEPT
/sbin/iptables -A FORWARD -p ! icmp -s $LAN0_NET -d $DNS4 -j ACCEPT
/sbin/iptables -A FORWARD -p ! icmp -s $DNS4 -d $LAN0_NET -j ACCEPT
## http dla lan
/sbin/iptables -A FORWARD -p tcp -s $LAN0_NET -d 0/0 --dport 80 -j ACCEPT
## GG, tlen
/sbin/iptables -A FORWARD -p tcp -s $LAN0_NET -d 0/0 --dport 8074 -j ACCEPT
/sbin/iptables -A FORWARD -p udp -s $LAN0_NET -d 0/0 --dport 8074 -j ACCEPT
## ftp dla lan
/sbin/iptables -A FORWARD -p tcp -s $LAN0_NET -d 0/0 --dport 21 -j ACCEPT
/sbin/iptables -A FORWARD -p tcp -s $LAN0_NET -d 0/0 --dport 20 -j ACCEPT
## terminal svr
/sbin/iptables -A FORWARD -p tcp -s $LAN0_NET -d 0/0 --dport 3389 -j ACCEPT
## squid
/sbin/iptables -t nat -A PREROUTING -s $LAN0_NET -p tcp --dport 80 -j REDIRECT --to-port 3128
###################################################################################################
## dostepy do kompow TS ############################################################
/sbin/iptables -A FORWARD -p tcp --dport 62695 -j ACCEPT
/sbin/iptables -t nat -A PREROUTING -p tcp --dport 62695 -i $LAN0_DEV -j DNAT --to 10.0.0.20:3389
################################################
## zablokowane kompy ###########################
/sbin/iptables -A INPUT -s $LAN0_NET -m mac --mac-source 00:1d:60:4f:a6:b3 -j DROP
/sbin/iptables -A FORWARD -s $LAN0_NET -m mac --mac-source 00:1d:60:4f:a6:b3 -j DROP
Dodane:
Witajcie.
Nie rozwiązałem dalej problemu z przekierowaniami usług terminalowych z zewnątrz do lokalnej sieci.
Domyślną polityką sieci jest DROP. Wycinek mojego firewalla.
Kod: Zaznacz cały
/sbin/iptables -F
/sbin/iptables -X
/sbin/iptables -F -t nat
/sbin/iptables -Z
LAN0_ADDR="10.0.0.254"
LAN0_NET="10.0.0.0/255.255.255.0"
LAN0_DEV="eth0"
LAN1_ADDR="1.2.3.4"
LAN1_NET="1.2.3.4/255.255.255.192"
LAN1_DEV="eth1"
/sbin/iptables -P INPUT DROP
/sbin/iptables -P FORWARD DROP
/sbin/iptables -P OUTPUT DROP
/sbin/iptables -A INPUT -i lo -j ACCEPT
/sbin/iptables -A OUTPUT -o lo -j ACCEPT
/sbin/iptables -A FORWARD -o lo -j ACCEPT
/sbin/iptables -A INPUT -i eth0 -j ACCEPT
/sbin/iptables -A OUTPUT -o eth0 -j ACCEPT
/sbin/iptables -A INPUT -p tcp -j ACCEPT -m state --state ESTABLISHED
/sbin/iptables -A INPUT -p udp -j ACCEPT -m state --state ESTABLISHED
/sbin/iptables -A INPUT -p icmp -j ACCEPT -m state --state ESTABLISHED
/sbin/iptables -A INPUT -p icmp -j ACCEPT -m state --state RELATED
/sbin/iptables -A FORWARD -p tcp -j ACCEPT -m state --state ESTABLISHED
/sbin/iptables -A FORWARD -p tcp -j ACCEPT -m state --state RELATED
/sbin/iptables -A FORWARD -p udp -j ACCEPT -m state --state ESTABLISHED
/sbin/iptables -A FORWARD -p icmp -j ACCEPT -m state --state ESTABLISHED
/sbin/iptables -A FORWARD -p icmp -j ACCEPT -m state --state RELATED
/sbin/iptables -A OUTPUT -p tcp -j ACCEPT -m state --state ESTABLISHED
/sbin/iptables -A OUTPUT -p tcp -j ACCEPT -m state --state RELATED
/sbin/iptables -A OUTPUT -p udp -j ACCEPT -m state --state ESTABLISHED
/sbin/iptables -A OUTPUT -p icmp -j ACCEPT -m state --state ESTABLISHED
/sbin/iptables -A OUTPUT -p icmp -j ACCEPT -m state --state RELATED
#dostęp do dns
/sbin/iptables -A OUTPUT -o $LAN1_DEV -p tcp -j ACCEPT -m state --state NEW -m multiport --destination-port 53
/sbin/iptables -A OUTPUT -o $LAN1_DEV -p udp -j ACCEPT -m state --state NEW -m multiport --destination-port 53
/sbin/iptables -A FORWARD -o $LAN1_DEV -p tcp -j ACCEPT -m state --state NEW -m multiport --destination-port 53
/sbin/iptables -A FORWARD -o $LAN1_DEV -p udp -j ACCEPT -m state --state NEW -m multiport --destination-port 53
# dla sieci z wewnątrz możliwość łączenia się z innymi terminalami
/sbin/iptables -A OUTPUT -o $LAN1_DEV -p tcp -j ACCEPT -m state --state NEW -m multiport --destination-port 3389
/sbin/iptables -A FORWARD -o $LAN1_DEV -p tcp -j ACCEPT -m state --state NEW -m multiport --destination-port 3389
# dostęp do XP wewnątrz sieci z zewnątrz(nie działa!!!!)
/sbin/iptables -t nat -A PREROUTING -p tcp --dport 13389 -j DNAT --to-destination 10.0.0.2:3389
/sbin/iptables -A FORWARD -p tcp --dport 13389 -j ACCEPT
echo 1 >/proc/sys/net/ipv4/ip_forward
I nie można się połączyć z komputerem wpisując:
jako adres w kliencie pulpitu zdalnego z zewnątrz sieci.
Wpisując tak regułę dla tego Windows XP:
Kod: Zaznacz cały
/sbin/iptables -t nat -A PREROUTING -p tcp --dport 3389 -j DNAT --to-destination 10.0.0.2:3389
/sbin/iptables -A FORWARD -p tcp --dport 3389 -j ACCEPT
Łączy się bez problemu tyle że po standardowym porcie a chcę tego uniknąć. Może mi ktoś wytłumaczyć dlaczego to nie chce działać? Czy w takim przypadku trzeba inaczej zapisać regułę?