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:
I did not try to use the nat feature of iptables to reference leemars for communication between the host and the host.
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.
--------------------------------------------------------------------------
Solution 2: Transparent Bridge (Layer 2)
I used this solution to generate a bridge and connect the virtual network card with the physical network card.
Host:
# 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 eth0 0.0.0.0 promisc # enable eth0 to enter promiscuous mode
# Ifconfig tap0 0.0.0.0 promisc # enable tap0 to enter promiscuous mode
# Brctl addbr br0 # Add a bridge
# Brctl addif br0 eth0 # Add eth0 to the bridge
# Ifconfig eth0 up # activate eth0
# Dhclient br0 # set IP address for br0
# Brctl addif br0 tap0 # Add tap0 to the bridge
# Ifconfig tap0 up # activate tap0
Guest:
Set the NIC to DHCP. Or an IP address in Subnet that is set to Host, as shown in the following example:
IP: 192.168.1.201
Netmask: 255.255.255.0
Gateway: 192.168.1.1
Allows direct access between the host and the host.
--------------------------------------------------------------------------
Solution 3: Transparent IP (Layer 3) proxy ARP bridge (by parprouted)
I did not try this because I need the parprouted software.
Host:
# Echo 1>/proc/sys/net/ipv4/ip_forward # enable the forwarding function
# Chmod 0666/dev/net/tun # Set Access Permissions
# Tunctl-t tap0-u leemars # create a tap device named tap0 and its owner is leemars
# Ip link set tap0 up # activate tap0
# Ip addr add 169.1.1.1/32 dev tap0 # specify any private address for tap0
# Parprouted [-d] ath0 tap0 # Start parprouted to listen to ath0 and tap0.d. The parameters are in Debug mode.
Guest:
Nic settings are as follows:
IP: 192.168.1.201
Netmask: 255.255.255.0
Gateway: 192.168.1.1
Guest-> WAN:
The Gateway provides WAN Access Services.
Guest-> Host:
Directly access the IP address of the Host.
Host-> Guest:
You can directly access the IP address of Guest.
--------------------------------------------------------------------------
Solution 4: ARP Proxy (by Linux) + Route
Route
Host:
# Echo 1>/proc/sys/net/ipv4/ip_forward # enable the forwarding function
# Chmod 0666/dev/net/tun # Set Access Permissions
# Tunctl-t tap0-u leemars # create a tap device named tap0 and its owner is leemars
# Ip link set tap0 up # activate tap0
# Route add-host 192.168.1.201 dev tap0 # add a route to redirect 192.168.1.201 to tap0
# Echo 1>/proc/sys/net/ipv4/conf/ath0/proxy_arp # Open ARP Proxy on ath0
# Echo 1>/proc/sys/net/ipv4/conf/tap0/proxy_arp # Open ARP Proxy on tap0
Guest:
Nic settings are as follows:
IP: 192.168.1.201
Netmask: 255.255.255.0
Gateway: 192.168.1.1
Mutual access is allowed.
3. Internal network
I don't know what it is.