proxmox折腾记

1,685次阅读
没有评论

添加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

注:enp2s0为有公网IP的网卡
编辑完成后运行service networking restart生效

安装DHCP服务.

apt-get install isc-dhcp-server

修改文件:/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

收工

查看IP分配情况

查看文件/var/lib/dhcp/dhcpd.leases

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