Proxmox VE 7.3 开通NAT服务器
本文最后更新于 424 天前,其中的信息可能已经有所发展或是发生改变。

按照Proxmox VE官方wiki配置vmbr0

配置NAT使用的vmbr1

cp /etc/network/interface /etc/network/interface.bak
auto vmbr1
iface vmbr1 inet static
    address 172.16.1.1
    netmask 255.255.255.0
    bridge_ports none
    bridge_stp off
    bridge_fd 0
    post-up echo 1 > /proc/sys/net/ipv4/ip_forward
    post-up echo 1 > /proc/sys/net/ipv4/conf/vmbr1/proxy_arp
    post-up iptables -t nat -A POSTROUTING -s '172.16.1.0/24' -o vmbr0 -j MASQUERADE
    post-down iptables -t nat -D POSTROUTING -s '172.16.1.0/24' -o vmbr0 -j MASQUERADE

接下来我们在设置文件中加入一个Linux Bridge,开启NAT模式,那么以vmbr1为例,你就得到一个172.16.1.0/24,网关为172.16.1.1的网段。

重启网络

systemctl restart networking

安装isc-dhcp-server

apt install isc-dhcp-server

编辑/etc/default/isc-dhcp-server

# Defaults for isc-dhcp-server (sourced by /etc/init.d/isc-dhcp-server)
# Path to dhcpd’s config file (default: /etc/dhcp/dhcpd.conf).
#DHCPDv4_CONF=/etc/dhcp/dhcpd.conf
#DHCPDv6_CONF=/etc/dhcp/dhcpd6.conf
# Path to dhcpd’s PID file (default: /var/run/dhcpd.pid).
#DHCPDv4_PID=/var/run/dhcpd.pid
#DHCPDv6_PID=/var/run/dhcpd6.pid
# Additional options to start dhcpd with.
# Don’t use options -cf or -pf here; use DHCPD_CONF/ DHCPD_PID instead
#OPTIONS=””
# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
# Separate multiple interfaces with spaces, e.g. “eth0 eth1”.
INTERFACESv4=”vmbr1"
INTERFACESv6=””

配置DHCP

option domain-name “youtdomain.com”; //改为你自己的域名
option domain-name-servers 8.8.8.8;
default-lease-time 600;
max-lease-time 7200;             
ddns-update-style none;         //关闭动态 DNS 功能
authoritative;                  //表示此台DHCP服务器为区域中的官方服务器
log-facility local7;            //开启 DHCP Log 功能
subnet 192.168.100.0 netmask 255.255.255.0 {
   range 192.168.100.200 192.168.100.240;
   option subnet-mask 255.255.255.0;
   option domain-name-servers 8.8.8.8;
   option domain-name “youtdomain.com”;  //改为你自己的域名
   option routers 192.168.100.1;
   option netbios-name-servers 192.168.100.1;
   option netbios-node-type 8;
   get-lease-hostnames true;
   use-host-decl-names true;
   default-lease-time 600;
   max-lease-time 7200;
   interface vmbr0;
}
//host passacaglia { 
//  hardware ethernet 00:50:FC:8E:D2:3D;
//   //指定分配给此 MAC Address 的 DHCP Client 固定 IP
//  fixed-address 192.168.100.1;                        
//   //指定分配给上述 MAC Address 的 DHCP Client 固定 IP 位址
 //}

配置完毕,重启isc-dhcp-server

systemctl restart isc-dhcp-sever

转发端口

iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 19886 -j DNAT --to 172.16.1.12:22

上面一句的含义就是将 Proxmox VE(vmbr0) 的 19886 端口转发到 172.16.1.12 这台虚拟机的 22 端口

评论

  1. pony
    Windows Chrome
    1 年前
    2023-3-08 22:42:25

    我测试一下咯

发送评论 编辑评论


|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇