TypechoJoeTheme

主机评测

主机评测

专注云主机评测和优惠码发布

利用PVE给独立服务器自动_

2022-02-11
/
0 评论
/
4,164 阅读
/
未收录,点击推送
02/11

前言:

我们一般需要在独立服务器安装虚拟化比如我本人推荐使用proxmox(PVE)开源的,在PVE日常使用中如果有多ip分配的话,手动其实算是一个很大的工作量。本文白话记录v4与v6的获取,实现一次设置终身解放。

准备工作:

来到ovh或者sys的后台ip所在页面,生成对应的mac

配置网卡参数:

  • 连接服务器SSH

打开并编辑/etc/network/interfaces

  1. auto lo
  2. iface lo inet loopback
  3. iface eno3 inet manual
  4. auto vmbr0
  5. iface vmbr0 inet static
  6. address 服务器ip/24
  7. gateway 网关
  8. bridge-ports eno3
  9. bridge-stp off
  10. bridge-fd 0
  11. iface vmbr0 inet6 static
  12. address 这里ipv6分配个/128
  13. gateway 网关这里来个::1
  14. iface eno1 inet manual
  15. iface eno2 inet manual
  16. iface eno4 inet manual
  17. auto vmbr1
  18. iface vmbr1 inet static
  19. address 192.168.0.1/24
  20. bridge_ports none
  21. bridge_stp off
  22. bridge_fd 0
  23. bridge-vlan-aware yes
  24. bridge-vids 2-4094
  25. #转发ip4流量到小鸡使其可以连接外网
  26. post-up echo 1 > /proc/sys/net/ipv4/ip_forward
  27. post-up iptables -t nat -A POSTROUTING -s '192.168.0.1/24' -o vmbr0 -j MASQUERADE
  28. post-down iptables -t nat -D POSTROUTING -s '192.168.0.1/24' -o vmbr0 -j MASQUERADE
  29. iface vmbr1 inet6 static
  30. address 2001:xxxx:303:xxxx::3/64
  31. up ip -6 route add 2001:xxxx:303:xxxx::/64 dev vmbr1
  32. post-down ip -6 route del 2001:xxxx:303:xxxx::/64 dev vmbr1
  33. post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 222 -j DNAT --to 192.168.0.3:22
  34. post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 222 -j DNAT --to 192.168.0.3:22
  35. post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 80 -j DNAT --to 192.168.0.3:80
  36. post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 80 -j DNAT --to 192.168.0.3:80
  37. post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 443 -j DNAT --to 192.168.0.3:443
  38. post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 443 -j DNAT --to 192.168.0.3:443
  39. post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 8888 -j DNAT --to 192.168.0.3:8888
  40. post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 8888 -j DNAT --to 192.168.0.3:8888
  • 打开etc/sysctl.conf编辑
  1. net.ipv4.tcp_congestion_control=bbr
  2. net.core.default_qdisc=fq
  3. net.ipv4.conf.all.rp_filter=1
  4. net.ipv4.icmp_echo_ignore_broadcasts=1
  5. net.ipv4.conf.default.forwarding=1
  6. net.ipv4.conf.default.proxy_arp = 0
  7. net.ipv4.ip_forward=1
  8. kernel.sysrq = 1
  9. net.ipv4.conf.default.send_redirects = 1
  10. net.ipv4.conf.all.send_redirects = 0
  11. net.ipv4.ip_forward=1
  12. net.ipv6.conf.all.accept_dad = 1
  13. net.ipv6.conf.all.accept_ra = 0
  14. net.ipv6.conf.all.accept_redirects = 1
  15. net.ipv6.conf.all.accept_source_route = 0
  16. net.ipv6.conf.all.autoconf = 0
  17. net.ipv6.conf.all.disable_ipv6 = 0
  18. net.ipv6.conf.all.forwarding=1

配置DHCP v4

  • 安装DHCP
  1. apt install isc-dhcp-server # 安装hdcp
  2. systemctl status isc-dhcp-server #启动查看状态
  3. service isc-dhcp-server restart #重启dhcp
  4. systemctl enable isc-dhcp-server #开机启动
  • 找到并编辑/etc/default/isc-dhcp-server
  1. INTERFACESv4="vmbr0"
  2. #INTERFACESv6=""
  • 找到并编辑/etc/dhcp/dhcpd.conf
  1. subnet 0.0.0.0 netmask 0.0.0.0 {
  2. authoritative;
  3. default-lease-time 21600000;
  4. max-lease-time 432000000;
  5. }
  6. # Bind IP by MAC
  7. host VM1 {
  8. # MAC Address
  9. hardware ethernet x:x:x:x:x:x;
  10. # Gateway
  11. option routers x.x.x.x;
  12. # Subnet
  13. option subnet-mask 255.255.255.0;
  14. # Failover IP
  15. fixed-address x.x.x.x;
  16. # DNS server
  17. option domain-name-servers 8.8.8.8,8.8.4.4;

绑定以此类推vm1,vm2,vm3,。。。。。。

配置DHCP v6

  • 安装radvd
  1. apt install radvd #安装
  2. radvdservice radvd restart #重启
  3. radvdstatus radvd #启动
  4. radvdsystemctl enable radvd #开机启动
  • 找到并打开编辑 etc/radvd.conf
  1. interface vmbr0
  2. {
  3. AdvSendAdvert on;
  4. MinRtrAdvInterval 30;
  5. MaxRtrAdvInterval 100;
  6. prefix xxxx:abc0:1234:79::/64
  7. {
  8. AdvOnLink on;
  9. AdvAutonomous on;
  10. AdvRouterAddr on;
  11. };
  12. };

配置pve

  • 在pve中找到DNS,添加一个DNS服务器用来解析v6地址,博主用谷歌v6DNS

创建虚拟机

创建一个虚拟机,别忘记将ovh或sys的ip地址mac绑定上去

proxmoxpve
朗读

赞 · 1
赞赏
感谢您的支持,我会继续努力哒!
打开手机扫一扫,即可进行打赏哦!
版权属于:

主机评测

本文链接:

https://www.zjpc.cc/1002.html(转载时请注明本文出处及文章链接)

评论 (0)
  • OωO
  • |´・ω・)ノ
  • ヾ(≧∇≦*)ゝ
  • (☆ω☆)
  • (╯‵□′)╯︵┴─┴
  •  ̄﹃ ̄
  • (/ω\)
  • ∠( ᐛ 」∠)_
  • (๑•̀ㅁ•́ฅ)
  • →_→
  • ୧(๑•̀⌄•́๑)૭
  • ٩(ˊᗜˋ*)و
  • (ノ°ο°)ノ
  • (´இ皿இ`)
  • ⌇●﹏●⌇
  • (ฅ´ω`ฅ)
  • (╯°A°)╯︵○○○
  • φ( ̄∇ ̄o)
  • ヾ(´・ ・`。)ノ"
  • ( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
  • (ó﹏ò。)
  • Σ(っ °Д °;)っ
  • ( ,,´・ω・)ノ"(´っω・`。)
  • ╮(╯▽╰)╭
  • o(*////▽////*)q
  • >﹏<
  • ( ๑´•ω•) "(ㆆᴗㆆ)
  • (。•ˇ‸ˇ•。)
  • 泡泡
  • 阿鲁
  • 颜文字
火爆
火爆
火爆