VBox Virtual machine and host (host) communication principle and SOCAT (socket cat) Brief introduction

Source: Internet
Author: User
Tags symlink

Objective

When attempting to use SOCAT to establish server-side interface forwarding, it is found that the principle of virtual machine access network is not very understanding, and then the Internet to find information to understand how it is, and thus have this summary blog. Socat can establish a full-duplex communication channel between the server ports, which can be used for port data forwarding, which is said to be one of the three Linux/unix system artifacts.

Virtual machine Virtual Network connection mode

1. Bridging mode

The virtual network card is bridged directly on the physical network card, the virtual machine and the host position is equal, the equivalent of the LAN adds a new machine, the virtual machine assigned IP is the real IP address of the LAN, host and virtual machine and other LAN host and virtual machine can access each other

2. Host only (HOST-ONLY) adaptation mode

Host can access the virtual machine, virtual inaccessible host (host) and other LAN host, LAN other host can not access the virtual machine, virtual machine and LAN isolation

3.NAT (network address translation) mode

Virtual NAT device to access the internal and external network, the LAN host can not access the virtual machine, the host is no exception, if you need to access the virtual machine services, virtual network cards need to set up port forwarding, virtual machines can not access each other

OSI Open Network Seven layer model

Physical layer (transfer media), Data link layer (data channel), Network layer (routing), Transport layer (data transmission), Session layer, presentation layer, application layer

TCP/IP four layer model

Application layer, Transport layer, Internet connectivity layer, network access layer

TCP/IP four layer model and OSI seven layer model

The Internet uses a TCP/IP four layer model to connect to each network

Corresponding relationships such as:

Virtual network card

Using software to simulate the function of real card, also known as virtual network adapter, can realize virtual hub, VPN function, etc.

Virtual network card Implementation principle

Tun/tap driver is an implementation of the virtual network card driver, is open source, with it as an example to explain the implementation principle.

The virtual network card sends the data not through the real physical network card, but through the application which sends to the user state, it sends the data through the real network card again. User state and kernel mentality programs exchange data through character device files.

Socat Brief Introduction

Socat is a repeater, can establish a full-duplex channel data forwarding function between 2 terminals, the function is very powerful, is one of the three major Linux/unix system artifacts.

Socat usage

1. The input stream and the server establish a communication channel, set up, you can send data

socat - TCP4:www.domain.org:80

2. Server A port 5000 request Unified forwarding to B server Port 6000 processing

socat-d-d-lf/var/log/socat.log tcp4-listen:5000,reuseaddr,fork tcp4:b Server ip/domain:6000

。。。。。。 There are a number of other uses that can be found in the official documentation links listed below

Network equipment

1. What is a switch

English is called "switch", a network device for the transmission of Electrical (optical) signals, which can provide a proprietary signal path to any 2 network nodes of the access switch, which works in the data link layer of the OSI network model.

2. What is a hub

English is called "hub", meaning "center". Hubs are devices that connect multiple Ethernet twisted-pair or fiber-optic assemblies to the same piece of physical media. Hubs work in the physical layer of the OSI network model. It can only be contracted in the form of broadcast.

3. What is a router

Router (Router), also known as Gateway device, is a device that connects each LAN and WAN in the Internet, it automatically chooses and sets the route according to the situation of the channel, and sends the signal in the order of the best path. Work in the network layer of the OSI network model.

Problem

1. Bridge mode virtual machine cannot ping the host

Check the data, found that because of WIN7 firewall limitations, find the firewall Advanced Settings-"Inbound rules-" File and Printer Sharing (Echo request-icmpv4-in Private public network)-"open rules

2.NAT mode, virtual machines cannot access each other under the same host

Check the data, all virtual machines that use NAT mode cannot access each other.

3.socat forwarding to other servers will fail

The reason may be that the server being received has security restrictions

4.socat Compilation installation Prompt error

Tar:socat-1.7.3.0/configure.ac:cannot create symlink to ' configure.in ': Read-only file system
Tar:error exit delayed from previous errors

Check the data, because VBox default does not support shared directory symlink, the following is the search for the link

https://github.com/mitchellh/vagrant/issues/713

Http://superuser.com/questions/446362/why-cant-i-create-soft-link-on-vboxsf-file-system

Postscript

The use of spare time, work space, the side of the investigation data side practice, interrupted the completion of this article, basically achieve their own purposes. When I wrote this article, I remembered a long time ago Bo friends wrote a sentence: You can know what you do not know, but you can not know the ambiguity of a half solution. The words are very sensible, people still need to toss some good.

Resources

[1] Bridge mode WIN7 virtual machine cannot ping the host

http://blog.csdn.net/mmyzlinyingjie/article/details/21468365

[2] VBox NAT Network Explanation

http://huzhangsheng.blog.163.com/blog/static/34787784200802801435931/

[3] VBox Virtual network card connection method introduction

Http://blog.sina.com.cn/s/blog_7de9d5d80100t2uw.html

[4] Virtual machine Three network connection modes (bridged, NAT, host-only)

Http://www.360doc.com/content/11/0507/15/3508740_115023160.shtml

[5] The relationship between the virtual network card and the host network card under VMware workstation VMnet1 the connection mode image from this

Http://www.cnblogs.com/lzhdim/archive/2011/08/03/2125717.html

[6] VirtualBox four ways to connect to your network

Http://www.cnblogs.com/adforce/p/3363373.html

[7] Open Systems Interconnect Reference Model

http://baike.baidu.com/view/486949.htm?fromtitle=OSI%E4%B8%83%E5%B1%82%E6%A8%A1%E5%9E%8B&fromid=9763441 &type=syn

[8] TCP/IP Reference Model

Http://baike.baidu.com/view/1792633.htm

[9] A comparison of 2 models from the TCP/IP four-layer model and the OSI seven-layer model is derived from this

Http://book.51cto.com/art/200906/127291.htm

[10] Virtual network card

Http://baike.baidu.com/view/545.htm

[11] Virtual NIC and OpenVPN

Http://www.cnblogs.com/kernelfans/archive/2009/06/06/1497805.html

[12] Tun/tap differences

Http://www.cnblogs.com/adodo1/p/4327553.html

[13] Virtual network card TUN/TAP driver design principle virtual network card implementation schematic 1 from here

Http://www.cnblogs.com/happyhotty/articles/1933051.html

[14] Network Virtualization Technology (II): Tun/tap macvlan macvtap Virtual network card implementation schematic 2 from here

Http://www.cnblogs.com/yudar/p/4630958.html

[15] Baidu Encyclopedia-switch

Http://baike.baidu.com/view/1077.htm

[16] Interactive Encyclopedia-Switches

Http://www.baike.com/wiki/%E4%BA%A4%E6%8D%A2%E6%9C%BA

[17] Baidu Encyclopedia-Hub

Http://baike.baidu.com/view/7770.htm

[18] Baidu encyclopedia-routers

Http://baike.baidu.com/view/1360.htm

[19] Using Socat for port forwarding

Http://www.cnblogs.com/lexus/archive/2012/12/02/2798796.html

[20]socat Official Document-readme

Http://www.dest-unreach.org/socat/doc/README

[21]socat Official documentation-detailed description

Http://www.dest-unreach.org/socat/doc/socat.html

[21]socat Home

http://www.dest-unreach.org/socat/

[22]socat:some Useful commands

Http://www.cnblogs.com/shangdawei/p/3843039.html

VBox Virtual machine and host (host) communication principle and SOCAT (socket cat) Brief introduction

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.