Thanks Pino for quick response.
Actually I use the libguestfs APIs in C++ program. Following your idea, I think I should try guestfs_set_network for this.
Please correct me if I have any misunderstanding.

Thanks,
Allen

2016-07-12 16:38 GMT+08:00 Pino Toscano <ptoscano@redhat.com>:
Hi,

On Tuesday, 12 July 2016 16:30:17 CEST Baochuan Wu wrote:
> I mounted virtual disks of CentOS 6.4 using libguestfs. After mounting, I
> tried to install some software using yum command. The yum command failed
> because of DNS failure, I think I correctly configured DNS(/etc/resolv.conf
> in the CentOS virtual disk).
>
> I wonder is it possible to access network inside libguestfs?

By "mounting", do you mean with guestfish?  If so, it has a --network
parameter to enable networking for the guest.  Other tools have similar
options to enable and disable the networking, and few of them
(virt-customize, virt-builder, and virt-dib) have networking enabled
by default.

--
Pino Toscano