Network settings of VirtualBox in Linux

Source: Internet
Author: User
Article title: network settings of VirtualBox in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Install some tools first

Apt-get install uml-utilities (tunctl is required)

Tunctl can generate a tap. I understand it as a virtual network card.

Apt-get install bridge-utils (required for brctl)

Brctl is used to set up a bridge.

The host is debian and the IP address is 192.168.1.2.

Eth0

The client is XP

Dhcp is enabled on the route. The address is 192.168.1.1.

There are three ways for virtualBox to access the Internet

Nat

This method does not need to be set on the client. it can be automatically captured and the obtained address is different from the external address.

Here I am

IP: 10.0.2.15

Gw: 10.0.2.2

You can access the Internet, but the host and host cannot access each other.

Host Interface

This is the most complex. leemars has four more solutions and directly references these four solutions.

-----------------------------------------------------------------------------

Solution 1:

In fact, the nat function of iptables is used to implement communication between the host and the host.

Referenced from leemars. I did not try this.

Host:

# Echo 1>/proc/sys/net/ipv4/ip_forward # enable the forwarding function

# Iptables-t nat-a postrouting-j MASQUERADE # use iptables to complete NAT

# Chmod 0666/dev/net/tun # set access permissions

# Tunctl-t tap0-u leemars # Create a tap device named tap0 and its owner is leemars

# Ifconfig tap0 up # activate tap0

# Ifconfig tap0 10.10.10.1 netmask 255.255.255.0 # specify the IP address and network segment for tap0 as 10.10.10.1/24.

Guest:

Nic settings are as follows:

IP: 10.10.10.10

Netmask: 255.255.255.0

Gateway: 10.10.10.1

Guest-> WAN:

The Linux iptables NAT function provides WAN access services.

Guest-> Host:

10.10.10.1 is the real Host. any access to the Host by Guest can be completed by accessing 10.10.10.1.

Host-> Guest:

10.10.10.10 is a real Guest. Host. any access to Guest can be completed by accessing 10.10.10.10.

-----------------------------------------------------------------------------

[1] [2] [3] Next page

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.