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 188.127.231.111 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 188.127.231.111, 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 10.1.1.0/24 -j ACCEPT
    iptables -A FORWARD -i eth1 -o eth0 -d 10.1.1.0/24 -j ACCEPT
    iptables -t nat -A POSTROUTING -s 10.1.1.0/24 -o eth1 -j SNAT --to-source 188.127.231.111
    iptables -A INPUT -s 188.127.231.111 -i eth1 -p tcp -m tcp --dport 3389 -j ACCEPT
    iptables -A FORWARD -s 188.127.231.111 -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 10.1.1.2:3389



    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
    address 0.0.0.0

    iface eth1 inet static
    address 188.127.231.111
    netmask 255.255.255.0
    gateway 188.127.231.254

    iface br0 inet static
    address 10.1.1.1
    netmask 255.255.255.0
    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



    #!/bin/bash

    sleep 30
    vde_tunctl -b
    sleep 1
    /sbin/ifconfig tap0 0.0.0.0 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


    ./qemu-auto

    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 10.1.1.2, mask 255.255.255.0, gateway 10.1.1.1, Google dns - 8.8.8.8 and 8.8.4.4.

    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 127.0.0.1:1"
    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: