The invention relates to the field of
cloud computing technologies, in particular to a method for implementing two-wire access through a
virtual machine with a single network card. The method comprises the following steps that firstly, kernel parameters of an
operating system are configured in a
host machine and IP (
Internet Protocol) forwarding is allowed; secondly, two network cards are configured in the
host machine, one network card is in bridge connection with a network bridge br1 and is provided with a
private IP for creating the
virtual machine; thirdly, the other network card is connected to a switch of an outer network and is in bridge connection with br0 for distributing a public IP of the
virtual machine, and the IP is not configured; fourthly, after the virtual
machine is created successfully, one
private IP is distributed to the virtual
machine; fifthly, when the virtual
machine needs two-wire access, a pair of public IPs is configured on the network bridge br0, a
virtual network interface of the br0 is marked through id of the virtual machine, and the pair of public IPs is respectively mapped to the
private IP of the virtual machine by utilizing an NAT (
Network Address Translation) mapping rule; lastly, when the two-wire access is not needed, the NAT mapping rule corresponding to the virtual machine is deleted. According to the method, access of a two-wire network of the virtual machine is implemented under the environment of the single network card, and the method can be used for network access of the virtual machine.