Virtual Windows under Debian Virtual

    It was necessary here to whip up Windows on VPS. The hosting has chosen "cloud" from Overansan, because they give a small denyuka for testing during registration. If you keep the server turned off and turn it on as needed, then that's enough for a long time. However, subsequent payment with such a scheme can not afford much. But the problem is that there are, of course, no Windows as pre-installed systems. This article is a small but complete and working step-by-step guide on installing Windows on VPS under Debian. Other hosters may have a slightly different experience, but the essence is the same.

    We register, buy IP (hereinafter referred to as as an example), create a server with the installed Debian OS.
    Install the necessary: create a test disk on 100M Try to run:
    apt-get update
    apt-get install mc nano screen qemu bridge-utils vde2

    dd if=/dev/zero of=/root/hda.img count=1 bs=100M

    qemu -M pc -m 1024 -win2k-hack -localtime -hda /root/hda.img -boot d -net nic,vlan=0,macaddr=00:ce:53:e9:71:cf -net user,vlan=0 -name "test" -vnc :1

    If it starts, then try to access the console of our virtual machine using vncviewer. IP, port 1

    Did it work? Great, move on.

    The DNS in /etc/resolv.conf is already registered, but if you change the network settings, then we will no longer have the DNS, so we take the package down:
    apt-get remove --purge resolvconf

    We need to get normal control over Windows, for this let's push port 3389 out and make NAT so that from Windows had internet access.
    Turn on forwarding:
    echo 1 > /proc/sys/net/ipv4/ip_forward
    Run the editor:
    nano /etc/sysctl.conf
    next, look for the line # net.ipv4.ip_forward = 1 and remove the “lattice”.

    Add rules for NAT and forwarding: so that the rules are loaded at each start of network interfaces, save the current rules.
    iptables -A FORWARD -i eth0 -o eth1 -s -j ACCEPT
    iptables -A FORWARD -i eth1 -o eth0 -d -j ACCEPT
    iptables -t nat -A POSTROUTING -s -o eth1 -j SNAT --to-source
    iptables -A INPUT -s -i eth1 -p tcp -m tcp --dport 3389 -j ACCEPT
    iptables -A FORWARD -s -i eth1 -p tcp -m tcp --dport 3389 -j ACCEPT
    iptables -t nat -A PREROUTING -p tcp -i eth1 --dport 3389 -j DNAT --to-destination

    iptables-save > /etc/iptables.conf
    And in the file / etc / network / interfaces, add the boot line "post-up / sbin / iptables-restore </etc/iptables.conf"

    Now we edit the network settings file / etc / network / interfaces: In the file / etc / qemu- ifup comment everything We create / root / qemu-auto and assign the necessary rights: In / root / qemu-auto we write: And at startup by crown: Download from somewhere the image of the Windows installation disk, for example: Create a disk of the size we need, for me 5G was enough: And we start the virtual machine:

    auto eth0 lo eth1 br0

    iface lo inet loopback

    iface eth0 inet static

    iface eth1 inet static

    iface br0 inet static
    bridge_ports eth0
    bridge_fd 9
    bridge_hello 2
    bridge_maxage 12
    bridge_stp off

    post-up /sbin/iptables-restore < /etc/iptables.conf

    echo "" > /root/qemu-auto
    chmod 755 /root/qemu-auto
    chmod +s /root/qemu-auto


    sleep 30
    vde_tunctl -b
    sleep 1
    /sbin/ifconfig tap0 promisc up
    sleep 1
    brctl addif br0 tap0
    screen -Sdm qemu qemu -M pc -m 1024 -win2k-hack -localtime -cdrom /root/server2003.iso -hda /root/hda.img -boot d -net nic,macaddr=00:ce:53:e9:71:cf -net tap,ifname=tap0 -name "win2k3" -vnc :1

    crontab -e
    @reboot /root/qemu-auto

    wget http ://myserver/server2003.iso

    dd if=/dev/zero of=/root/hda.img count=50 bs=100M


    Then everything should be clear - with the help of VNC we go to the virtual machine (as in the test example above) and we see the familiar Windows installation screen. I installed the system on five slots (very fast, but expensive), then reduced the number to two - it works quite comfortably. This, by the way, is the advantage of cloud scalable hosting. In Windows, do not forget to configure the network - IP, mask, gateway, Google dns - and

    That's all, we got a fully working Windows Server.
    And, yes, do not forget after installation to remove "-vnc: 1" from the startup line or replace it with "-vnc"
    After the reboot, everything will come to life itself.

    Maybe he did something wrong - I see Debian almost the first time. But it works and works the way I need. Hope someone comes in handy.

    PS Do not consider hosting for advertising - I have nothing to do with them.

    Also popular now: