LINUX.ORG.RU

История изменений

Исправление beastie, (текущая версия) :

нет Девид Блейн, лучше не надо таких фокусов

давай сравним: (нагло выдранно из линка сверху)

JunOS filter:

firewall {
    filter incoming_traffic {
        term WWW {
            from {
                destination-address {
                    192.168.1.7/32;
                }
                protocol tcp;
                destination-port [ 80 443 ];
            }
            then accept;
        }
        term SSH {
            from {
                source-address {
                    192.168.2.1/32;
                    192.168.2.2/32;
                }
                destination-address {
                    192.168.1.0/28;
                }
                protocol tcp;
                destination-port 22;
            }
            then accept;
        }
        term 8319 {
            from {
                source-address {
                    192.168.2.1/32;
                }
                destination-address {
                    192.168.1.0/28;
                }
                protocol tcp;
                destination-port 8319;
            }
            then accept;
        }
        term 443_5900 {
            from {
                source-address {
                    192.168.2.3/32;
                    192.168.2.4/32;
                }
                destination-address {
                    192.168.1.0/28;
                }
                protocol tcp;
                destination-port [ 443 5900 ];
            }
            then accept;
        }
        term established {
            from {
                tcp-established;
            }
            then {
                count established;
                accept;
            }
        }
        term DNS {
            from {
                source-address {
                    8.8.8.8/32;
                    8.8.4.4/32;
                }
                protocol udp;
                source-port 53;
            }
            then {
                count DNS;
                accept;
            }
        }
        term other {
            then discard;
        }
    }
    filter outgoing_traffic {
        term 192.168.2.5 {
            from {
                source-address {
                    192.168.1.7;
                }
            destination-address {
                 192.168.2.5/32
            }
            then {
                discard
            }
        }
    }
}

versus

OpenBSD PF:

skip on lo
block in quick
pass in proto tcp to 192.168.1.7 port { http, https }
pass in proto tcp from { 192.168.2.1, 192.168.2.2 } to 192.168.1.0/28 port ssh
pass in proto tcp from 192.168.2.1 to 192.168.1.0/28 port 8319
pass in proto tcp from { 192.168.2.3, 192.168.2.4 } to 192.168.1.0/28 port { https, 5900 }
pass in proto udp from { 8.8.8.8, 8.8.4.4 } port domain
block out from 192.168.1.7 to 192.168.2.5

PS: в pf отдельно «established» или как его там не нужен, ибо «keep state» для tcp включён по дефаулту

ну и для полной картины уродец iptables:

-P INPUT DROP
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -d 192.168.1.7 -m multiport --dports 80,443 -j ACCEPT
-A INPUT -p tcp -s 192.168.2.1 -d 192.168.1.0/28 -dport 22 -j ACCEPT
-A INPUT -p tcp -s 192.168.2.2 -d 192.168.1.0/28 -dport 22 -j ACCEPT
-A INPUT -p tcp -s 192.168.2.1 -d 192.168.1.0/28 -dport 8319 -j ACCEPT
-A INPUT -p tcp -s 192.168.2.3 -d 192.168.1.0/28 -m multiport -dports 443,5900 -j ACCEPT
-A INPUT -p tcp -s 192.168.2.4 -d 192.168.1.0/28 -m multiport -dports 443,5900 -j ACCEPT
-A INPUT -p udp -s 8.8.8.8 -dport 53 -j ACCEPT
-A INPUT -p udp -s 8.8.4.4 -dport 53 -j ACCEPT
-A OUTPUT -p tcp -s 192.168.1.7 -d 192.168.2.5 -j DROP

Исходная версия beastie, :

нет Девид Блейн, лучше не надо таких фокусов

давай сравним: (нагло выдранно из линка сверху)

JunOS filter:

firewall {
    filter incoming_traffic {
        term WWW {
            from {
                destination-address {
                    192.168.1.7/32;
                }
                protocol tcp;
                destination-port [ 80 443 ];
            }
            then accept;
        }
        term SSH {
            from {
                source-address {
                    192.168.2.1/32;
                    192.168.2.2/32;
                }
                destination-address {
                    192.168.1.0/28;
                }
                protocol tcp;
                destination-port 22;
            }
            then accept;
        }
        term 8319 {
            from {
                source-address {
                    192.168.2.1/32;
                }
                destination-address {
                    192.168.1.0/28;
                }
                protocol tcp;
                destination-port 8319;
            }
            then accept;
        }
        term 443_5900 {
            from {
                source-address {
                    192.168.2.3/32;
                    192.168.2.4/32;
                }
                destination-address {
                    192.168.1.0/28;
                }
                protocol tcp;
                destination-port [ 443 5900 ];
            }
            then accept;
        }
        term established {
            from {
                tcp-established;
            }
            then {
                count established;
                accept;
            }
        }
        term DNS {
            from {
                source-address {
                    8.8.8.8/32;
                    8.8.4.4/32;
                }
                protocol udp;
                source-port 53;
            }
            then {
                count DNS;
                accept;
            }
        }
        term other {
            then discard;
        }
    }
    filter outgoing_traffic {
        term 192.168.2.5 {
            from {
                source-address {
                    192.168.1.7;
                }
            destination-address {
                 192.168.2.5/32
            }
            then {
                discard
            }
        }
    }
}

versus

OpenBSD PF:

skip on lo
block in quick
pass in proto tcp to 192.168.1.7 port { http, https }
pass in proto tcp from { 192.168.2.1, 192.168.2.2 } to 192.168.1.0/28 port ssh
pass in proto tcp from 192.168.2.1 to 192.168.1.0/28 port 8319
pass in proto tcp from { 192.168.2.3, 192.168.2.4 } to 192.168.1.0/28 port { https, 5900 }
pass in proto udp from { 8.8.8.8, 8.8.4.4 } port domain
block out from 192.168.1.7 to 192.168.2.5

PS: в pf отдельно «established» или как его там не нужен, ибо «keep state» для tcp включён по дефаулту

ну и для полной картины уродец iptables:

-P INPUT DROP
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -d 192.168.1.7 -m multiport --dports 80,443 -j ACCEPT
-A INPUT -p tcp -s 192.168.2.1 -d 192.168.1.0/28 -dport 22 -j ACCEPT
-A INPUT -p tcp -s 192.168.2.2 -d 192.168.1.0/28 -dport 22 -j ACCEPT
-A INPUT -p tcp -s 192.168.2.1 -d 192.168.1.0/28 -dport 8319 -j ACCEPT
-A INPUT -p tcp -s 192.168.2.3 -d 192.168.1.0/28 -m multiport -dports 443,5900 -j ACCEPT
-A INPUT -p udp -s 8.8.8.8 -dport 53 -j ACCEPT
-A INPUT -p udp -s 8.8.4.4 -dport 53 -j ACCEPT
-A OUTPUT -p tcp -s 192.168.1.7 -d 192.168.2.5 -j DROP