Routing settings in linux (using linux as a router)

Source: Internet
Author: User
Route settings in linux (using linux as a router)-Linux Enterprise Application-Linux server application information. For details, refer to the following section. The network structure is as follows:
Pc1 -------------------------------- Linux ------------------------------ pc2
192.168.18.2 ------ 192.168.18.1 --- 192.168.19.1 ------- 192.168.19.2

Linux is a host with dual NICs used as a router.

Procedure
1. Set IP addresses
Pc1:
IP: 192.168.18.2 netmask: 255.255.255.0 gateway: 192.168.18.1
Pc2:
IP: 192.168.19.2 netmask: 255.255.255.0 gateway: 192.168.19.1
Linux:
Eth0: 192.168.18.1 netmask 255.255.255.0
Eth1: 192.168.19.1 netmask 255.255.255.0

2. Enable the routing function on linux
Echo "1">/proc/sys/net/ipv4/ip_forward

3. Test whether pc2 can be reached from pc1
Ping 192.168.19.2

4. To prevent the system from automatically disabling the routing function after the restart
Vi/etc/rc. d/rc. local Add the following content.
Echo "1">/proc/sys/net/ipv4/ip_forward

5. This simple linux host router for Static Routing is configured. Note that dynamic routing is generally used if there are too many routes, which is better and more convenient.

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.