Introduction to iptables firewall configuration tools in Linux

Source: Internet
Author: User
Tags perl script
In the past few years, Linux has grown significantly as a firewall platform. Since ipfwadm of the earlier version 1.2 kernel, the Linux firewall code has gone a long way. The netfilter system is used in the 2.4 Linux kernel. In the latest version 2.4, Linux greatly enhances security, such as better encryption support and netfilter system.

In the past few years, Linux has grown significantly as a firewall platform. Since ipfwadm of the earlier version 1.2 kernel, the Linux firewall code has gone a long way. The netfilter system is used in the 2.4 Linux kernel. In the latest version 2.4, Linux greatly enhances security, such as better encryption support and the use of the netfilter system. Netfilter has full backward compatibility.

This article willIptablesConfiguration to make a summary and focus on someIptablesConfiguration tool. This article will focus on the Linux Kernel IP firewall and its various interface configuration tools, such as GUI or script (shell, Perl or specific configuration language ). Using these tools simplifies iptables configuration to reduce configuration errors. For more information about iptables, see Linux iptables HOWTO written by RustyRussell.

Difficulties in using command line to configure iptables

Using the command line interface of iptables to configure iptables firewall is a challenge for one person. it is difficult for users to specify the behavior of all IP packets. You need to have a deep understanding of TCP/IP and application layer protocols. Like its predecessor ipchains, iptables Merges IP filtering rules into the chain. IP packet traversal rule links are processed and can be sent to another link for processing, or it is processed by the default policy (ACCEPT, DROP, REJECT. Some network applications are easier to pass through the firewall than others, so you need to understand the establishment and disconnection of network connections.

Let's take a look at the POP3 protocol. this is one of the simplest protocols. Allow all packets whose inner port is 110 to solve all management problems through the request, because this only allows the client to send an application, but the server cannot respond. In addition, network address translation (NAT) and other packet forwarding methods also have many problems. The firewall configuration will affect the security of the entire enterprise, so be careful. The configuration of iptables will be discussed below. For more details, refer to Linuxiptables HOWTO

Command line options of iptables

Before proceeding to this discussion, let's take a look at a summary of the iptables command line options.

Rule chain maintenance options

1. create a new rule chain (-N)
2. delete an empty rule chain (-X)
3. change a built-in rule chain policy (-P)
4. list rules in a rule chain (-L)
5. erase a rule from the rule chain (-F)

Rule maintenance

1. add A new rule to A rule chain (-)
2. delete a rule at a certain position in the rule chain (-D)

Advantages of iptables

Before discussing various iptables configuration tools, let's take a look at the advantages of iptables, especially the advantages of netfilter over ipchains.

Iptables allows the establishment of a state firewall, that is, to save each connection that passes through the firewall in the memory. This mode is necessary to effectively configure FTP, DNS, and other network services.

Iptables can filter any combination of TCP flag messages and MAC addresses.

System logs are easier to configure and more scalable than ipchains.

For Network AddressTranslation and transparent proxy support, netfilter is more powerful and easy to use.

Iptable can prevent some DOS attacks, such as SYS flood attacks.

Iptables configuration tool

Now, let's take a look at some configuration tools of Linuxiptables. I focus on the features, elasticity, and ease of use of each tool. We will discuss the following tools:

MonMotha's Firewall 2.3.5 By: MonMotha

Firewallscript (iptables 4.4c-3 devel) by Patrik Hildingsson

Auke Kok by Ferm-0.0.18

Andy Gilligan, AGT-0.83 author

Knetfilter-1.2.4 by Luigi Genoni

By gShield-2.0.2: R. Gregory

Firewall 2.3.5 of MonMotha

Firewall2.3.5 written by MonMotha is a shell script of about 30 kB. Currently, it is mainly applicable to host-based protection because some network-based options are under development. The interface of this script (for example, the method for passing configuration options to iptables) is a bit messy. However, it does not require a configuration file and is easy to install. it can be copied directly to any location. By default, it does not do anything at all, in fact, it does not execute at all, and there is a lack of documentation. This script may be useful to dial-up users.

Firewallscript

Firewallscript (IFS4.4d) is also a bash script, about 85 KB. This script can be used for host-and network-based protection. When it is run for the first time, it will generate a configuration file directly.

Welcome Xuewang, Add this article to favorites[1] [2] [3] $ False $

However, by default, this file does not play any role, but only serves as a test. This script can configure NAT and address disguise. This script is very complex but lacks documentation, so it is best to read its code carefully and use the iptables-L command to determine which chain has taken effect and what is allowed/rejected. The IP packet tracking function of this script can also provide entertainment for you. In addition, it automatically detects and loads the kernel modules required by iptables. This script and the previous script also have the undo function to restore the original configuration file of iptables.

Ferm

Ferm is a Perl script that uses a configuration file written in C language. This language is easy to read and understand. This script provides good documentation and rich examples for reference.

This is an example:

-----------------------------------------------------------------------------

# Simple workstation example for ferm

Chain input {
If ppp0 # put your outside interface here
{
Proto tcp goto fw_tcp;
Proto udp goto fw_udp;
Proto icmp goto fw_icmp;
}
}

Chain fw_tcp proto tcp {
Dport ssh ACCEPT;
Syn DENY log;
Dport domain ACCEPT;
Dport 0: 1023 DENY log;
}

Chain fw_udp proto udp {
DENY log;
}

Chain fw_icmp proto icmp {
Icmptype (
Destination-unreachable time-exceeded
) ACCEPT;
DENY log;
}

-----------------------------------------------------------------------------

This configuration file will generate iptables rules for ferm: allow outbound ssh and DNS packets to pass, block all UDP packets, and allow only two types of ICMP messages to pass through: the target cannot be reached or timed out, and other types of ICMP messages in the log are rejected.

AGT

AGT is a program written in C language. From its code, it is still in the development stage. Automake is not supported. you need to manually edit the Makefile file. the file is not very rich, but its configuration file is very simple. The following is a configuration file:

NEW | FROM-INT
NEW | RESET

| FROM-INT | icmp | ACCEPT |
| FROM-INT | tcp | ACCEPT | pop3
| FROM-INT | tcp | ACCEPT | imap

| RESET | tcp | REJECT -- reject-with tcp-reset |

This file format, coupled with the lack of necessary documents, is a great challenge for users. And it is better to spend more time learning iptables.

Knetfilter

Knetfilter is a great graphical iptables configuration tool based on KDE (KDE1 and KDE2 ). Knetfilter is very easy to use. you can easily use it to configure host-protected rules and rule lists. you can save and restore these rules and rule lists; test rule and rule list (run on the same panel)TcpdumpNetwork sniffer. It also supports NAT and network address camouflage configurations. However, for a dial-up workstation, knetfilter does not work well because it requires a local IP address and only detects eth0 network interfaces without PPP detection. There are few documents for this project, but because it is based on the graphic interface, it can be used well even without a manual.

GShield

GShield is a bashshell script and may be the most mature tool currently. Its documentation is rich, its configuration files are also reasonable and intuitive, and NAT can be configured. It can handle both static IP addresses and dynamic IP addresses (for example, PPP ).

GShield also has a graphical interface, which is still in the early development stage and can be downloaded from http://members.home.com/vhodges/gshieldconf.html. However, it seems only compatible with earlier versions of gShield (1.x ).

The following is an example configuration file:

FW_ROOT = "/etc/firewall"
IPTABLES = 'which iptables'
LOCALIF = "eth0"
DNS = "24.31.195.65"
LTIME = "20/m"
ALLOW_DHCP_LEASES = "YES"
...

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.