标签:kvm
vi /etc/sysctl.conf
net.ipv4.ip_forward=1
sysctl -p
#!/bin/bash
#vnc端口映射
let vncport=7020
let deskport=6020
let ipnum=20
let ipstop=50
iptables -t nat -A POSTROUTING -p tcp --dport 5900 -j SNAT --to-source 192.168.10.1
iptables -t nat -A POSTROUTING -p tcp --dport 3389 -j SNAT --to-source 192.168.10.1
echo -e "端口映射情况如下:\nwindows的ip地址\t\tvnc登录地址\t\t\t远程桌面登录地址"
while [ $ipnum -le $ipstop ];do
#vnc端口映射
iptables -t nat -A PREROUTING -d 10.199.2.12 -p tcp --dport $vncport -j DNAT --to-destination 192.168.10.$ipnum:5900
#远程桌面端口映射
iptables -t nat -A PREROUTING -d 10.199.2.12 -p tcp --dport $deskport -j DNAT --to-destination 192.168.10.$ipnum:3389
echo -e "192.168.10.$ipnum\t\t10.199.2.12:$vncport\t\t10.199.2.12:$deskport"
let vncport=vncport+1
let deskport=deskport+1
let ipnum=ipnum+1
done
echo -e "iptables -t nat -vnL --line-number\t查看映射表\niptables -t nat -F\t清空映射表"
标签:kvm
原文地址:http://blog.51cto.com/quliren/2091157