LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Virtualization and Cloud (https://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/)
-   -   qemu network same ip (https://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/qemu-network-same-ip-4175602370/)

end 03-22-2017 09:51 PM

qemu network same ip
 
hy

i run qemu like this but for every machine he give same ip. xml file of virbr0 have dhcp range.

when i run with virsh i dont have this problem just when run like this

Code:

qemu-system-x86_64 -vga std -nographic  -vnc :2 -m 1G -smp 4 -enable-kvm -drive format=raw,file=/home/ja/vm/kali.img -usbdevice tablet  -net bridge,br=virbr0  -net nic,model=virtio  &

dijetlo 03-22-2017 11:20 PM

Kako si bio moj prijatelj? :)

Do you have dnsmasq installed to act as your dhcp front-end?

You know I do love a good manual...

Virsh is chatting up libvirt, which has an internal dhcp capability.

end 03-23-2017 08:52 AM

re
 
good my frend good expect this kind of problems. how are you? where are you from by the way i need put you in some place on earth :)

i have problem with this dnsmasq i set it up and bind to virbr0, remove default.xml that virsh use. and when i start virsh net-start default he pull same config like xml is still there. is there another way to start virbr0 interface.

actualy dont bother with this.

new approach

if i create vlan like this https://wiki.archlinux.org/index.php/VLAN

how to use that interface in qemu command

end 03-23-2017 01:10 PM

hy

in libvirt network default.xml i remove dhcp options, in dns masq.conf set interface to virbr0 and add dhcp-range. when run vm they dont get ip no problem i ad it manually have internet acces just these two machine canot ping or comunicate in any way.

end 03-24-2017 06:24 PM

what i try

kill all dnsmasq process, then

Code:

dnsmasq --interface=virbr0 --bind-interfaces --dhcp-range=192.168.122.2,192.168.122.10
start vm

Code:

qemu-system-x86_64 -vga std -display none -vnc :1 -m 2G -smp 2 -enable-kvm -drive format=raw,file=/home/ja/vm/w7.img -usbdevice tablet  -net bridge,br=virbr0 -net nic,model=virtio
dhcp gives same ip to this vm and another. if i change it manually ping whant work.if i kill dnsmasq and start vm ip is not given.

then i try

Code:

qemu-system-x86_64 -vga std -nographic  -vnc :2 -m 1G -smp 4 -enable-kvm
-drive format=raw,file=/home/ja/vm/kali.img -usbdevice tablet  -net
bridge,br=virbr0,net=192.168.122.0/24,host=192.168.122.1,dhcpstart=192.168.122.10 
-net nic,model=virtio

when dnsmssq is on above code ignores ip setup and use dnsmasq, when dnsmasq is off above code again gives same ip.

then i try user mode

Code:

qemu-system-x86_64 -vga std -nographic  -vnc :2 -m 1G -smp 4
-enable-kvm -drive format=raw,file=/home/ja/vm/kali.img -usbdevice
tablet  -net
user,net=192.168.122.0/24,host=192.168.122.1,dhcpstart=192.168.122.10 
-net nic,model=virtio

again give same ip if i change dhcpstart when running second vm to 192.168.122.9 again canot ping. i reed that in user mode network ping whant work, but i have some python scripts with tcp socket connection that i testing beatwen vm's from any script i canot make connections beatwen vm's. firewall off or on with forwarded options on virbr0 same problem.

note:

when i use virsh to start vm's no problem in communication in any way. but virsh slow down my comp with 2 vm's i cannot nothing.

Prichiated

edited:

now i created tap and tap1 interfacewith same subnet 192.168.1.1/24

in dnsmasq.conf i added

interface=tap
interface=tap1

dhcprange=iprange
dhcprange=iprange

again dnsmasq gives same ip to boath vm's. so defenetly problem with dnsmasq.

edited:

i can do thing like this

tap=192.168.1.1
tap1=192.168.2.1

dnsmasq

interface=tap
interface=tap1

dhcprange=192.168.1.2,192.168.1.10,12h
dhcprange=192.168.2.2,192.168.2.10,12h

Code:

iptables -I INPUT -i tap -j ACCEPT
iptables -I OUTPUT -o tap -j ACCEPT

iptables -I INPUT -i tap1  -j ACCEPT
iptables -I OUTPUT -o tap1  -j ACCEPT

iptables -I FORWARD -i tap -o tap1 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
iptables -I FORWARD -i tap1 -o tap  -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT

Code:

sudo  qemu-system-x86_64 -vga std -nographic  -vnc :2 -m 1G -smp 4
-enable-kvm -drive format=raw,file=/home/ja/vm/kali.img -usbdevice
tablet  -net nic,model=virtio -net
tap,ifname=tap,script=no,downscript=no

this way comunication beatwen vm's work.

So if anyone know way dnsmasq giving same ip to two different machines i will prichiated. even i like most last solution, its complicating life beacouse i only test python scripts beatwen vm's. And maybe in future i will need dnsmasq to work proper.

thanks


All times are GMT -5. The time now is 03:55 AM.