Debian 10安装Proxmox VE,并利用单IP VPS LXC虚拟化开NAT小鸡

4次阅读
没有评论

Proxmox VE

(简称为PVE),是一个款开源虚拟化管理软件,和ESXI类似,简单的说就是用来开设和管理虚拟机的。

本次使用机器美国单IP VPS,配置2C2G 40G,索性赶紧学习一下如何操作。网上搜索了很多教程,大同小异,出现有些有问题的地方还真没讲,于是对本次安装及开通

NAT

小鸡做一下记录。

一、安装PVE前的准备工作:

1.首先需要一台干净

Debian 10

系统的

VPS

DD安装一键脚本换系统

apt-get update
apt-get install -y xz-utils openssl gawk file wget
wget --no-check-certificate -qO InstallNET.sh 'https://moeclub.org/attachment/LinuxShell/InstallNET.sh' && chmod a+x InstallNET.sh

国内使用下面镜像

bash InstallNET.sh -d 10 -v 64 -a --mirror 'http://mirrors.tencent.com/debian/'

国外使用下面语句

bash InstallNET.sh -d 10 -v 64 -a

2.DD完系统后,安装 wget  cur sudo

apt update  && apt install -y curl wget sudo

二、安装Proxmox VE

1.设置host,PVE官方要求,需要做如下修改:

首先设置hostname,根据实际情况自行修改,我这里设置为pve

hostnamectl set-hostname pve

修改/etc/hosts,添加如下内容

127.0.0.1       localhost.localdomain localhost
**这里填你服务器公网IP**   pve.proxmox.com pve

2.添加PVE安装源

依次执行下面的命令:

#清华大学源

echo "deb https://mirrors.tuna.tsinghua.edu.cn/proxmox/debian/pve buster pve-no-subscription" > /etc/apt/sources.list.d/pve-install-repo.list

下载秘钥

wget http://download.proxmox.com/debian/proxmox-ve-release-6.x.gpg -O /etc/apt/trusted.gpg.d/proxmox-ve-release-6.x.gpg && chmod +r /etc/apt/trusted.gpg.d/proxmox-ve-release-6.x.gpg
apt update && apt full-upgrade -y
#如需升级pve,则执行该命令
apt update&&apt dist-upgrade -y

 添加社区源

echo "deb http://download.proxmox.wiki/debian/pve stretch pve-no-subscription" >/etc/apt/sources.list.d/pve-install-repo.list

删除企业源

rm -rf /etc/apt/sources.list.d/pve-enterprise.list

中途让你选择是否继续,选择Y,回车。

3.安装PVE

apt -y install proxmox-ve postfix open-iscsi

如果您不是安装的双系统,则可以删除os-prober软件包。

apt remove os-prober

4.reboot重启服务器,使其加载PVE内核,重启成功后访问PVE WEB界面:https://IP:8006,注意是https协议,否则无法打开。用户名、密码就是服务器所使用的用户名/密码。

5.如果是海外的独立服务器,建议开启BBR来优化TCP传输,开启方法如下:

修改内核配置

cat >>/etc/sysctl.conf << EOF
net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbr
EOF

使配置生效

sysctl -p

使用命令 lsmod |grep bbr 进行验证,当看到tcp_bbr字样,说明BBR开启成功。

lsmod |grep bbr

Linux默认描述符为1024,为避免后期出现各种问题,建议修改ulimit,描述符限制,修改方法如下:

echo 'fs.file-max = 65535' >>/etc/sysctl.confecho '* soft nofile 65535' >>/etc/security/limits.confecho '* hard nofile 65535' >>/etc/security/limits.confecho 'ulimit -SHn 65535' >>/etc/profile

好了,到此,PVE安装完成。

三、单IP VPS LXC虚拟化开NAT小鸡

1.配置网络

首先,配置

IPv6

网络,如果没有

ipv6

或者不需要可忽略,编辑

/etc/modprobe.d/local.conf

,修改或者添加如下内容:

options ipv6 disable=0

编辑/etc/modules,添加如下字符:

ipv6

开启IPv4,IPv6转发,编辑

/etc/sysctl.conf

,添加以下内容到尾部:

net.ipv4.ip_forward=1

net.ipv4.conf.all.rp_filter=1

net.ipv4.icmp_echo_ignore_broadcasts=1

net.ipv4.conf.default.forwarding=1

net.ipv4.conf.default.proxy_arp = 0

net.ipv4.conf.default.send_redirects = 1

net.ipv4.conf.all.send_redirects = 0

net.ipv6.conf.

ens3

.autoconf=0

net.ipv6.conf.

ens3

.accept_ra=2

net.ipv6.conf.default.forwarding=1

net.ipv6.conf.all.forwarding=1

net.ipv6.conf.default.proxy_ndp=1

net.ipv6.conf.all.proxy_ndp=1

其中红色部分修改为自己的网卡名:

net.ipv6.conf.

ens3

.autoconf=0

net.ipv6.conf.

ens3

.accept_ra=2

网卡名称查看输入:

ip a



proxmox-09.png

重点来了,编辑

/etc/network/interfaces

,我的

VPS

原配置如下:

# This file describes the network interfaces available on your system# and how to activate them. For more information, see interfaces(5).source /etc/network/interfaces.d/*# The loopback network interfaceauto loiface lo inet loopback# The primary network interfaceallow-hotplug ens3iface ens3 inet static    address 107.175.***.***/24gateway 107.175.***.***# dns-* options are implemented by the resolvconf package, if installeddns-nameservers 8.8.8.8dns-search colocrossing.com

修改如下内容如下:

# This file describes the network interfaces available on your system# and how to activate them. For more information, see interfaces(5).auto loiface lo inet loopbackiface ens3 inet manual #修改成你原来的网卡名auto vmbr0iface vmbr0 inet staticaddress 107.175.***.***/24  #这里必须和原配置一样netmask 255.255.255.0gateway 107.175.***.***     #这里必须和原配置一样bridge_ports ens3     #修改成你原来的网卡名bridge_stp offbridge_fd 0#private sub networkauto vmbr1iface vmbr1 inet staticaddress  10.10.10.1/24   #自定义你内网ip段,你开心定成啥就是啥netmask  255.255.255.0bridge_ports nonebridge_stp offbridge_fd 0post-up echo 1 > /proc/sys/net/ipv4/ip_forwardpost-up   iptables -t nat -A POSTROUTING -s ‘10.10.10.0/24’ -j MASQUERADEpost-down iptables -t nat -D POSTROUTING -s ‘10.10.10.0/24’ -j MASQUERADE

修改完成后保存,重启

VPS

,如果重启发现连不上,遗憾的告诉你你改错了导致外网蹦了,去

VNC

重新修改配置吧!

重启成功后,进入PVE Web管理页面

https://ip:8006

2.创建CT

创建之前先下载

LXC

系统模板

Debian 10安装Proxmox VE,并利用单IP VPS LXC虚拟化开NAT小鸡
Debian 10安装Proxmox VE,并利用单IP VPS LXC虚拟化开NAT小鸡

如果你是国内机器下载很慢,请更换源,调整使用清华镜像或者其他国内镜像下载,速度有很大的提升!

Debian 10安装Proxmox VE,并利用单IP VPS LXC虚拟化开NAT小鸡

#

#清华大学镜像

#中国科学技术大学

#

Debian 10安装Proxmox VE,并利用单IP VPS LXC虚拟化开NAT小鸡

开始创建

CT

实例。

Debian 10安装Proxmox VE,并利用单IP VPS LXC虚拟化开NAT小鸡
Debian 10安装Proxmox VE,并利用单IP VPS LXC虚拟化开NAT小鸡
Debian 10安装Proxmox VE,并利用单IP VPS LXC虚拟化开NAT小鸡
Debian 10安装Proxmox VE,并利用单IP VPS LXC虚拟化开NAT小鸡
Debian 10安装Proxmox VE,并利用单IP VPS LXC虚拟化开NAT小鸡
Debian 10安装Proxmox VE,并利用单IP VPS LXC虚拟化开NAT小鸡
Debian 10安装Proxmox VE,并利用单IP VPS LXC虚拟化开NAT小鸡
Debian 10安装Proxmox VE,并利用单IP VPS LXC虚拟化开NAT小鸡
Debian 10安装Proxmox VE,并利用单IP VPS LXC虚拟化开NAT小鸡

注意:这里有个坑,官方模板ssh未开放登录,要手动修改才能通过外网访问。
执行nano /etc/ssh/sshd_config

Debian 10安装Proxmox VE,并利用单IP VPS LXC虚拟化开NAT小鸡
Debian 10安装Proxmox VE,并利用单IP VPS LXC虚拟化开NAT小鸡
Debian 10安装Proxmox VE,并利用单IP VPS LXC虚拟化开NAT小鸡

然后

Ctrl+O

保存,回车,

Ctrl+X

退出,执行sshd重启命令:

systemctl restart sshd

注意:debian10官方模板源有问题,自行替换

# deb http://deb.debian.org/debian stretch maindeb http://deb.debian.org/debian stretch maindeb-src http://deb.debian.org/debian stretch main

到这里,小鸡的开通及连接教程已全部完成。

3.配置外网端口转发,在母鸡中执行,代码如下:

iptables -t nat -A PREROUTING -i vmbr0 -p tcp –dport 10022 -j DNAT –to-destination 10.10.10.100:22iptables -t nat -A PREROUTING -i vmbr0 -p udp –dport 10022 -j DNAT –to-destination 10.10.10.100:22

外网端口

10022

就是对应的内网小鸡

22

端口,配置完成后可以通过

ip:10022

来访问小鸡,如需其他端口,上面代码自行修改执行即可。

至此,教程全部结束~

正文完
 0
评论(没有评论)