Application of NAT table for Linux

Source: Internet
Author: User

Iptables is very powerful, with a teacher said, "Only unexpected, not to do", of course, learning is the same way!

For example, an example of understanding NAT:

-The machine has two network cards, eth0 and Eth1,eth0 IP for 10.0.2.68, eth1 IP for 192.168.1.1;eth0 connected to the Internet, another machine 192.168.1.2 and eth1 interoperability!

How can I set up eth1 to connect to the Internet?

#echo "1" >/proc/sys/net/ipv4/ip_forward#iptables-t nat-a postrouting-s 192.168.1.0/24-o eth0-j MASQUERADE

The first command is the kernel parameter-related configuration file, which is designed to turn on the route forwarding function

The second article means: Iptables to Nat to do an IP forwarding operation, the-o option followed by the device name for the Egress network card, masquerade will automatically read eth0 now IP address and then do snat out Postrouting apply the rules in this chain after the packet is routed (all packets are processed first by this chain)

The firewall rules we're setting up are only saved in memory, and the rules are gone when the system restarts, so we're going to save the operation.

#service iptables Save

Iptables Backup and Recovery

If you want to clear all firewall rules, "iptables-f" is OK, but the best way

#service iptables Stop

This will invalidate the firewall, but once it is reset, the firewall automatically starts

A backup firewall rule task will be encountered in the future, just copy this file to

#sh/usr/local/sbin/iptables.sh#iptables-save > Myipt.rule#cat myipt.rule

To recover, use the following command to

#iptables-restore < Myipt.rule



This article is from the "Old seven Linux Operations Management" blog, please be sure to keep this source http://asd9577.blog.51cto.com/4291946/1930283

Application of NAT table for Linux

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.