Firewall (iptables) blocking server ping of client
Posted: Fri May 16, 2014 8:21 pm
I am attempting to set up an OpenVpN on my Centos 6 server to connect a remote client (Mac os x).
With firewall disabled on both server and client, everything works great! I can ping the client from the server, and I can ping the server from the client and the connection is active.
When I enable a simple firewall on the server, I can no longer ping the client over the VPN interface. After about a minute, the client VPN loses contact as the server and shuts down the interface due to keepalive expiring.
Here is the content of the iptables.rules script that I am using to debug this situation. The script is based on examples from the OpenVPN HOWTO and is not really a complete firewall:
----------------------------------------------------------------------------------
#--------------------------------------------------------------
# Interfaces
# em1 - internet
# em2 - LAN
# tun0 - vpn interface
#--------------------------------------------------------------
# Flush and reset all iptables
#--------------------------------------------------------------
iptables -F
iptables -X
iptables -Z
iptables -t nat -F
iptables -t nat -X
iptables -t nat -Z
#--------------------------------------------------------------
# Setup default policy
#--------------------------------------------------------------
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP
#--------------------------------------------------------------
# VPN rules
#--------------------------------------------------------------
# Allow traffic on OpenVPN udp port
iptables -A INPUT -i em1 -p udp --dport 1194 -j ACCEPT
iptables -A OUTPUT -o em1 -p udp --dport 1194 -j ACCEPT
# Allow traffic in/out tun0
iptables -A INPUT -i tun0 -j ACCEPT
iptables -A OUTPUT -o tun0 -j ACCEPT
iptables -A FORWARD -i tun0 -j ACCEPT
# Allow icmp in/out
iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT
iptables -A OUTPUT -p icmp --icmp-type echo-reply -j ACCEPT
iptables -A OUTPUT -p icmp --icmp-type echo-request -j ACCEPT
iptables -A INPUT -p icmp --icmp-type echo-reply -j ACCEPT
----------------------------------------------------------------------------------------------------------------
I would appreciate your help, as I really need to firewall this server, and so far have been unable to enable a firewall and keep the VPN connection active.
Thanks,
Mark
With firewall disabled on both server and client, everything works great! I can ping the client from the server, and I can ping the server from the client and the connection is active.
When I enable a simple firewall on the server, I can no longer ping the client over the VPN interface. After about a minute, the client VPN loses contact as the server and shuts down the interface due to keepalive expiring.
Here is the content of the iptables.rules script that I am using to debug this situation. The script is based on examples from the OpenVPN HOWTO and is not really a complete firewall:
----------------------------------------------------------------------------------
#--------------------------------------------------------------
# Interfaces
# em1 - internet
# em2 - LAN
# tun0 - vpn interface
#--------------------------------------------------------------
# Flush and reset all iptables
#--------------------------------------------------------------
iptables -F
iptables -X
iptables -Z
iptables -t nat -F
iptables -t nat -X
iptables -t nat -Z
#--------------------------------------------------------------
# Setup default policy
#--------------------------------------------------------------
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP
#--------------------------------------------------------------
# VPN rules
#--------------------------------------------------------------
# Allow traffic on OpenVPN udp port
iptables -A INPUT -i em1 -p udp --dport 1194 -j ACCEPT
iptables -A OUTPUT -o em1 -p udp --dport 1194 -j ACCEPT
# Allow traffic in/out tun0
iptables -A INPUT -i tun0 -j ACCEPT
iptables -A OUTPUT -o tun0 -j ACCEPT
iptables -A FORWARD -i tun0 -j ACCEPT
# Allow icmp in/out
iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT
iptables -A OUTPUT -p icmp --icmp-type echo-reply -j ACCEPT
iptables -A OUTPUT -p icmp --icmp-type echo-request -j ACCEPT
iptables -A INPUT -p icmp --icmp-type echo-reply -j ACCEPT
----------------------------------------------------------------------------------------------------------------
I would appreciate your help, as I really need to firewall this server, and so far have been unable to enable a firewall and keep the VPN connection active.
Thanks,
Mark