Proxmox PVE端口转发NAT脚本

微信扫一扫,分享到朋友圈

Proxmox PVE端口转发NAT脚本
0

2020 03 30 更新内容:

因为之前的脚本是pve5的,最近更新了自己做的pve6使用的了。

地址:https://github.com/YFsama/MoYuScript/blob/master/bash/vmbr_iptables_nat_init.sh (里面还有其他的脚本哟)

#!/bin/bash

#添加網卡
echo "
auto vmbr1
iface vmbr1 inet static
	address  172.24.31.254
	netmask  24
	bridge-ports none
	bridge-stp off
	bridge-fd 0
" >> /etc/network/interfaces

ifup vmbr1

# 開啓IP轉發
echo "
net.ipv4.conf.all.forwarding = 1
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0
net.ipv6.conf.lo.disable_ipv6 = 0
net.ipv6.conf.default.forwarding = 1
net.ipv6.conf.all.forwarding = 1
net.ipv6.conf.all.proxy_ndp = 1
net.ipv6.conf.all.accept_ra = 2
" > /etc/sysctl.conf

sysctl -p
# IPtable初始化 保存
iptables -t nat -A POSTROUTING -s '172.24.31.0/24' -o vmbr0 -j MASQUERADE

touch /etc/network/if-pre-up.d/iptables

echo "
#!/bin/sh
/sbin/iptables-restore < /etc/iptables
" > /etc/network/if-pre-up.d/iptables

chmod +x /etc/network/if-pre-up.d/iptables

iptables-save > /etc/iptables

———-分割线————

自从入了PVE就沉迷了,这是一个非常好用的脚本也是咱最喜欢的脚本之一,这个脚本是狗蛋给咱的,原作者咱不详。

1.sh

#!/bin/bash
rm -rf /etc/apt/sources.list.d/*
cat > /etc/apt/sources.list  <<'EOF'
deb http://ftp.cn.debian.org/debian/ stretch main
deb-src http://ftp.cn.debian.org/debian/ stretch main

deb http://security.debian.org/ stretch/updates main contrib non-free
deb-src http://security.debian.org/ stretch/updates main contrib non-free

deb http://ftp.cn.debian.org/debian/ stretch-updates main contrib non-free
deb-src http://ftp.cn.debian.org/debian/ stretch-updates main contrib non-free
EOF
apt-get update
apt-get -y install dnsmasq
cat >> /etc/network/interfaces <<'EOF'

auto vmbr1
iface vmbr1 inet static
address 192.168.0.1
netmask 255.255.255.0
bridge_ports none
bridge_stp off
bridge_fd 0
EOF
cat >> /etc/dnsmasq.conf <<'EOF'
interface=vmbr1
#dhcp-option=1,255.255.225.0 
dhcp-range=192.168.0.100,192.168.0.199,12h
dhcp-option=3,192.168.0.1
dhcp-option=option:dns-server,114.114.114.114,8.8.8.8
EOF
cat >> /etc/sysctl.conf <<'EOF'
net.ipv4.ip_forward = 1
EOF
sysctl -p
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j MASQUERADE
cat > /etc/network/if-pre-up.d/iptables <<'EOF'
#!/bin/bash
/sbin/iptables-restore < /etc/iptables.up.rules
EOF
chmod +x /etc/network/if-pre-up.d/iptables
iptables-save > /etc/iptables.up.rules
service networking restart
service dnsmasq restart
rm 1.sh
咱很菜的,是个智障。 人设非常容易崩。
下一篇

Laravel Class env does not exist 解决方法

你也可能喜欢

发表评论

您的电子邮件地址不会被公开。 必填项已用 * 标注

提示:点击验证后方可评论!

插入图片
返回顶部