Linux hosts do routing for subnets to realize shared Internet

Source: Internet
Author: User
Keywords Nbsp; iptables realize share the Internet kernel
Tags .net access aliyun default etc external gateway host

&http://www.aliyun.com/zixun/aggregation/37954.html ">NBSP; Implementation: Linux host to do the route for the subnet to achieve shared access. 2 IP, one public network IP (22.33.44.55), an internal and external gateway (192.168.0.254).

First turn on routing forwarding, and to ensure that the power-on reboot takes effect. The following actions:

1: Modify/etc/sycctl.conf, turn on routing forwarding.

[Root@kook ~]# vi/etc/sysctl.conf

Net.ipv4.ip_forward = 1

2: Immediate effect

[Root@kook ~]# Sysctl-p

Net.ipv4.ip_forward = 1

Net.ipv4.conf.default.rp_filter = 1

Net.ipv4.conf.default.accept_source_route = 0

KERNEL.SYSRQ = 0

Kernel.core_uses_pid = 1

Net.ipv4.tcp_syncookies = 1

KERNEL.MSGMNB = 65536

Kernel.msgmax = 65536

Kernel.shmmax = 4294967295

Kernel.shmall = 268435456

Adding iptables Nat also ensures that the boot route takes effect.

1: Add iptable NAT

[Root@kook ~]# iptables-t nat-a postrouting-s 192.168.10.0/24-o eth0-j Masquerade

2: Modify the default iptables, to ensure that the reboot is still in effect.

[Root@kook ~]# iptables-save >/etc/sysconfig/iptables

3: Let iptables boot

[Root@kook ~]# chkconfig iptables on

[Root@kook ~]# chkconfig--list iptables

Iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off

Test on the subnet to see if you can surf the web. Complete。

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.