After setting up iptables. My webserver has "connection timed out". I'm trying to setup my iptables based on what I have read is a pretty good starting point for a web server from another serverFault post. I have a file called "iptables-setup" with the following:
# Allow outgoing traffic and disallow any passthroughs
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP
# Allow traffic already established to continue
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# Allow ssh, #dns, ftp and web services
iptables -A INPUT -p tcp --dport ssh -i eth0 -j ACCEPT
# DNS
# iptables -A INPUT -p tcp --dport domain -i eth0 -j ACCEPT
iptables -A INPUT -p tcp --dport ftp -i eth0 -j ACCEPT
iptables -A INPUT -p udp --dport ftp -i eth0 -j ACCEPT
iptables -A INPUT -p tcp --dport ftp-data -i eth0 -j ACCEPT
iptables -A INPUT -p udp --dport ftp-data -i eth0 -j ACCEPT
# HTTP
iptables -A INPUT -p tcp --dport 80 -i eth0 -j ACCEPT
# HTTPS
iptables -A INPUT -p tcp --dport 443 -i eth0 -j ACCEPT
# CPanel
iptables -A INPUT -p tcp --dport 2083 -i eth0 -j ACCEPT
# WHM
iptables -A INPUT -p tcp --dport 2087 -i eth0 -j ACCEPT
# Allow local loopback services
iptables -A INPUT -i lo -j ACCEPT
# Allow pings
iptables -I INPUT -p icmp --icmp-type destination-unreachable -j ACCEPT
iptables -I INPUT -p icmp --icmp-type source-quench -j ACCEPT
iptables -I INPUT -p icmp --icmp-type time-exceeded -j ACCEPT
iptables -I INPUT -p icmp --icmp-type echo-request -j ACCEPT
iptables -I INPUT -p icmp --icmp-type echo-reply -j ACCEPT
I then run:
% service iptables stop
Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT: mangle filter [ OK ]
Unloading iptables modules: [ OK ]
% sh iptables-setup
% service iptables save
Saving firewall rules to /etc/sysconfig/iptables: [ OK ]
% service iptables restart
Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT: mangle filter [ OK ]
Unloading iptables modules: [ OK ]
Applying iptables firewall rules: [ OK ]
% iptables --list -n -v
Chain INPUT (policy ACCEPT 84670 packets, 33M bytes)
pkts bytes target prot opt in out source destination
84083 33M acctboth all -- * * 0.0.0.0/0 0.0.0.0/0
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 110K packets, 52M bytes)
pkts bytes target prot opt in out source destination
109K 52M acctboth all -- * * 0.0.0.0/0 0.0.0.0/0
Chain acctboth (2 references)
pkts bytes target prot opt in out source destination
116 16979 tcp -- !lo * [MY_IP] 0.0.0.0/0 tcp dpt:80
78 158K tcp -- !lo * 0.0.0.0/0 [MY_IP] tcp spt:80
0 0 tcp -- !lo * [MY_IP] 0.0.0.0/0 tcp dpt:25
0 0 tcp -- !lo * 0.0.0.0/0 [MY_IP] tcp spt:25
0 0 tcp -- !lo * [MY_IP] 0.0.0.0/0 tcp dpt:110
0 0 tcp -- !lo * 0.0.0.0/0 [MY_IP] tcp spt:110
5 866 icmp -- !lo * [MY_IP] 0.0.0.0/0
3 132 icmp -- !lo * 0.0.0.0/0 [MY_IP]
26431 11M tcp -- !lo * [MY_IP] 0.0.0.0/0
19622 7514K tcp -- !lo * 0.0.0.0/0 [MY_IP]
64 4250 udp -- !lo * [MY_IP] 0.0.0.0/0
66 10580 udp -- !lo * 0.0.0.0/0 [MY_IP]
26500 11M all -- !lo * [MY_IP] 0.0.0.0/0
19691 7524K all -- !lo * 0.0.0.0/0 [MY_IP]
0 0 tcp -- !lo * [MY_IP] 0.0.0.0/0 tcp dpt:80
0 0 tcp -- !lo * 0.0.0.0/0 [MY_IP] tcp spt:80
0 0 tcp -- !lo * [MY_IP] 0.0.0.0/0 tcp dpt:25
0 0 tcp -- !lo * 0.0.0.0/0 [MY_IP] tcp spt:25
0 0 tcp -- !lo * [MY_IP] 0.0.0.0/0 tcp dpt:110
0 0 tcp -- !lo * 0.0.0.0/0 [MY_IP] tcp spt:110
1 576 icmp -- !lo * [MY_IP] 0.0.0.0/0
0 0 icmp -- !lo * 0.0.0.0/0 [MY_IP]
15 600 tcp -- !lo * [MY_IP] 0.0.0.0/0
17 720 tcp -- !lo * 0.0.0.0/0 [MY_IP]
0 0 udp -- !lo * [MY_IP] 0.0.0.0/0
1 1016 udp -- !lo * 0.0.0.0/0 [MY_IP]
16 1176 all -- !lo * [MY_IP] 0.0.0.0/0
18 1736 all -- !lo * 0.0.0.0/0 [MY_IP]
47158 19M all -- !lo * 0.0.0.0/0 0.0.0.0/0
% netstat -lntp | egrep ":80"
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 13687/httpd
I added spaces for legibility and [MY_IP] is subbed in for my ip. Again, the question I have is, are there problems with my ipconfig that could be causing my web server to fail an HTTP connection that worked before?
sh iptables-setupis supposed to do? – Nic Young Feb 21 at 6:47sh iptables-setupRuns the script with the iptables configuration writtent to the file "iptables-setup". Given that the settings are showing up onservice iptables status, I'm thinking it might have something to do with a missing ACCEPT on a chain? – garromark Feb 21 at 6:55