CentOS7 下可以限制出站流量吗? - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
baalchina
V2EX    Linux

CentOS7 下可以限制出站流量吗?

  •  
  •   baalchina Oct 1, 2019 8394 views
    This topic created in 2402 days ago, the information mentioned may be changed or developed.

    大家好,请教下,firewall-cmd 可以限制入站,如果想反过来限制出站呢?

    比如我想禁止我的服务器访问特定的 ip。

    更进一步,我想在特定时间限制我的服务器访问某个 ip...

    请各位指点,谢谢。。

    11 replies    2019-10-03 21:14:06 +08:00
    wtks1
        1
    wtks1  
       Oct 1, 2019 via Android
    iptables 倒是知道怎么限制访问特定 ip,firewall 就不太清楚了
    joyfun
        2
    joyfun  
       Oct 1, 2019 via Android
    crontab 应该没问题
    freelancher
        3
    freelancher  
       Oct 1, 2019
    自己的服务器都控制不了要访问哪个 IP ?

    是不是要搞破坏?被发现了后果很严重的。
    MerlinPrismriver
        4
    MerlinPrismriver  
       Oct 1, 2019
    同有这个问题,,,
    这个场景其实还是挺现实的,比如设置一个只允许访问某段网络的跳板机……

    之前在 QQ 群里问过,得不到答案,都说 firewalld 不限制出站流量的,只能用 iptables...

    好像在 google 上也搜不出答案,,,同求指点
    bobylive
        5
    bobylive  
       Oct 1, 2019
    Firewalld: firewall-cmd --direct --add-rule ipv4 filter OUTPUT 0 -d 1.1.1.1/32 -j REJECT
    iptables: iptables -A OUTPUT -d 1.1.1.1/32 -p tcp -m tcp -j REJECT

    上是用的 iptables,所以也可以直接用 iptables。特定那就加 Cron 吧,iptables 有 -m time 的模,看看 man page 改即可。
    yuikns
        6
    yuikns  
       Oct 1, 2019
    iptables 能做的它肯定都能做。不过只有 rhel 用,一直没动力去学...

    我的话可能会 normalize 成熟悉的问题,改回 iptables: https://blog.argcv.com/articles/3167.c
    digimoon
        7
    digimoon  
       Oct 1, 2019
    老实换回 iptables
    当时打算转用 firewalld 的时候发现在用的一堆 iptables 规则不能实现,查官方文档网上找各种方法后发现解决方法就是在 firewalld 里 direct passthrough 添加 iptables 差不多的命令。然后又因为 firewalld 一启动就会自己创建一大堆链,导致原来的规则不能直接用要先搞清楚这 firewalld 预添加的链

    个人感觉是脱裤子放屁,最后还是用回 iptables
    optional
        8
    optional  
       Oct 1, 2019 via Android
    用 centOS7 的第一件事就是把 firewalld 换回 iptables
    LFUNWF
        9
    LFUNWF  
       Oct 2, 2019 via Android
    squid 透明代理
    realpg
        10
    realpg &bsp;
    PRO
       Oct 2, 2019
    firewalld 不就是 iptables 的封装么……
    hefish
        11
    hefish  
       Oct 3, 2019
    @digimoon 同感。一直用 iptables,不去碰 firewall-cmd。自己找不自在。
    About     Help     Advertise     Blog     API     FAQ     Solana     5474 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 56ms UTC 03:17 PVG 11:17 LAX 20:17 JFK 23:17
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86