# qemu startup script causes network error

## az20110303

here's my script for vm to startup

 *Quote:*   

> ETH0IP=192.168.0.101
> 
> GATEWAY=192.168.0.1
> 
> BROADCAST=192.168.0.255
> ...

 

it works fine except that after booting vm host is unable to translate names to IPs. So if i type in browser google.com i get error, but if i type http://209.85.169.104 it opens.

But VM works normally with names!

after shuting down vm this problem exists. only reboot helps. 

thanks for any help!

----------

## Mad Merlin

You could save yourself a lot of grief by just normally using br0 with eth0 bridged in, there's really no reason not to. qemu-kvm's default script (qemu-ifup) will bridge a dynamically created tap device into the bridge with the default route for you and remove it on shutdown. You can go one step further and statically create and bridge in the tap at startup time and your VM startup script becomes a single line long (and doesn't even need sudo).

Anyways, you're probably using DHCP normally with eth0, right? So, when you bring down eth0 your DHCP client exits and removes the nameserver stored in /etc/resolv.conf and of course you no longer can resolve any DNS entries. If so, you need to run your DHCP client on br0 once you bring it up instead of setting the IP manually, this will give you an IP and will populate your /etc/resolv.conf file once again.

----------

## Hu

Why does every command in that script start with sudo?  If the script needs to be privileged to run, then check for that and abort on an unprivileged run.  Let the user sudo the script.

----------

