编辑/etc/network/interfaces
nano /etc/network/interfaces
添加vmbr2
auto vmbr2 iface vmbr2 inet static address 192.168.0.254 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 iptables -t nat -A POSTROUTING -s '192.168.0.0/24' -o vmbr0 -j MASQUERADE post-down iptables -t nat -D POSTROUTING -s '192.168.0.0/24' -o vmbr0 -j MASQUERADE
开启新网卡vmbr2
ifup vmbr2
创建新虚拟机,网卡选桥接,选择新的vmbr2
手动设置类似以下的IP
ipaddress 192.168.0.1 netmask 255.255.255.0 broadcast 192.168.0.255 gateway 192.168.0.254 (ip vmbr2 on the host)
dns信息可以是8.8.8.8,8.8.4.4
端口转发方法1:
iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 1022 -j DNAT --to 192.168.0.1:22
用这种的话可以直接写在母鸡/etc/network/interfaces里,这样完整的内容就是
auto vmbr2 iface vmbr2 inet static address 192.168.0.254 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 iptables -t nat -A POSTROUTING -s '192.168.0.0/24' -o vmbr0 -j MASQUERADE post-down iptables -t nat -D POSTROUTING -s '192.168.0.0/24' -o vmbr0 -j MASQUERADE post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 1022 -j DNAT --to 192.168.0.1:22 post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 1022 -j DNAT --to 192.168.0.1:22
端口转发方法2:
在母鸡上执行
qm set 100 -args "--redir tcp:1022::22"
以上100是虚拟机id号,意思是将id为100的虚拟机的22端口转发到母鸡的1022端口上
除此之外,还可以直接编辑虚拟机配置文件/etc/pve/qemu-server/id号.conf
添加一行args: –redir tcp:11389::3389,类似如下:args: --redir tcp:11389::3389 balloon: 4096 bootdisk: virtio0 cores: 8 cpu: host ide2: local:iso/cn_windows_server_2008_r2_standard_enterprise_datacenter_and_web_with_sp1_x64_dvd_incl_virtio-140506-homemade-by-Jetso.iso,media=cdrom memory: 8192 name: WIN2K8 net0: virtio=00:xx:xx:xx:xx:xx,bridge=vmbr2 numa: 0 ostype: win7 smbios1: uuid=aebd16b6-2678-454e-9efd-xxxxxxxxxxx sockets: 1 virtio0: local:100/vm-100-disk-1.qcow2,size=40G参见http://help.ovh.co.uk/Proxmox
第二种方法测试不行!!!