Initial configuration of iptables in debian

Source: Internet
Author: User
First, open the corresponding functional modules in the Linux kernel # echo1/proc/sys/net/ipv4/ip_forward change the content of the file/proc/sys/net/ipv4/ip_forward from 0 1 indicates that the kernel supports ip forwarding. The/proc system is a virtual file system that actually exists in the memory and is used to display the running status of the system. In this way, the system restarts. First, open the corresponding functional modules in the Linux kernel.
# Echo 1>/proc/sys/net/ipv4/ip_forward
Change the content of the/proc/sys/net/ipv4/ip_forward file from 0 to 1 to inform the kernel that ip forwarding is supported. The/proc system is a virtual file system that actually exists in the memory and is used to display the running status of the system.
After the system is restarted, it will be reset. some people say this can be saved (add the following line in/etc/sysct1.conf: net. ipv4.ip _ forward = 1 takes effect after restart)

SaveIptables:
# Iptables-save>/etc/network/iptables
Add the following line to the eth0 configuration in/etc/network/interface so that the system will be automatically transferred to iptables at startup.
Up/sbin/iptables-restore </etc/network/iptables
There is still such a paragraph to be verified
Configure firewall rules through ifup
You can also set firewall rules in the network configuration file/etc/network/interfaces. you need:
Rebuild the firewall rules when the network interface is activated.
Use iptables-save to save the rule settings to/etc, for example,/etc/iptables. up. rules.
Configure etc/network/interfaces to call the configured rules.
Iface eth0 inet static
Address x. x
[... Interface configuration...]
Pre-up iptables-restore </etc/iptables. up. rules
You can also set some rules to save them in the/etc/iptables. down. rules file when the network interface is down, and then add them to the interface configuration file:
Post-down iptables-restore </etc/iptables. down. rules
More advanced firewall configuration scripts for ifupdown can be placed in the *. d/directory and called through run-parts (see run-parts (8.
--------------------- Appendix:

Configuration of iptables for single-arm ppp0 routing
First load the module ipt_MASQUERADE and iptable_nat
Modify/etc/modules to add ipt_MASQUERADE and iptable_nat (one row)
Then modify the iptables file
* Nat
: Prerouting accept [217: 16072]
: Postrouting accept [8:1300]
: Output accept [15: 1737]
-A postrouting-o ppp0-j MASQUERADE
COMMIT
Add the colored line under * net

Port 25 and port 445 of the ppp0 device are blocked.
* Filter
: Input accept [11729: 15211118]
: Forward accept [699: 233477]
: Output accept [7090: 542505]
-A input-p tcp-I ppp0 -- dport 445-j DROP
-A input-p tcp-I ppp0 -- dport 25-j DROP
#-A input-p tcp-I ppp0 -- dport 21-j DROP
COMMIT
* Number of rows added to the filter

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.