Here we have linux tutorial for, how to open port 80 in linux iptables. Many times we need to open 80 port on linux box. Through command line opening the 80 or any port that is easy. In this tutorial I will how you can open the port 80.
how to open port 80 in linux iptables
Using following you can check the firewall setting of Linux.
01
[root@sonyk-pc project]# iptables -L
02
Chain INPUT (policy ACCEPT)
03
target prot opt source destination
04
ACCEPT udp -- anywhere anywhere udp dpt:domain
05
ACCEPT tcp -- anywhere anywhere tcp dpt:domain
06
ACCEPT udp -- anywhere anywhere udp dpt:bootps
07
ACCEPT tcp -- anywhere anywhere tcp dpt:bootps
08
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
09
ACCEPT icmp -- anywhere anywhere
10
ACCEPT all -- anywhere anywhere
11
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:domain
12
ACCEPT udp -- anywhere anywhere state NEW udp dpt:domain
13
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh
14
ACCEPT tcp -- anywhere anywhere tcp dpt:http state NEW
15
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:vnc-server
16
ACCEPT udp -- anywhere anywhere state NEW udp dpt:vnc-server
17
ACCEPT tcp -- anywhere anywhere tcp dpt:patrol-snmp state NEW
18
ACCEPT tcp -- anywhere anywhere tcp dpt:61613 state NEW
19
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
21
Chain FORWARD (policy ACCEPT)
22
target prot opt source destination
23
ACCEPT all -- anywhere 192.168.122.0/24 state RELATED,ESTABLISHED
24
ACCEPT all -- 192.168.122.0/24 anywhere
25
ACCEPT all -- anywhere anywhere
26
REJECT all -- anywhere anywhere reject-with icmp-port-unreachable
27
REJECT all -- anywhere anywhere reject-with icmp-port-unreachable
28
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
30
Chain OUTPUT (policy ACCEPT)
31
target prot opt source destination
Using following command you can open the port 80. using following command use 80 port will be open for 192.168.2.0 to 192.168.2.68 ip addresses.
1
[root@sonyk-pc project]# iptables -A INPUT -s 192.168.2.0/68 -d 192.168.2.16 -p tcp --dport 80 -j ACCEPT
using following command you can save the setting in iptables.
1
[root@sonyk-pc project]# restorecon -R /etc/sysconfig/iptables
3
[root@sonyk-pc project]# service iptables save
5
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
Than restart the firewall using following command
1
[root@sonyk-pc project]# service iptables restart
2
iptables: Flushing firewall rules: [ OK ]
3
iptables: Setting chains to policy ACCEPT: nat mangle filte[ OK ]
4
iptables: Unloading modules: [ OK ]
5
iptables: Applying firewall rules: Using intrapositioned negation (`--option ! this`) is deprecated in favor of extrapositioned (`! --option this`).
6
Using intrapositioned negation (`--option ! this`) is deprecated in favor of extrapositioned (`! --option this`).