Easy configuration of Linux dual-nic virtual Routing

Source: Internet
Author: User

Linux is becoming more and more popular among computer users. As a result, many users may encounter the problem of dual-nic virtual routing in Linux when learning Linux, here we will introduce the solution for the Linux dual-nic virtual routing. Here we will share with you. Reason: I have been in the lab for two months. I am not satisfied with this, that is, the network speed is too slow. I can only access the Internet with one desktop and notebook.

Recently, I was thinking about how to use the existing hardware resources to connect two machines to the Internet at the same time. I want to use a network port's conversion port, that is, the one that changes the two ports, but it takes half the distance. I thought of the line from the routing network port to the conversion port, and used the network cable. That is to say, just like the original type of bus network, only one machine can interact with the routing, so the gray-faced back to the dormitory. Suddenly I thought of another method, using a dual network card, a normal network connection, another virtual route, and then creating an intranet. After checking the Internet, we can achieve it. Well, it is not difficult to find an independent network card as far as the lab is concerned ~~~~

The configuration process is as follows:
Environment: Linux
Desktop: P1, two NICs eth0, eth1
Notebook: P2
Lab Intranet address: 192.168.2.12 Gateway: 192.168.2.1

Objective: The eth1 of P2 and P1 form the virtual Intranet 192.168.1.0. The eth0 of P1 and the original vro form the Intranet 192.168.2.0 of the lab.

Steps:
P1 settings:
Switch root user sudo-s)
Ifconfig eth0 192.168.2.12 netmask 255.255.0.0; configure eth0, lab Intranet
Ifconfig eth1 192.168.1.1 netmask 255.255.255.0; configure eth1, virtual Intranet
Route add-net 192.168.1.0 netmask route 255.255.0 dev eth1; generate a virtual Intranet route table
Route add default gw 192.168.2.1; add P1 default route
Echo '1'>/proc/sys/net/ipv4/ip_forward; alternatively, you can enable the forwarding function by adding net. ipv4.ip _ forward = 1 in/etc/sysctl. conf.
Iptables-F; Clear the set rule chain
Iptables-P INPUT ACCEPT
Iptables-p forward accept; defines the chain rule
Iptables-t nat-a postrouting-o eth0-j MASQUERADE; Enable nat

P2 settings:
Switch rootsudo-s)
Ifconfig eth0 192.168.1.2 netmask 255.255.255.0
Route add default gw 192.168.1.1

Test:
In this case, P2 should be able to connect to the Internet normally. If any problem occurs, check the value of "/proc/sys/net/ipv4/ip_forward" and set DNS for P2, if you need a proxy, you 'd better set it up, but it doesn't matter if you don't set it, because its package needs to be forwarded by P1, and P1 has already opened the proxy, but it seems that the speed will be slower.

In this way, you can easily complete the Linux dual-nic virtual route.

  1. Operation notes: Linux hard disk partition
  2. Install db2 in Linux
  3. Install PPStream network TV in Linux
  4. Protect your Linux operating system
  5. Checks whether Linux servers are attacked by hackers.

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.