Current location - Quotes Website - Collection of slogans - Add an open port number on the Linux server. How to drive 8080?
Add an open port number on the Linux server. How to drive 8080?
1. Modify the file /etc/sysconfig/iptables.

[root @ bogon ~]# CD/etc/sys config/

[root @ bogon sys config]# VI iptables

The contents of this document are as follows. Note that the red line is newly added, opening port 8080 to the outside world.

# Firewall configuration written by system configuration firewall

# Manually customizing this file is not recommended.

* Filter

: Enter Accept [0:0]

: Forward Accept [0:0]

: Output accepted [0:0]

: RH- firewall-1- input-[0:0]

-one input -j right-firewall-1- input

-a right firewall-1- input -i lo -j accept.

-A RH-Firewall- 1-INPUT-p icmp-icmp-type any-j ACCEPT

-right firewall-1- input -p 50 -j accept

-right firewall-1- input -p 5 1 -j accept

-an RH firewall-1-input-pudp-dport5353-d224.0.0.251-j accepted.

-A RH-Firewall- 1-INPUT-p UDP-m UDP-dport 63 1-j ACCEPT

-an RH- firewall-1- input -p tcp -m tcp-dport 63 1 -j accept.

-an RH- firewall-1- input -m state-state establishment, correlation -j accept.

-A RH-Firewall- 1-INPUT-m state-state NEW-m TCP-p TCP-dport 2 1-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 443-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 8080-j ACCEPT

-right firewall-1- input -j reject-reject-with icmp- host-forbidden

-Forward -j Reject-Reject-With icmp- Host-Forbidden

commit a crime

This line of text is actually a modification of the previous line. In VI, yy is used to copy one line, yyn is used to copy multiple lines, and P is used to paste. It's quite convenient.

2. Restart the iptables service.

[root @ bogonsystconfig] # service iptables restarted.

Refresh firewall rules: [OK]

Set Chain to Policy Acceptance: Filter [OK]

Uninstall iptables module: [OK]

Apply iptables firewall rules: [OK]

Load the additional iptables module: ip_conntrack_ftp [OK].

[root@bogon sysconfig]#

3. If you don't want to modify the iptables table, you can directly enter the following command:

# iptables -I input -p tcp-dport 80 -j accept.