Set Linux as a gateway server (NAT translation)

Source: Internet
Author: User
Article title: set Linux as a gateway server (NAT translation ). 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.

1. two network interfaces, one internal interface and one external interface

2. NAT translation (internal)

Procedure:

1. set the Linux kernel to support ip packet forwarding:
Echo "1">/proc/sys/net/ipv4/ip_forward

2. load the necessary kernel modules for NAT:
Modprobe ip_tables
Modprobe ip_nat_ftp

Modprobe ip_nat_irc
Modprobe ip_conntrack
Modprobe ip_conntrack_ftp
Modprobe ip_conntrack_irc

3. initialize the rule table in iptables:
Iptables-F
Iptables-X
Iptables-Z
Iptables-F-t nat
Iptables-X-t nat
Iptables-Z-t nat

4. set the default rule of the rule chain:
Iptables-P INPUT DROP
Iptables-P OUTPUT ACCEPT
Iptables-P FORWARD ACCEPT
Iptables-t nat-P PREROUTING ACCEPT
Iptables -- t nat-P POSTROUTING ACCEPT
Iptables-t nat-P OUTPUT ACCEPT

5. Add IP camouflage rules:
Iptables-t nat-a postouting-S 192.168.1.0/24-O eth1-j MASQUERADE
Where: eth1 is an Internet Nic, 192.168.1.0/24 is an internal local address, and MASQUERADE is a compliant packet that can pass through

6. Save
Iptables-save> nat-1.1
Service iptables save

 

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.