Set up a firewall for LINUX-document-Linux Enterprise Application-Linux server application information. For more information, see the following section. Set up a firewall in LINUX
With the popularity of the Internet, people's daily work is also closely related, so more and more organizations have opened Internet proxy services for employees. However, when an enterprise's internal network is connected to the Internet, its internal resources are like the lambs to be sold, therefore, in addition to computer viruses and System Robustness among other internal reasons, system security mainly prevents illegal user intrusion through the Internet. At present, the prevention measures mainly rely on the firewall technology.
1. What is firewall?
Firewall (firewall) refers to a combination of software or hardware devices. It is located between an enterprise or a network group computer and an external channel (Internet, restrict external users from accessing the internal network and managing the permissions of internal users to access the external network. It mainly controls the round-trip access to the protected network (that is, the outlets), so that the connection points can be checked and evaluated.
From its birth to the present, the firewall has gone through four stages of development: a router-based firewall, a user-based firewall tool set, a firewall built on a general operating system, and a firewall with a secure operating system. At present, most of the Firewall vendors provide a combination of software and hardware for secure operating systems, such as NETEYE, NETSCREEN, and TALENTIT. There are also a lot of Firewall software in the LINUX operating system. In addition to the IPCHAINS, there are also many, such as Sinus Firewall and Jfwadmin.
The current firewall can be divided into two types in terms of structure:
2) vro and filter structure
Internal Network <-----> Filter <----> Router <----> Internet
Ii. Principles of using IPCHAINS to build a LAN Firewall
In essence, building a LAN firewall with IPCHAINS is also a C/S interactive application. Generally, services provided by servers with certain functions are always provided by specific background programs. In TCP/IP networks, this specific service is often bound to a specific TCP or UDP port. Then, the background program continuously listens to the port (listen). Once a client request that meets the conditions is received, the Service performs a TCP handshake and establishes a connection with the client, respond to customer requests. At the same time, a copy of the binding will be generated to continue listening to client requests.
IPCHAINS is such a SERVER. Requests from the Intranet to Intenet or requests from the external network to the Intranet are monitored, checked, evaluated, forwarded, and denied.
Common Services, protocols, and default ports.
Service type protocol port
Www tcp/UDP 80
TELNET
ICMP
SMTP
POP3
FTP
DNS
Iii. Steps for using IPCHAINS as a firewall
1. Install
The current version of IPCHAINS has been developed to 1.3.9. Generally, LINUX is installed. If not, you can download it at www.linux.org. The following is an example of installing IPCHAINS with TLC4.0. As it requires IP-MASQ support, it is determined that the IP-MASQ module is installed.
In TLC4.0, place the disc into the optical drive,
# Turbopkg
Select ipchains and then press OK to automatically install it.
If you download the ipchains installation package:
1) if it is an rpm package:
# Rpm? Ivh *. rpm
2XX if the package is .tar.gz
# Tar xvfz * .tar.gz (unpack the package first)
Go to the Undo directory
#./Configure
# Make
# Make install
The installation is successful.
2. Enable ipchains
Manually modify the/proc/sys/net/ipv4/ipforward file and set its content to 1.
Run the touch command in the/etc/rc. d/directory to create the rc. ipfwadm file.
Add the following code to the rc. local file in the/etc/rc. d/directory:
If [-f/etc/rc. d/rc. ipfwadm]; then/etc/rc. d/rc. ipfwadm; fi;
In the future, all ipchains configuration commands will be modified in the rc. ipfwadm file.
3. Configure ipchains (Basic Application)
Ipchains manages machines by using the IP address of the machine as a flag. Therefore, you must first ensure that the IP address of the machine on your lan has been allocated, and you are quite familiar with it.
The Ipchains configuration rules are generally centered around the input, output, and ipforward rules. input indicates the filtering rules for internal connection requests, output refers to the filtering rules for external connection requests, and ipforward refers to the forwarding of internal and external communication packets. The Command Format of Ipchains is generally:
Ipchains [ADC] ipchains rules [ipchains option].
For detailed usage of commands, see HOWTO documentation.
Now let's assume that the enterprise's intranet CIDR block is 192.168.1.0 ~ 192.168.1.255. the IP address of the firewall host is 192.168.1.1. Assume that the firewall currently accesses the Internet through proxy and rejects all external telnet requests. Restrict access by internal users to external sites, grant certain machine privileges to access external machines, and deny access to the Internet by some internal machines. The CIDR block is:
+ -------------- +
| Intranet segment | 192.168.1.1 ISDN and PSDN
| + ------------ | Firewall | <==================> Internet
| 192.168.1.0 | + -------- +
+ -------------- +
You can configure ipchains firewall rules in either of the following ways:
1) permit all packages first, and then prohibit dangerous packages from passing through the firewall;
2) deny all packages first, and then allow specific packages to pass the defense based on the required services.
Fire wall.
In comparison, the second approach is safer.
The following is the file content of my rc. ipfwadm:
/Sbin/depmod? A
/* Automatically load the required modules. If you think this is dangerous, you must manually specify the installation module. You can manually specify the loading module as follows */
#/Sbin/modprobe/lib/modules/2.2.10/ipv4/ip_masq_ftp
/* Load the ip disguised ftp module */
#/Sbin/modprobe/lib/modules/2.2.10/ipv4/ip_masq_irc
/* Load the ip disguised irc module */
#/Sbin/modprobe/lib/modules/2.2.10/ipv4/ip_masq_raudio
#/Sbin/modprobe/lib/modules/2.2.10/ipv4/ip_masq_user
#/Sbin/modprobe/lib/modules/2.2.10/ipv4/ip_masq_autofw
/Sbin/modprobe-a-t/lib/modules/2.2.10/ipv4/ip_masq *
/* Automatically load modules related to ip camouflage */
Ipchains? F
/* Refresh all ipchains Rules */
Ipchains-P forward DENY
/* Refuse to forward all IP packets */
/* Allow specific packages to pass */
/* Open a host with high permissions */
Ipchains-A forward-s 192.168.1.10/32-j MASQ
/* Allow unrestricted access to the internal host 192.168.1.10. For example, general manager */
Ipchains-A forward-s 192.168.1.12/32-j MASQ
/* Allow unrestricted access to the internal host 192.168.1.12. For example, add */
Ipchains-A forward-s 192.168.1.41/32-j MASQ
/* For example linuxbird host address: 192.168.1.41 */
/* Some machines cannot be connected to the Internet as needed */
Ipchains-A forward-s 192.168.1.3/32-j DENY
/* This machine is a dedicated internal document machine and cannot access the outside */
/* Set the sites that can be accessed by common internal users */
Ipchains-A forward-d 202.101.98.55/32-j MASQ # FJ-DNS
Ipchains-A forward-d 202.101.0.133/32-j MASQ # FJ-DNS
/* This is an online DNS server. I use the DNS of Fuzhou Telecom Bureau */
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