natcfg.sh:利用iptables进行端口转发,支持域名、ddns、udp、IP等
Kdatacenter:$17.1/月/1G内存/100GB SSD空间/1TB流量/1Gbps端口/KVM/韩国SK/直连;原生IP
natcfg.sh,基于iptables进行端口转发,特色是支持域名、ddns、udp、IP等,在NAT VPS不用设置内网IP,更简单。缺点是不支持端口段。
一、前提操作 非必需
1、卸载 firewalld 和 ufw
apt remove firewalld ufw
或
yum remove firewalld ufw
然后重启。
2、安装iptables
yum install -y iptables yum update iptables yum install iptables-services
iptables配置文件:/etc/sysconfig/iptables
3、开启转发功能
echo -e "net.ipv4.ip_forward=1" >> /etc/sysctl.conf sysctl -p
4、设置一下iptable开机启动自动载入规则功能
CentOS 系统:
service iptables save systemctl enable iptables.service
Debian/Ubuntu 系统:
iptables-save > /etc/iptables.up.rules echo -e '#!/bin/bash\n/sbin/iptables-restore /etc/network/if-pre-up.d/iptables chmod +x /etc/network/if-pre-up.d/iptables
二、使用natcfg.sh进行转发
SSH下:
wget --no-check-certificate -qO natcfg.sh https://zhujiwiki.com/wp-content/uploads/2020/11/natcfg/natcfg.sh && bash natcfg.sh
需要继续设置时,执行
bash natcfg.sh
三、卸载natcfg.sh
wget --no-check-certificate -qO natcfg.sh https://zhujiwiki.com/wp-content/uploads/2020/11/natcfg/dnat-uninstall.sh && bash dnat-uninstall.sh
四、配置文件
/etc/dnat/conf
项目已开源:https://github.com/arloor/iptablesUtils
文章版权声明:除非注明,否则均为主机测评原创文章,转载或复制请以超链接形式并注明出处。
还没有评论,来说两句吧...