自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

iptables實(shí)現(xiàn)端口轉(zhuǎn)發(fā)、端口映射及雙向通路

運(yùn)維 系統(tǒng)運(yùn)維
iptables 是與最新的 2.6.x 版本Linux 內(nèi)核集成的 IP 信息包過濾系統(tǒng)。iptables實(shí)現(xiàn)端口轉(zhuǎn)發(fā)、端口映射及雙向通路的具體方法,統(tǒng)統(tǒng)都能在文章中找答案!

iptables實(shí)現(xiàn)端口轉(zhuǎn)發(fā)、端口映射及雙向通路其實(shí)不難配置,只要你跟好我的腳步,看下文:

  項(xiàng)目上線,有兩臺(tái)服務(wù)器,A在公網(wǎng)。linux rhel5.4,運(yùn)行php開發(fā)的一個(gè)打折購(gòu)物網(wǎng):尚品折扣,數(shù)據(jù)庫(kù)部署到內(nèi)網(wǎng)中,每次導(dǎo)入數(shù)據(jù)都要ssh到公網(wǎng),然后再轉(zhuǎn)到內(nèi)網(wǎng)。一次采集了一些服裝品牌的數(shù)據(jù),比如,艾格的服裝資訊,優(yōu)衣庫(kù)的打折,朵以的產(chǎn)品介紹

  下面是實(shí)現(xiàn)過程:

  允許數(shù)據(jù)包轉(zhuǎn)發(fā):

 

  1.   #echo 1 > /proc/sys/net/ipv4/ip_forward  
  2.  

 

  轉(zhuǎn)發(fā)TCP 8081到xx.xx.xx.xx:

 

  1.   #iptables -t nat -I PREROUTING -p tcp –dport 80 -j DNAT –to xx.xx.xx.xx  
  2.  

 

  使轉(zhuǎn)發(fā)數(shù)據(jù)包實(shí)現(xiàn)“雙向通路”,給數(shù)據(jù)包設(shè)置一個(gè)正確的返回通道:

 

  1.   #iptables -t nat -I POSTROUTING -p tcp –dport 8080 -j MASQUERADE  
  2.  

 

  表示將規(guī)則保存到/etc/sysconfig/iptables文件

 

  1.   #service iptables save  
  2.  

 

  重啟iptables使剛才添加的規(guī)則生效

 

  1.   #service iptables restart  
  2.  

#p#
 

 

  如果執(zhí)行上述命令,依然不能轉(zhuǎn)發(fā),可能由于iptables服務(wù)沒有停止,命令無法寫入iptables文件,應(yīng)先執(zhí)行service iptables stop,再執(zhí)行上述命令,***service iptables start再啟動(dòng)服務(wù)

  由于Linux防火墻默認(rèn)是關(guān)閉3306端口。因此,若要能夠訪問3306端口,可以用兩種方式,一個(gè)是關(guān)閉防火墻,另一個(gè)就是讓防火墻開放3306端口。

  開放3306端口的解決步驟如下:

  1、修改/etc/sysconfig/iptables文件,增加如下一行:

  -A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT

  2、重啟防火墻,這里有兩種方式重啟防火墻

  a) 重啟后生效

  開啟: chkconfig iptables on

  關(guān)閉: chkconfig iptables off

  b) 即時(shí)生效,重啟后失效

  開啟: service iptables start

  關(guān)閉: service iptables stop

  數(shù)據(jù)庫(kù)映射成功。

通過文章的描述,相信各位都能學(xué)會(huì)了iptables實(shí)現(xiàn)端口轉(zhuǎn)發(fā)、端口映射及雙向通路的方法。希望對(duì)大家有幫助!

【編輯推薦】

  1. CentOS下配置iptables防火墻
  2. Centos5下安裝iptables以及l(fā)ayer7協(xié)議
  3. Centos 5.3 環(huán)境下編譯iptables
  4. CentOS+iptables+squid透明代理+防火墻設(shè)置
  5. centos IPTables 配置方法
  6. 創(chuàng)建iptables NAT 規(guī)則
  7. Ubuntu iptables 初始化的實(shí)現(xiàn)
  8. Ubuntu iptables 內(nèi)網(wǎng)端口映射

 

 

責(zé)任編輯:趙鵬 來源: 網(wǎng)絡(luò)轉(zhuǎn)載
相關(guān)推薦

2011-03-16 13:29:33

iptables 端口

2011-03-16 13:09:10

iptables 端口

2019-07-25 15:15:54

端口映射服務(wù)器

2011-03-17 13:55:23

iptablesNAT端口映射

2011-03-16 10:43:36

2011-03-17 14:26:45

iptables 端口

2009-09-16 08:49:29

linux端口映射linux端口linux

2011-03-17 09:35:35

iptables 映射Linux內(nèi)核

2021-08-17 00:02:11

LinuxWindows服務(wù)器

2020-11-19 10:35:19

LinuxWindows端口映射

2010-09-02 14:47:56

2011-08-25 14:35:04

Nth端口映射ftp服務(wù)器

2009-12-15 16:21:53

水星路由器端口映射

2011-03-17 09:06:58

iptables映射端口

2010-08-09 11:35:17

路由器端口映射

2011-03-16 10:12:27

LinuxIptables端口轉(zhuǎn)發(fā)

2009-12-15 15:50:22

路由器端口映射

2010-08-05 10:39:32

路由端口

2011-04-07 10:04:03

寬帶路由器

2010-08-02 12:00:06

ADSL Modem端口映射
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)