备份规则
mkdir ~/full-cone-nat && cd ~/full-cone-nat
mkdir rules
iptables-save > rules/iptables-rule.old
systemctl stop firewalld ufw安装依赖
apt update
apt install cmake gcc g++ make git autoconf libtool libncurses5-dev libssl-dev libsodium-dev libreadline-dev zlib1g-dev libmnl-dev libnftnl-dev libxtables-dev克隆仓库
mkdir repos
git clone https://github.com/llccd/netfilter-full-cone-nat repos/netfilter-full-cone-nat
git clone git://git.netfilter.org/iptables repos/iptables编译安装
cd repos/netfilter-full-cone-nat
make
modprobe nf_nat
insmod xt_FULLCONENAT.kocd ..
cp repos/netfilter-full-cone-nat/libipt_FULLCONENAT.c repos/iptables/extensions
cp repos/netfilter-full-cone-nat/libip6t_FULLCONENAT.c repos/iptables/extensions
cd repos/iptables
ln -sfv /usr/sbin/xtables-multi /usr/bin/iptables-xml
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
./autogen.sh
./configure
make
make installcp repos/netfilter-full-cone-nat/xt_FULLCONENAT.ko /lib/modules/$(uname -r)/
depmod
grep "xt_FULLCONENAT" /etc/modules-load.d/fullconenat.conf恢复规则
cd ..
iptables-restore < rules/iptables-rule.old添加规则
iptables -t nat -A POSTROUTING -o eth0 -j FULLCONENAT
iptables -t nat -A PREROUTING -i eth0 -j FULLCONENAT开机自启
iptables-save > rules/iptables-rule.new
[[ -f /etc/rc.local ]] || echo '#!/bin/sh -e' > /etc/rc.local
echo "iptables-restore < $(readlink -f rules/iptables-rule.new)" >> /etc/rc.local
chmod +x /etc/rc.local
systemctl enable rc-local --now源码地址
原创
Debian/Ubuntu 开启Full Cone NAT支持
本文采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。
赞赏支持
如果觉得文章对你有帮助,可以请作者喝杯咖啡 ☕
评论交流
欢迎留下你的想法