现在的位置: 首页 > 电脑相关 > 正文
Centos7设置iptables中转
2022年06月08日 电脑相关 ⁄ 共 1064字 评论数 2

说明:一般用海外服务器的都会遇到线路爆炸,网络不好的情况,导致我们用的效果很差,这时候就可以用端口转发来改善这种情况,常见的转发有rinetdHaproxyiptablessocat,前面2种只能转发TCP,后面TCP/UDP都可以转发,如果用来玩游戏的话就需要转发UDP了。

1.下载Centos源:

http://mirrors.aliyun.com/centos/7/isos/x86_64/.

2.安装centos7

3.关闭firewalld防火墙

systemctl stop firewalld.service

systemctl disable firewalld.service

4.安装wget

yum -y install wget

5.编辑网卡

vi /etc/sysconfig/network-scripts/ifcfg-ens3

编辑 ONBOOT=yes

6.安装一键脚本

wget --no-check-certificate -qO natcfg.sh http://www.arloor.com/sh/iptablesUtils/natcfg.sh && bash natcfg.sh

 

wget --no-check-certificate -qO natcfg.sh https://raw.githubusercontent.com/arloor/iptablesUtils/master/natcfg.sh && bash natcfg.sh

 

7.设置本地/目的端口 目的服务器ip即可。

 

8.保存

    service iptables save

执行这个命令的时候有时候可能会报错:The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.

这是因为没有安装iptables服务,直接使用yum安装iptables服务即可.

    yum install iptables-services

安装完成后,重新执行 service iptables save 命令即可保存成功。

 

9.配置iptables开机自启

 保存后重启依然没有生效,后百度得知,需要设置iptables开机自启才可使配置生效。

 执行如下命令(老版本命令为:service iptables on),设置iptables开机自启

     systemctl enable iptables.service

 

建伟

【上篇】
【下篇】

目前有 2 条留言 其中:访客:0 条, 博主:0 条


  1. 管理员
    建伟 : 2022年06月15日23:02:42  -49楼 @回复 回复

    学习了


  2. 管理员
    建伟 : 2022年06月15日23:02:26  -48楼 @回复 回复

    留言是种美德,写点什么…

给我留言

留言无头像?



×