Iptables learning 011. when the routing forwarding function is enabled, [plain] echo1 & gt;/proc/sys/net/ipv4/ip_forward is temporarily enabled. the default ip_forward value is zero and forwarding is not allowed. you can simply change it to 1. The modification takes effect immediately, that is, the kernel has enabled the ip forwarding function. Permanent launch... iptables learning 01 1. when the routing forwarding function is enabled, [plain] echo 1>/proc/sys/net/ipv4/ip_forward is temporarily enabled. the default ip_forward value is zero, and forwarding is not allowed. you can change it to 1. The modification takes effect immediately, that is, the kernel has enabled the ip forwarding function. Enable [plain] sudo vim/etc/sysctl permanently. conf # enable the route forwarding function permanently. net. ipv4.ip _ forward = 1 sudo sysctl-p sudo/etc/init. d/procpsrestart # Restart the procps service (# sysctl-p) iptables [-t table name] operator [rule chain name] [rule] several operations on the chain, -I insert-A append-R replace-D delete-L list display-F clear all rules in the chain-P set the chain default action ACCEPT REJECT DROP-Z counter reset-N definition A new rule chain-X deletes the defined rule chain-I will place the rule on the first line, -A will be placed in the last row for the rule operation:-A append-I insert-D delete example [plain] iptables-t filter-A FORWARD-s 10.1. 1.11-d 202.1.1.1-j ACCEPT: append a rule to the end of the FORWARD chain in the filter table. allow (-j ACCEPT) data packets whose source address is 10.1.1.11 and destination address is 202.1.1.1 pass through. -T is followed by the table name,-A is followed by the Chain name,-s is the source address,-d is the destination address, and-j is the processing direction. In iptables, the default table name is filter. Therefore, you can omit-t filter and write it directly: [plain] iptables-a forward-s 10.1.1.11-d 202.1.1.1-j ACCEPT-s match source address-d match destination address-I inbound interface match-o outbound interface match-sport source port match -- dport target Port match-j jump, that is, there is another package direction! Parameter, use! This is the opposite. The-s parameter specifies the source address. if you use this parameter to tell netfilter how to handle a packet that matches the source address, you can specify a unicast IP address, you can also specify a network. if a single IP address actually contains a 32-bit subnet mask, for example,-s 10.1.1.11 is actually-s 10.1.1.11/32. we can also specify different masks to implement the source network address rules, for example, we can use-s 10.1.1.0/24 to specify a Class C address. The-d parameter is in the same format as the-s parameter. -The I parameter is the network interface of the specified inbound interface. for example, I only allow packets from the eth3 interface to pass the FORWARD chain, you can specify iptables-a forward-I eth3-j ACCEPT-o as the output interface.
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