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