ProxmoxVE 配置 NAT 网络
1. 升级系统软件包
1$ apt-get update
2$ apt-get dist-upgrade
2. 安装 ifupdown2
使用 ifupdown2 网络管理软件包,还可以实时重新加载网络配置,而无需重新启动。
1$ apt install ifupdown2
3. 配置物理网卡
使用 PVE 的 WEB 管理界面,设置物理网卡的配置。
注意:一定要分配一个静态的IP地址,否则无法正常登录 PVE
节点 > 系统 > 网络:
- address:192.168.10.66/24
- gateway:192.168.10.1
保存后应用配置
4. 配置虚拟网卡
4.1 修改虚拟网卡配置
使用 PVE 提供管理界面进行配置。 删除 vmbr0 设备的所有配置内容。
编辑 /etc/network/interfaces
1$ nano /etc/network/interfaces
加入
1source /etc/network/interfaces.d/*
1# network interface settings; autogenerated
2# Please do NOT modify this file directly, unless you know what
3# you're doing.
4#
5# If you want to manage parts of the network configuration manually,
6# please utilize the 'source' or 'source-directory' directives to do
7# so.
8# PVE will preserve these directives, but will NOT read its network
9# configuration from sourced files, so do not attempt to move any of
10# the PVE managed interfaces into external files!
11
12source /etc/network/interfaces.d/*
13
14auto lo
15iface lo inet loopback
16
17auto enp1s0
18iface enp1s0 inet static
19 address 192.168.10.66/24
20 gateway 192.168.10.1
21
22iface vmbr0 inet manual
23 bridge-ports none
24 bridge-stp off
25 brideg-fd
4.2 新建虚拟网卡配置
创建新的虚拟网卡配置
注意:给虚拟网卡指定一个新的静态地址,是为下一级网络提供NAT服务
1$ nano /etc/network/interfaces.d/vmbr0-nat
配置内容
1auto vmbr0
2# private sub network
3iface vmbr0 inet static
4 address 192.168.100.1/24
5 bridge-ports none
6 bridge-stp off
7 bridge-fd 0
8
9 post-up echo 1 > /proc/sys/net/ipv4/ip_forward
10 post-down echo 0 > /proc/sys/net/ipv4/ip_forward
11 post-up iptables -t nat -A POSTROUTING -s '192.168.100.0/24' -o enp1s0 -j MASQUERADE
12 post-down iptables -t nat -D POSTROUTING -s '192.168.100.0/24' -o enp1s0 -j MASQUERADE
4.3 应用配置
1$ ifup -a