Use the following command:
#/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
#/sbin/iptables -I INPUT -p tcp -- Dport 22 -j ACCEPT
#/etc/rc.d/init.d/iptables save
After restarting the computer, the firewall has opened ports 80 and 22 by default.
Temporarily turn off the firewall completely, you can not restart the machine:
#/etc/init.d/iptables status ##View Firewall Status
#/etc/init .d/iptable stop ## Turn off the firewall this time
#/etc/init.d/iptable restart ## Restart the firewall
Permanently turn off the firewall:
#chkconfig --level 35 iptables off (note that there are two British short lines in the middle; reboot)
Attachment:
The method for setting the firewall open port is as follows:
vi /Etc/sysconfig/iptables
Note that it is best to leave the management ports of VNC and SSH when modifying the firewall.
Here is an example of an iptables:
# Firewall configuration written by system-config-securitylevel
# Manual customization of this file is not recommended.*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Firewall- 1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp –icmp-type any -j ACCEPT
- A RH-Firewall-1-INPUT -p 50 -j ACCEPT
-A RH-Firewall-1-INPUT -p 51 -j ACCEPT
-A RH-Firewall-1-INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 53 -j ACCEPT
-A RH-Firewall-1-INPUT -m state –state NEW -m udp -p udp –dport 53 -j ACCEPT
-A RH-Firewall-1-INPUT -m State –state NEW -m tcp -p tcp –dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 25 -j ACCEPT
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
-A RH-Firewall- 1-INPUT -m state –state NEW -m tcp -p tcp –dport 443 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT –reject-with icmp-host- Prohibited
COMMIT
To modify this file according to your needs, for example, if you do not want to open port 80 to provide web services, you should delete this line accordingly:
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
Restart iptables after all modifications:
service iptables restart
You can verify that the rules are in effect: iptables -L
This completes the CentOS firewall settings modification.
Two virtual network cards after installing the virtual machine: 1.bridged (bridge mode) <?喎& #
in CentOS Introduction to lvs LVS has a similar point to other application-layer or IP-based load b
This article will guide you to install Debian 7 Wheezy network directly by using DNSMASQ as a PXE se
Understand the process: ? PID, PPID? Current process status? Memory allocation? CPU and actu
Linux task planning tool crontab
Linux compiles the kernel and adds system calls
Small note IptabLes and IptabLex virus cleanup process
Linux system reloading and restoring
Linux lftp connection ftp server upload download command
File archiving, compression, and decompression of Linux commands - tar, gzip, gunzip, bzip2, bunz
Linux. How to install and uninstall the .run file
Linux network based three-layer switch and NAT address translation notes
Compression and decompression commands commonly used under Linux
Hanwang World: I think Microsoft's window system should learn from the 10 characteristics of Linux
Familiar with tips, let Win8 function no longer hide from cats
Tip: Use Notepad to write "local Weibo"
How Symantec Enterprise Users Deploy Security Center
Solve the Windows8 system Metro mall can not use this application
How to check the status of LAN arp network in Win7 system?
Retrieving the Windows 7 operating system wireless password method
Windows7 boot memory takes up a large fault resolution
Teach you how to disable the worm to replace the explorer file