iptables進行httpd的服務跳轉

2021-10-07 20:25:45 字數 1097 閱讀 1985

環境:

兩台機器:1.1.1.1、1.1.1.2

1.安裝iptables並開啟

[root@1~]

# yum install -y iptables iptables-services

[root@1~]

# systemctl stop firewalld

[root@1~]

# systemctl disable firewalld

[root@1~]

# systemctl start iptables

2.檢視原有filter規則,並清除

[root@1~]

# iptables -nl

[root@1~]

# iptables -f

3.配置規則

[root@1~]

# iptables -t nat -a postrouting -d 1.1.1.2 -p tcp --dport 80 -j snat -- to-source 1.1.1.1

[root@1~]

# iptables -t nat -a prerouting -d 1.1.1.1 -p tcp --dport 80 -j dnat -- to-destination 1.1.1.2:80

[root@1~]

# iptables -t nat -nl

看到有規則證明成功..

.開啟路由**

[root@1~]

# vim /etc/sysctl.conf

net.ipv4.ip_forward = 1

[root@1~]

# sysctl -p

4.在另一台安裝web服務

/www/html/index.html5.測試訪問

2

Iptables 10 Iptables自定義鏈

之前我們一直在討論和使用預設的鏈,感覺已經滿足我們的需要了,但是這樣嗎?有沒有可能我們想針對某乙個服務自定義一條鏈,所有與之相關的規則都放在一起,這樣會更好管理,我們不用在一大堆雜亂的規則中花大量時間找出我們想要的規則 答案是可以的,我們現在便新建一條自己的鏈吧 現在我們想自定義一條與web相關的鏈...

httpd相關操作

1.源 配置引數 說明 1.對於公共的模組採用靜態編譯,即永久包含進核心,如 rewrite proxy 2.去除不必要的資訊 3.動態共享物件的方式編譯部分引數 如ssl include cgid,並非每個模組都用 這種方式的編譯動靜結合,有利於加快訪問,同時提供適當的靈活性。2.檢視編譯進核心的...

httpd服務搭建

針對centos6搭建的httpd服務 2.配置檔案 etc httpd conf httpd.conf 一般預設的配置檔案是可以使用的 常用的就是 listen 80 documentroot var www html 3.在 var www html 下存放你想要在瀏覽器中顯示的檔案。途中遇到乙...