Open patatetom opened 1 year ago
I also use to do this. Did you find a solution @patatetom ?
I'm now using tap0
with dnsmasq
and vde_switch
like this :
# ip tuntap add tap0 mode tap
# ip addr add 192.168.101.254/24 dev tap0
# ip link set tap0 up
# dnsmasq -d -C <( cat <<~~~
port=0
interface=tap0
dhcp-range=192.168.101.1,192.168.101.99
dhcp-option=1,255.255.255.0
dhcp-option=6,208.67.222.220,208.67.220.222
~~~
)
_the above commands could be grouped in a script named
vde_slirp
_
$ vde_switch -tap tap0 -daemon
$ qemu ... -nic vde,mac=52:54:00:11:11:11
but I randomly encounter some strange errors on the virtual machine side :
dhcpcd[...]: enp0s2: soliciting a DHCP lease
dhcpcd[...]: enp0s2: checksum failure from 192.168.101.254
dhcpcd[...]: enp0s2: checksum failure from 192.168.101.254
dhcpcd[...]: enp0s2: checksum failure from 192.168.101.254
and in this case, the virtual network card enp0s2
does not get a network address...
In order to have dnsmasq running on my vde_switch, I do the following (in an init script), using your values:
VDE_TAP=tap0
VDE_NET=192.168.101
VDE_MASQ_DEV=`ip route list|grep default|tail -1|cut -f5 -d ' '`
VDE_DHCP_MIN=1
VDE_DHCP_MAX=99
VDE_IP_ADDR=192.168.101.254
VDE_DNS_DOM=decentral.ch
DNSMASQ_USER=dnsmasq
#DNSMASQ_EXTOPTS="--enable-tftp --dhcp-boot=/var/lib/qemu-vde/pxeboot/pxelinux.0"
#
# above are all specific definitions, the rest is now what's run
#
VDE_DHCP_RANGE=$VDE_NET.$VDE_DHCP_MIN,$VDE_NET.$VDE_DHCP_MAX
modprobe kvm-intel
echo "1024" > /proc/sys/dev/hpet/max-user-freq
modprobe tun
vde_switch -tap $VDE_TAP --pidfile /run/qemu-vde_switch.pid -daemon
chmod -R a+rwx /var/run/vde.ctl
# I still user old ifconfig, just replace with your iproute2 ip commands
ifconfig $VDE_TAP $VDE_IP_ADDR broadcast $VDE_NET.255 netmask 255.255.255.0
ifconfig $VDE_TAP up
echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o $VDE_MASQ_DEV -j MASQUERADE
dnsmasq --log-queries --user=$DNSMASQ_USER \
--dhcp-leasefile=/var/lib/misc/qemu-vde-dnsmasq.leases \
--dhcp-range=$VDE_DHCP_RANGE,255.255.255.0,$VDE_NET.255,8h\
--interface=$VDE_TAP\
--domain=$VDE_DNS_DOM \
$DNSMASQ_EXTOPTS \
--pid-file=/run/qemu-vde-dnsmasq.pid
# end of processing
Now, this runs on my qemu setup quite reliable as a virtual NAT'ed vde router, by setting a correct pxe boot image in DNSMASQ_EXTOPTS, I even also get the abilty to pxe boot a qemu vm from there.
If you try to achieve something similar, this might help.
hi, I used
slirpvde
to implement very simply a DHCP server on my VDE switch : given the abandonment ofslirpvde
, is there an alternative as simple ? regards, lacsaP.