[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Network connection of a qemu guest.



* On 2021 10 Mar 17:36 -0600, peter@easthope.ca wrote:
> Hi again,
> 
> https://wiki.qemu.org/Documentation/Networking
> and 
> http://en.wikibooks.org/wiki/QEMU/Networking
> refer to qemu options -net, -netdev and -device whereas the manual for 
> qemu 1:3.1+dfsg-8+deb10u8 describes -nic as current.
> 
> For an virtual NE 2000 NIC this is my trial configuration.
> 
> qemu-system-i386 -nic user,ipv6=off,model=ne2k_pci ...
> 
> How is a static IP address set?  Should a subnet be specified in 
> /etc/network/interfaces? Analogous to a real machine subnetted on an 
> Ethernet cable?

I rely on the Qemu system to setup the IP address from the 10.x.x.x
block but that seems only to be accessible from inside the VM:

qemu-system-i386 \
    -enable-kvm \
    -smp cpus=2 \
    -m 2G \
    -device intel-hda \
    -device hda-duplex \
    -net nic,model=e1000 \
    -net user,hostfwd=tcp::2222-:22 \
    -hda ${HOME}/Qemu/buster/buster.qcow2

The '-ner user' line sets up port forwarding to the 2222 port on the
host machine from port 22 on the VM.

Then to SSH into the guest when I need to I have the following set in
~/.ssh/config:

Host buster
    HostName localhost
    Port 2222
    user "user"
    IdentityFile /home/"user"/.ssh/id_buster

Then a simple 'ssh buster' allows me to SSH from the host the VM is
running on.

Hopefully this can help you get started so you can make it accessible
from hosts on your LAN if that is what you're looking to do.

- Nate

-- 

"The optimist proclaims that we live in the best of all
possible worlds.  The pessimist fears this is true."

Web: https://www.n0nb.us
Projects: https://github.com/N0NB
GPG fingerprint: 82D6 4F6B 0E67 CD41 F689 BBA6 FB2C 5130 D55A 8819

Attachment: signature.asc
Description: PGP signature


Reply to: