A simple practice of NAT using IPtables in RHLE5 operating system

Source: Internet
Author: User
Article title: a simple practice of NAT using IPtables in RHLE5 operating system. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Implementation: The Linux host performs routing to achieve shared internet access for the subnet. Two IP addresses, one public IP address (22.33.44.55) and one internal and external gateway (192.168.0.254 ).

First, enable route forwarding, and ensure that it takes effect after reboot. Follow these steps:

1: modify/etc/sycctl. conf to enable route forwarding.

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

Net. ipv4.ip _ forward = 1

2: effective immediately

[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

Add the NAT of iptables to ensure that the boot route takes effect.

1: Add NAT for iptable

[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 it will still take effect after restart.

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

3: Start iptables

[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 whether the Internet can be accessed in a subnet. 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.