Use your computer as a router

Source: Internet
Author: User

When you see the title, you don't think it's about routing simulation software?

No, it is a common terminal and a single Nic machine.

Maybe you will say that it is not surprising that a single Nic machine is using a router, such as cisco single-arm routing ......

But here we are talking about a general machine, or even the just-installed win95.

......

In fact, it is about the basic operation of the IP protocol in a single machine. This article is one-sided because it does not have a deep understanding of the operating mechanism of the IP protocol in the terminal.

After the IP protocol is installed on the computer, it becomes the cornerstone for you to access the Internet. The IP protocol group is responsible for connecting and Exploring each step.

The installation of the IP protocol must be bound to a network interface, that is, it must be installed with a NETWORK adapter, for example: MODEM Nic, virtual network adapter, VPN network adapter, dial-up network adapter, etc.

After the IP protocol is installed, a stack is created for the network connection, and a local loop of 127.0.0.x is created for the user. The local loop is automatically obtained or waiting for the user to manually set an IP address, publish yourself to the network and explore adjacent protocol carriers, listen for packets from the network, and communicate with each other according to network rules such as DHCP, DNS, and GATEWAY.

Different CIDR blocks in the INTERNET cannot access each other directly. You need to use the router packet forwarding function. The rule is based on an automatic or manual route information table.

In fact, the packet forwarding process exists in a single machine. The ROUTE command shows us a ROUTE information table:

C: \ WINNT \ system32> ROUTE PRINT
========================================================== ==========================================
Interface List
0x1... ms tcp Loopback interface
0x4000003... 00 XX a8 XX c7... Intel (R) PRO Adapter
========================================================== ==========================================
========================================================== ==========================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 192.168.0.1 192.168.0.111 1
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
192.168.0.0 255.255.255.0 192.168.0.111 192.168.0.111 1
192.168.0.111 255.255.255.255 127.0.0.1 127.0.0.1 1
192.168.0.255 255.255.255.255 192.168.0.111 192.168.0.111 1
224.0.0.0 224.0.0.0 192.168.0.111 192.168.0.111 1
255.255.255.255 255.255.255.255 192.168.0.111 192.168.0.111 1
Default Gateway: 192.168.0.1
========================================================== ==========================================
Persistent Routes:
None

This table shows how the single-host internal IP protocol maintains packet forwarding for different network segments. You may think that the computer PC should only exist in one network segment, here, we will look at the Protocol from a micro-perspective.

In the internal environment, the network segment related to computer work is:

1: 255.255.255.255 255.255.255.255 192.168.0.111 192.168.0.111 1

For Network Interface-oriented broadcast, No matter what network segment you are, LAN or INTERNET, this network segment exists. He is the basis for communication between the computer and the IP environment around him.

2: 224.0.0.0 224.0.0.0 192.168.0.111 192.168.0.111 1

Multicast addresses (multicast) are also known networks. Multicast addresses use the protocols or devices represented by different multicast addresses to discover the network environment.

3: 192.168.0.255 255.255.255.255 192.168.0.111 192.168.0.111 1

The broadcast address of the computer's network. Its existence is the basis for communication with machines in the same network segment.

4: 192.168.0.111 255.255.255.255 127.0.0.1 127.0.0.1 1

The computer's own IP address accesses the loop of its own IP address. This route defines that if this computer accesses its own IP address and does not pass through another gateway, it directly accesses itself through the 127.0.0.1 local loop IP address. It is equivalent to your own gateway.

5: 192.168.0.0 255.255.255.0 192.168.0.111 192.168.0.111 1

The network address of the computer, representing a network segment.

6: 127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1

The fixed address of the local loop specified by the IP protocol. Once the IP protocol is installed, you can use 127. X to access yourself. 127.0.0.1 stands for the unification of values.


7: 0.0.0.0 0.0.0.0 192.168.0.1 192.168.0.111 1

This is the same as the default router configuration. It indicates application-oriented. All data packets that are not multicast, broadcast, local loop, or local IP address are forwarded and accessed through the specified gateway.

The configuration of the route table in the vro is very difficult. It is very important to explain the order of the table items.

A reasonably ordered route table represents performance, security, and efficiency.

The static route table in the local computer, as shown in the above table, also uses the selection order, from bottom to top.

The loop route of the Local Computer is characteristic of the local static route table,

127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
192.168.0.111 255.255.255.255 127.0.0.1 127.0.0.1 1

The route information can be:

1: helpful.

It can help people without real network environments to test local network applications. The most commonly used is the local construction of IIS, network programming, and so on.

2: secure.

For example, many virtual subprograms, service programs, firewalls, and system processes run on a computer during startup must access or even connect to other program ports on the computer. With the local circuit, the gateway is not used to avoid system information leakage.

3: efficient.

Reduces network traffic and uses local loops directly to reduce the error wait time for poor network quality.

You can add and modify route tables on your own, such as connecting a computer to another computer to form a network.

However, their network ip addresses are not in the same network segment. You can modify the static route table to achieve network communication.

Some netizens asked me how to modify the static route table and communicate with different network segments. The most common answer on the internet is:

"Use route add xxx. xxx mask 255. xxx. xxx metric x to add a static route"

But in fact, we need to add two more.

The network protocol service targets multiple parties. It is not enough for only one machine to know a rule. Therefore, the static routing information of the two or more machines is added to each other at the same time, both parties know how to connect to establish a connection.

In this article, my understanding of TCP/IP is still quite simple. If something is wrong, please give me some advice.

Appendix:

Route command
ROUTE [-f] [-p] [command [destination] [MASK netmask] [gateway] [METRIC metric] [IF interface]


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.