firewalld配置閘道器伺服器

2021-10-05 10:33:10 字數 1792 閱讀 4479

1,在主機a上開啟防火牆

[root@ c7-41 ~] systemctl start firewalld.service
2,插入ip**,並生效

[root@ c7-41 ~] vim /etc/sysctl.conf

[root@ c7-41 ~]

cat /etc/sysctl.conf |

grep -v '^#'

net.ipv4.ip_forward=1

[root@ c7-41 ~] sysctl -p #生效

net.ipv4.ip_forward = 1

3,在主機b上關掉第一塊網絡卡

[root@ c7-42 ~]

ifdown ens33

在虛擬機器上測試是否ping通外網

[root@ c7-42 ~]

ping qq.com #已ping不通外網

ping

: qq.com name or service not known

4,在主機a上開啟firewalld策率

[root@ c7-41 ~] firewall-cmd --add-masquerade --permanent

success

[root@ c7-41 ~] firewall-cmd --permanent --direct --passthrough ipv4 -t nat -i postrouting -o ens37 -j masquerade -s 172.16.1.0/24

success

[root@ c7-41 ~] firewall-cmd --reload #啟動策率

5,在虛擬主機b上新增配置和策率

[root@ c7-42 ~] route add default gw 170.16.1.41 dev ens37

[root@ c7-42 ~] vim /etc/resolv.conf

[root@ c7-42 ~]

cat /etc/resolv.conf

nameserver 223.5.5.5

6,ping外網測試,能ping通

[root@ c7-42 ~]

ping qq.com

ping qq.com (58.250.137.36) 56(84) bytes of data.

64 bytes from 58.250.137.36 (58.250.137.36): icmp_seq=1 ttl=127 time=99.6 ms

64 bytes from 58.250.137.36 (58.250.137.36): icmp_seq=2 ttl=127 time=102 ms

7,以上為臨時配置,如果想永久使用則如下配置

在主機b的ens37網絡卡上新增以主機a的ens37網絡卡ip為閘道器在主機b上,並重啟主機b的網絡卡就可以實現

[root@ c7-42 ~] vim /etc/sysconfig/network-scripts/ifcfg-ens37

[root@ c7-42 ~]

cat /etc/sysconfig/network-scripts/ifcfg-ens37|

grep gateway

gateway=172.16.1.41

[root@ c7-42 ~] systemctl restart network

firewalld配置nat閘道器伺服器

需要 搭建yum倉庫 配置nat nginx或haproxy等實現 伺服器 操作在第一台上firewalld配置nat閘道器伺服器 root c7 41 systemctl start firewalld root c7 41 vim etc sysctl.conf root c7 41 egrep...

firewalld配置例子

例一 在域 172.24.0.0 24 內的客戶端不能訪問您的虛擬機器系統 一 root desktop0 firewall cmd add rich rule rule family ipv4 source address 172.24.0.0 24 service name ssh reject...

服務閘道器zuul之四 zuul閘道器配置

禁用過濾器 在zuul中特別提供了乙個引數來禁用指定的過濾器,該引數的配置格式如下 zuul.accessfilter.pre.disable true 動態載入 動態路由 通過結合spring cloud config的動態重新整理機制,可以是實現動態重新整理路由規則的功能。動態過濾器 對於實現請...