解決兩宿主機容器之間的透明訪問,如不進行優(yōu)化,容器之間的訪問,日志記錄為宿主機的IP地址。
成都創(chuàng)新互聯(lián)公司服務(wù)項目包括樂清網(wǎng)站建設(shè)、樂清網(wǎng)站制作、樂清網(wǎng)頁制作以及樂清網(wǎng)絡(luò)營銷策劃等。多年來,我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢、行業(yè)經(jīng)驗、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,樂清網(wǎng)站推廣取得了明顯的社會效益與經(jīng)濟效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到樂清省份的部分城市,未來相信會繼續(xù)擴大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!
1、安裝iptables-services組件
[root@test-nodes1 ~]# yum -y install iptables-services
[root@test-nodes1 ~]# systemctl start iptables
[root@test-nodes1 ~]# systemctl enable iptables
Created symlink from /etc/systemd/system/basic.target.wants/iptables.service to /usr/lib/systemd/system/iptables.service.
-----------------------------------------------------------------------------------------------
2、把以下iptable記錄的偽裝轉(zhuǎn)向刪除
[root@test-nodes1 ~]# iptables-save |grep -i postrouting
:POSTROUTING ACCEPT [68:4098]
:KUBE-POSTROUTING - [0:0]
-A POSTROUTING -m comment --comment "kubernetes postrouting rules" -j KUBE-POSTROUTING
-A POSTROUTING -s 172.7.21.0/24 ! -o docker0 -j MASQUERADE #刪除此條
-A KUBE-POSTROUTING -m comment --comment "kubernetes service traffic requiring SNAT" -m mark --mark 0x4000/0x4000 -j MASQUERADE
-----------------------------------------------------------------------------------------------
3、刪除該記錄
[root@test-nodes1 ~]# iptables -t nat -D POSTROUTING -s 172.7.21.0/24 ! -o docker0 -j MASQUERADE
-----------------------------------------------------------------------------------------------
4、插入一條新的記錄(排除對172.7.0.0/16網(wǎng)絡(luò)訪問的偽裝)
[root@test-nodes1 ~]# iptables -t nat -I POSTROUTING -s 172.7.21.0/24 ! -d 172.7.0.0/16 ! -o docker0 -j MASQUERADE
-----------------------------------------------------------------------------------------------
5、查看是否生效
[root@test-nodes1 ~]# iptables-save |grep -i postrouting
:POSTROUTING ACCEPT [13:814]
:KUBE-POSTROUTING - [0:0]
-A POSTROUTING -s 172.7.21.0/24 ! -d 172.7.0.0/16 ! -o docker0 -j MASQUERADE
-A POSTROUTING -m comment --comment "kubernetes postrouting rules" -j KUBE-POSTROUTING
-A KUBE-POSTROUTING -m comment --comment "kubernetes service traffic requiring SNAT" -m mark --mark 0x4000/0x4000 -j MASQUERADE
-----------------------------------------------------------------------------------------------
6、刪除iptables上所有reject拒絕規(guī)則
[root@test-nodes1 ~]# iptables-save | grep -i reject
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
[root@test-nodes1 ~]# iptables -t filter -D INPUT -j REJECT --reject-with icmp-host-prohibited
[root@test-nodes1 ~]# iptables -t filter -D FORWARD -j REJECT --reject-with icmp-host-prohibited
[root@test-nodes1 ~]# iptables-save | grep -i reject
-----------------------------------------------------------------------------------------------
7、保存iptables規(guī)則
[root@test-nodes1 ~]# iptables-save > /etc/sysconfig/iptables