S
S
syxoi2016-06-09 16:12:22
linux
syxoi, 2016-06-09 16:12:22

How to setup network in qemu?

Hi all!
OS: Archlinux (6/9/2016)
I've been trying for the fifth day to set up a network in a virtual machine, but it doesn't work.
I tried -net nic,vlan=0 -net user,vlan=0 - the network card receives addresses, but there is no Internet, and most importantly, when you ping, the IP address is determined, but there is no Internet or a fig.
The machine starts like this: qemu-system-x86_64 -enable-kvm -m 2048M -smp 3 -hda hard -cdrom os.iso -boot d -vga qxl.
I also tried this: -net tap,vlan=0,ifname=tap0,script=no,downscript=no, assigned addresses to the host and guest, but it doesn't work, the host doesn't even ping!
As for the bridge, then:
There is a network interface eth0, I configure the bridge:
brctl addbr br0
btctl addif br0 eth0
и сеть пропадает, ввожу ifconfig up br0 и dhcpcd br0 и сети по прежнему нет.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
X
xibir, 2016-06-09
@xibir

Самый простой вариант не указывать -net параметр. Будет NAT. Интернет в виртуалке работать будет, хост и виртуальная машина по ip-адресу друг друга НЕ видят.

J
jcmvbkbc, 2016-06-10
@jcmvbkbc

Пробовал еще так: -net tap,vlan=0,ifname=tap0,script=no,downscript=no, назнал адреса хосту и гостевой, но не работает, хост даже не пингуется!

Регулярно пользуюсь этим способом, всё работает. Если стоит networkmanager надо следить за тем, чтобы он не потушил tap-интерфейс если qemu от него отключается.

Дмитрий Айткулов, 2016-06-10
@Scarfase1989

я на центосе с делал так

# add bridge "br0"
[[email protected] ~]# nmcli c add type bridge autoconnect yes con-name br0 ifname br0 
Connection 'br0' (0f4b7bc8-8c7a-461a-bff1-d516b941a6ec) successfully added.
# set IP for br0
[[email protected] ~]# nmcli c modify br0 ipv4.addresses 10.0.0.30/24 ipv4.method manual 
# set Gateway for br0
[[email protected] ~]# nmcli c modify br0 ipv4.gateway 10.0.0.1 
# set DNS for "br0"
[[email protected] ~]# nmcli c modify br0 ipv4.dns 10.0.0.1 
# remove the current setting
[[email protected] ~]# nmcli c delete eno16777736 
# add an interface again as a member of br0
[[email protected] ~]# nmcli c add type bridge-slave autoconnect yes con-name eno16777736 ifname eno16777736 master br0 
# restart
[[email protected] ~]# reboot

change the IP and the names of network cards for yourself. By the way, there was another problem in that before this setting, the boss backed up eth0 and it tried to boot and interfered with work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question