iButterfly
V2EX  ›  问与答

工作平台转 Linux,防火墙怎么弄(≧﹏ ≦)

  •  
  •   iButterfly · Jun 12, 2014 · 4457 views
    This topic created in 4527 days ago, the information mentioned may be changed or developed.
    想默认不允许访问网络,特定程序加端口允许联网。
    iptables好像是针对IP加端口而不是程序。
    怎么弄?
    12 replies  •  2014-07-08 11:50:40 +08:00
    kafkakevin
    kafkakevin
    Jun 12, 2014
    1
    有一个叫 tcp wrapper的东西,不过只支持一部分程序
    参考
    http://linux.vbird.org/linux_server/0250simple_firewall.php#tcp_wrappers_program
    initialdp
    initialdp
    Jun 12, 2014❤️1
    2
    如果是ubuntu的话,用ufw,简单又方便。
    tamamaxox
    tamamaxox
    Jun 12, 2014
    3
    我觉得iptables真心适合你的需求,既然你都要用linux的话
    xunyu
    xunyu
    Jun 12, 2014
    4
    iptables足以
    lang1pal
    lang1pal
    Jun 12, 2014
    5
    条件允许的话弄一个物理防火墙
    ceyes
    ceyes
    Jun 12, 2014
    6
    把默认的policy 都设成drop,然后开放几个端口即可。

    这是我workstation 的 配 iptables 脚本,稍改一下就能满足你的需求吧。
    https://gist.github.com/ceyes/a3686796ef5980a2cbe9#file-firewall-sh
    rrfeng
    rrfeng
    Jun 12, 2014
    7
    lz 问的是限制出,iptables 还真没法区分应用 。
    RainFlying
    RainFlying
    Jun 12, 2014
    8
    iptables -P OUTPUT DROP // 非常危险
    iptables -m owner 不过 owner module 里非常有用的 ——-cmd-owner 选项已经没了。
    wzxjohn
    wzxjohn
    Jun 12, 2014
    9
    @RainFlying 你说的是6楼的脚本么?没看到这句啊。。。
    RainFlying
    RainFlying
    Jun 12, 2014
    10
    @wzxjohn 6 楼脚本是设置默认策略然后开了一些端口。老版本的 iptables 有一个 owner 模块,可以用来匹配程序名,比如 --cmd-owner httpd 用来匹配 httpd .
    rhwood
    rhwood
    Jun 12, 2014
    11
    可以看一下csf,比iptables容易理解和操作。至于要限定程序有点难,可能得考虑曲线方式
    iButterfly
    iButterfly
    OP
    Jul 8, 2014
    12
    看来Linux下没有太完美的解决方法- -
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1406 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 54ms · UTC 20:48 · PVG 04:48 · LAX 12:48 · JFK 15:48
    ♥ Do have faith in what you're doing.