<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # iptables企業案例-共享上網和端口映射 [TOC] ## 一、 共享上網 ### 1. 準備工作 1)環境模擬 內網服務器停止防火墻服務,關閉內網服務器外網網卡模擬真實環境, 刪除內網網卡DNS地址信息,使其不能上網,并配置網關為有外網的服務器[172.16.1.7] ```sh /etc/init.d/iptables stop ifdown eth0 vim /etc/sysconfig/network-scripts/ifcfg-eth1 ``` 網卡配置略 2)查看路由表 ```sh route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 172.16.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1 169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 eth1 0.0.0.0 172.16.1.7 0.0.0.0 UG 0 0 0 eth1 ``` 說明:內網服務器網關地址指定為共享上網服務器內網網卡地址 ### 2. 開啟共享上網服務器路由轉發功能 ```sh sed i '/net.ipv4.ip_forward/ s#0#1#g' /etc/sysctl.conf grep "_forward" /etc/sysctl.conf net.ipv4.ip_forward = 0 sysctl -p ``` ### 3. 共享上網實現[1:有固定外網IP] 1) 規則配置 ```sh iptables -t nat -A POSTROUTING -s 172.16.1.0/24 -o eth0 -j SNAT --to-source 10.0.0.7 -s 172.16.1.0/24 --- 指定將哪些內網網段進行映射轉換 -o eth0 --- 指定在共享上網哪個網卡接口上做NAT地址轉換 -j SNAT --- 將源地址進行轉換變更 -j DNAT --- 將目標地址進行轉換變更 --to-source ip地址 --- 將源地址映射為什么IP地址 --to-destination ip地址 --- 將目標地址映射為什么IP地址 ``` 2) 擴展[] 如果設置forward鏈默認drop策略,那還需要做如下配置: ```sh iptables -A FORWARD -i eth1 -s 172.16.1.0/24 -j ACCEPT iptables -A FORWARD -o eth0 -s 172.16.1.0/24 -j ACCEPT iptables -A FORWARD -i eth0 -d 172.16.1.0/24 -j ACCEPT iptables -A FORWARD -o eth1 -d 172.16.1.0/24 -j ACCEPT ``` 4. 共享上網實現[2:無固定外網IP] ```sh iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -j MASQUERADE ``` ## 二、端口映射 ### 1.將網關的IP和9000端口映射到內網服務器的22端口 1)映射關系 ```sh 端口映射 10.0.0.7:9000 -->172.16.1.8:22 ``` 2)實現命令 ```sh iptables -t nat -A PREROUTING -d 10.0.0.7 -i eth0 -p tcp --dport 9000 -j DNAT --to-destination 172.16.1.8:22 ``` ### 2. 實現把訪問10.0.0.5:80的請求轉到172.16.1.8:80 ```sh iptables -t nat -A PREROUTING -d 10.0.0.5 -p tcp --dport 80 -j DNAT --to-destination 172.16.1.8:80 ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看