ITPub博客

首页 > Linux操作系统 > Linux操作系统 > firewall-cmd 配置地址转发

firewall-cmd 配置地址转发

原创 Linux操作系统 作者:longer3281 时间:2021-05-19 16:26:02 0 删除 编辑

【机器地址配置】

A机器IP:192.168.122.85

B机器IP:192.168.122.86

【目的】

连接A地址:192.168.122.85:22000,跳转到192.168.122.86:22 

1)在A机器设置内核参数

sysctl -w net.ipv4.ip_forward=1

echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf 

2) 打开IPV4地址伪装 masquerade

firewall-cmd ---add-masquerade 【删除--remove-masquerade,查询--query-masquerade】

firewall-cmd ---runtime-to-permanent

firewall-cmd --query-masquerade

显示yes 为打开

3)打开地址转发

firewall-cmd --add-forward-port= port=22000:proto=tcp:toport=22:toaddr=192.168.122.86

firewall-cmd ---runtime-to-permanent

测试telnet  192.168.122.85 22000


4)用客户端工具连接

ssh -p 22000 192.168.122.85 

会跳转到B机器 192.168.122.85 

可以执行hostname验证



来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/9606353/viewspace-2772983/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: sed 将文件反排
请登录后发表评论 登录
全部评论
数据库架构师,DB从业经历 DB2,Oracle,MySQL,PGSQL,MonogDB 等数据库,hadoop,hive,spark,flink,doris等大数据技术。

注册时间:2009-05-22

  • 博文量
    69
  • 访问量
    185392