1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > linux7防火墙端口映射 服务器使用firewall进行端口映射端口转发

linux7防火墙端口映射 服务器使用firewall进行端口映射端口转发

时间:2021-01-12 11:55:51

相关推荐

linux7防火墙端口映射 服务器使用firewall进行端口映射端口转发

centos7

centos7通过firewall防火墙实现端口映射功能

首先要开启转发功能:

vi /etc/sysctl.conf

添加一行:

net.ipv4.ip_forward = 1

让修改生效:

sysctl -p

输入命令,如果源服务器IP为a.a.a.a:

firewall-cmd --add-forward-port=port=80:proto=tcp:toaddr=a.a.a.a:toport=80

开启伪装IP:

firewall-cmd --add-masquerade --permanent

重启firewall使生效:

firewall-cmd --reload

到此CENTOS7下利用firewall进行端口映射加速WEB服务的设置就完成了。

echo1>/proc/sys/net/ipv4/ip_forward

systemctl start firewalld.service

systemctl enable firewalld.service

firewall-cmd --permanent --add-masquerade

firewall-cmd --permanent --add-port=你要的端口/tcp

firewall-cmd --permanent --add-port=你要的端口/udp

firewall-cmd --permanent --add-forward-port=port=55555:proto=tcp:toport=你要的端口:toaddr=被转发的ip

firewall-cmd --permanent --add-forward-port=port=55555:proto=udp:toport=你要的端口:toaddr=被转发的ip

firewall-cmd --reload

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。