Proxmox Nat 設定

主機安裝 proxmox 默認沒DHCPD服務,需要自已安裝

1:添加NAT網橋

只有一個公網IP,想要虛擬機上網,就只能使用NAT模式.沒有使用WEB UI上的方案,直接編輯/etc/network/interface文件

auto vmbr0
iface vmbr0 inet static
  address 192.168.100.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/vmbr0/proxy_arp
  post-up   iptables -t nat -A POSTROUTING -s '192.168.100.0/24' -o enp2s0 -j MASQUERADE
  post-down iptables -t nat -D POSTROUTING -s '192.168.100.0/24' -o enp2s0 -j MASQUERADE

複製代碼

運行 service networking restart 使添加的網橋生效

2:安裝DHCP服務.

apt-get install isc-dhcp-server
複製代碼

3:配置DHCP服務

修改文件:/etc/default/isc-dhcp-server,添加INTERFACES=“vmbr0”
修改文件:/etc/dhcp/dhcpd.conf

ddns-update-style none;
default-lease-time 600;
max-lease-time 7200;
#ping true;
option domain-name-servers 172.27.15.2, 10.72.81.2;
option domain-name "cloud.isfate.com";
authorative;
log-facility local7;
subnet 192.168.100.0 netmask 255.255.255.0 {
    range 192.168.100.5 192.168.100.230;
    option subnet-mask 255.255.255.0;
    option domain-name-servers 8.8.8.8, 8.8.4.4;
    option domain-name "cloud.isfate.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;
}

複製代碼

最後, service isc-dhcp-server restart