美文网首页
Ubuntu下如何映射端口

Ubuntu下如何映射端口

作者: JacobPan | 来源:发表于2018-01-07 23:43 被阅读0次

    若PC上有两张网卡,需要把网卡A的网络共享到网卡B的局域网中,类似路由器wan口到lan口的映射。在windows下十分简单,直接在网络中心中打开网卡A的共享功能就行,而若在Ubuntu中,需要一下命令:

    # sysctl net.ipv4.ip_forward=1
    # iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
    

    其中,eth1是网卡A的ifname

    以上是在Ubuntu 16.04的做法,在Ubuntu 12.04,可以直接

    # echo 1 > /proc/sys/net/ipv4/ip_forward
    iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
    

    Jacob Pan ( jacobpan3g.github.io/cn )

    相关文章

      网友评论

          本文标题:Ubuntu下如何映射端口

          本文链接:https://www.haomeiwen.com/subject/xahvnxtx.html