Showing posts with label iptables. Show all posts
Showing posts with label iptables. Show all posts

2.19.2015

Open HTTP port 80 on CentOS

Got from here.
1. Look at the current iptables
# iptables --line -vnL
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out     source               destination
1        0     0 ACCEPT     udp  --  virbr0 *       0.0.0.0/0            0.0.0.0/0           udp dpt:53
2        0     0 ACCEPT     tcp  --  virbr0 *       0.0.0.0/0            0.0.0.0/0           tcp dpt:53
3        0     0 ACCEPT     udp  --  virbr0 *       0.0.0.0/0            0.0.0.0/0           udp dpt:67
4        0     0 ACCEPT     tcp  --  virbr0 *       0.0.0.0/0            0.0.0.0/0           tcp dpt:67
5     195K  212M ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
6        3   252 ACCEPT     icmp --  *      *       0.0.0.0/0            0.0.0.0/0
7       74  5440 ACCEPT     all  --  lo     *       0.0.0.0/0            0.0.0.0/0
8       16   864 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22
9     170K   39M REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited

2. Inject rule, as long as it's before the REJECT line
# iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT

3. Save
# service iptables save

4. Add httpd_t to the list of permissive domains (So we don't need to turn off selinux)
# yum install policycoreutils-python
# semanage permissive -a httpd_t