Gateway setup in linux

Source: Internet
Author: User
For more information, see <G id = "1"> linux Enterprise Application </G> <G id = "2"> Linux server application </G>. Today, I did a hypothesis experiment on gateways in linux. The experiment principle is very simple, and the process is like this.

I have three virtual machines, all of which are enabled. The network is set to host-only (vmware). One is used as a gateway and connects two VLANs. Each vlan includes one virtual machine, the details are as follows:

Eth0: 192.168.254.2 netmask: 255.255.255.128 HOST 1
Eth1: 192.168.254.136 netmask 255.255.255.128 host 2

Eth3: 192.168.254.4 eth4: 192.168.254.131 netmask are both zookeeper 255.128 host 3

In the above circumstances, use the service iptables stop command under the root user to stop the firewalls of each host, and then use

Route add-net 192.168.254.128 netmask 255.255.255.128 gw 192.168.254.4

To create a route, remember to set netmask correctly. Otherwise, it will fail.

Similarly, it is created on host 2.

Route add-net 192.168.254.0 netmask 255.255.255.128 gw 192.168.254.131

Create a route

Enable the data packet forwarding service on host 3.

Echo 1>/proc/sys/net/ipv4/ip_forward

Complete

Note: ping is successful only when the entire network is correctly set.

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.