V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
zq9610
V2EX  ›  问与答

Linode 的服务器配的 PPTP,为什么每次重启以后都要重新配置一遍 iptables NAT 转发才能用(上网)?

  •  
  •   zq9610 · 2014-12-18 02:18:57 +08:00 · 3260 次点击
    这是一个创建于 3425 天前的主题,其中的信息可能已经有所发展或是发生改变。
    13 条回复    2014-12-18 15:48:42 +08:00
    msg7086
        1
    msg7086  
       2014-12-18 02:53:04 +08:00
    因为没把iptables配置放进启动脚本里?
    luo362722353
        2
    luo362722353  
       2014-12-18 04:34:46 +08:00 via iPhone
    直接把防火墙关了
    msg7086
        3
    msg7086  
       2014-12-18 05:10:59 +08:00
    @luo362722353 那就完全废了。没防火墙怎么转发……
    ryd994
        4
    ryd994  
       2014-12-18 05:31:05 +08:00
    service iptables save
    service iptables enable
    luo362722353
        5
    luo362722353  
       2014-12-18 06:34:58 +08:00 via iPhone
    service iptables stop
    chkconfig iptables off
    iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
    dianyong
        6
    dianyong  
       2014-12-18 08:31:45 +08:00
    建议也别 service iptables save 了,debian和rhel的保存方式还不一样。
    直接把规则写进脚本,放在 /etc/rc.local 开机加载就行了。
    spritefly
        7
    spritefly  
       2014-12-18 09:16:22 +08:00
    imn1
        8
    imn1  
       2014-12-18 10:54:21 +08:00
    debian 需要用 root 账户(sudo 也不行)执行 iptables-save,不然重启后 iptables 将恢复到上一次 save 的规则
    Nin
        9
    Nin  
       2014-12-18 11:27:39 +08:00
    vi /etc/network/if-post-down.d/iptables

    #!/bin/bash
    iptables-save > /etc/iptables.rules

    chmod +x /etc/network/if-post-down.d/iptables

    然后用同样的方式修改/etc/network/if-pre-up.d/iptables
    Nin
        10
    Nin  
       2014-12-18 11:33:55 +08:00
    #!/bin/bash
    iptables-restore < /etc/iptables.rules

    补上...
    sam12321
        11
    sam12321  
       2014-12-18 11:45:52 +08:00
    直接放rc.local
    TheCure
        12
    TheCure  
       2014-12-18 11:47:51 +08:00
    要么放rc.local
    要么save 然后在/etc/interfaces里默认加载
    zq9610
        13
    zq9610  
    OP
       2014-12-18 15:48:42 +08:00
    @luo362722353
    # service iptables stop
    iptables: 未被识别的服务
    # chkconfig iptables off
    在 iptables 服务中读取信息时出错:没有那个文件或目录
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   773 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 20:39 · PVG 04:39 · LAX 13:39 · JFK 16:39
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.