Enabling the route forwarding function in Linux

Source: Internet
Author: User
The Linux kernel configuration for enabling the Linux route forwarding function contains the routing function by default, but this function is not enabled by the default system. To enable Linux routing, you can adjust the network parameters of the kernel. To configure and adjust kernel parameters, run the sysctl command. The LINUX kernel configuration is enabled by default, but the default system does not enable this function. To enable Linux routing, you can adjust the network parameters of the kernel. To configure and adjust kernel parameters, run the sysctl command. There are two Usage cases for the LINUX route forwarding function. this experiment is the second case. 1. First, the LINUX machine needs two IP addresses, one being the Internet IP address and the other being the intranet IP address. 2. the available IP addresses in the intranet are insufficient. you can use this method to create a new CIDR block so that the intranet has enough IP addresses. Experiment Records: 1. set the intranet IP address: [root @ Router ~] # Vi/etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE = eth0 HWADDR = 00: 50: 56: 98: 6D: 8C TYPE = Ethernet UUID = 48036192-4306-439f-bb7b-f08f5600d4df ONBOOT = yes NM_CONTROLLED = yes BOOTPROTO = none IPADDR = 192.168.11.211 NETMASK = 255.255.255.0 GATEWAY = 192.168.11.1 DNS1 = 255.dns2 = 202.106.0.20 2. set the IP address of the new network segment: [root @ Router ~] # Cat/etc/sysconfig/network-scripts/ifcfg-eth1 DEVICE = eth1 TYPE = Ethernet UUID = policonboot = yes NM_CONTROLLED = yes BOOTPROTO = none PREFIX = 24 DEFROUTE = yes else 4_failure_fatal = yes else 6init = no HWADDR = 00: 50: 56: 98: 5A: 4C IPADDR = 192.168.90.254 NETMASK = 255.255.255.0 3. modify the kernel parameter so that it will take effect after restarting [root @ Router ~] # Vi/etc/sysctl. conf net. ipv4.ip _ forward = 1 change "0" to "1" 4. take effect after restarting the server [root @ Router ~] # Reboot 5. restart test [root @ Router ~] # Ifconfig eth0 Link encap: Ethernet HWaddr 00: 50: 56: 98: 6D: 8C inet addr: 192.168.11.211 Bcast: 192.168.11.255 Mask: 255.255.255.0 inet6 addr: fe80: 250: 56ff: fe98: 6d8c/64 Scope: Link up broadcast running multicast mtu: 1500 Metric: 1 RX packets: 6283 errors: 0 dropped: 0 overruns: 0 frame: 0 TX packets: 808 errors: 0 dropped: 0 overruns: 0 carrier: 0 collisions: 0 txqueuelen: 1000 RX bytes: 485497 (474.1 KiB) TX bytes: 121455 (118.6 KiB) eth1 Link encap: Ethernet HWaddr 00: 50: 56: 98: 5A: 4C inet addr: 192.168.90.254 Bcast: 192.168.90.255 Mask: 255.255.0 inet6 addr: fe80: 250: 56ff: fe98: 5a4c/64 Scope: Link up broadcast running multicast mtu: 1500 Metric: 1 RX packets: 5421 errors: 0 dropped: 0 overruns: 0 frame: 0 TX packets: 13 errors: 0 dropped: 0 overruns: 0 carrier: 0 collisions: 0 txqueuelen: 1000 RX bytes: 384977 (375.9 KiB) T X bytes: 918 (918.0 B) [root @ Router ~] # Ping www.baidu.com PING www.a.shifen.com (61.135.169.105) 56 (84) bytes of data. 64 bytes from 61.135.169.105: icmp_seq = 1 ttl = 54 time = 31.0 MS 64 bytes from 61.135.169.105: icmp_seq = 2 ttl = 54 time = 4.54 MS
 

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.