no comments yet
07
Dec
2019
centos7配置端口转发
#!/bin/bash
#开启系统路由模式功能
echo net.ipv4.ip_forward=1>>/etc/sysctl.conf
#运行这个命令会输出上面添加的那一行信息,意思是使内核修改生效
sysctl -p
#开启firewalld
systemctl start firewalld
#开启4650端口监听tcp请求
firewall-cmd --zone=public --add-port=4650/tcp --permanent
#设置IP地址伪装
firewall-cmd --add-masquerade --permanent
#设置端口映射
firewall-cmd --add-forward-port=port=4650:proto=tcp:toaddr=211.211.211.211:toport=3389 --permanent
firewall-cmd --add-masquerade --permanent
#重启firewall
firewall-cmd --reload
如果提示firewall-cmd: command not found
错误,
yum install firewalld -y