A few basic questions
Posted: 2005/12/13 11:58:10
Hi,
I scanned some of the messages here in the forum and also read the RHEL4 documentation on iptables. But something is not clear to me. In here people are posting traditional iptable config files, but Centos does not use those in etc/sysconfig/iptables. It has an abbreviated form. I have a remote server with a public IP and behind it another server on a LAN with MySQL. I want to do 2 things, connect to port 3306 (MySQL) on that machine on the LAN with my client tools from my machine and also VNC into that database machine.
I already have ssh connected VNC into the machine with the public addr. I am scared to death of changing the 'non standard' iptables config as it talks about using "service iptables save", not the trad method of saving the iptable config file and then "service iptables restart". If I screw up this iptables somehow then it means getting folk to meet me at the hosting centre etc.
So here is my guess at what my RHEL4 version of iptables should look like. Where is the SNAT and DNAT? Where is thos form of iptables documented?
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -i eth1 -s eth0 -d 0.0.0.0/0 -j DROP
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp --syn -m limit --limit 5/s -i eth0 -j ACCEPT
-A RH-Firewall-1-INPUT -p 50 -j ACCEPT
-A RH-Firewall-1-INPUT -p 51 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type echo-request -m limit --limit 1/s -i eth0 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -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 443 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 21 -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 25 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT
These would seem to be a good idea too
-A RH-Firewall-1-INPUT -i eth1 -s eth0 -d 0.0.0.0/0 -j DROP
-A RH-Firewall-1-INPUT -p tcp --syn -m limit --limit 5/s -i eth0 -j ACCEPT
I need to add in traditional iptable terms the NAT stuff and these other FORWARD rules where suggested elsewhere I assume to allow the VNC to operate to the remote machine.
$IPTABLES -A FORWARD -i eth0 -o eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A FORWARD -i eth1 -o eth0 -j ACCEPT
$IPTABLES -A FORWARD -j DROP
$IPTABLES -t nat -A PREROUTE -s 82.108.5.145 -i eth0 --dport 3306
$IPTABLES -t nat -A POSTROUTING -o eth0 -j SNAT --to eth0
Thx.
David
I scanned some of the messages here in the forum and also read the RHEL4 documentation on iptables. But something is not clear to me. In here people are posting traditional iptable config files, but Centos does not use those in etc/sysconfig/iptables. It has an abbreviated form. I have a remote server with a public IP and behind it another server on a LAN with MySQL. I want to do 2 things, connect to port 3306 (MySQL) on that machine on the LAN with my client tools from my machine and also VNC into that database machine.
I already have ssh connected VNC into the machine with the public addr. I am scared to death of changing the 'non standard' iptables config as it talks about using "service iptables save", not the trad method of saving the iptable config file and then "service iptables restart". If I screw up this iptables somehow then it means getting folk to meet me at the hosting centre etc.
So here is my guess at what my RHEL4 version of iptables should look like. Where is the SNAT and DNAT? Where is thos form of iptables documented?
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -i eth1 -s eth0 -d 0.0.0.0/0 -j DROP
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp --syn -m limit --limit 5/s -i eth0 -j ACCEPT
-A RH-Firewall-1-INPUT -p 50 -j ACCEPT
-A RH-Firewall-1-INPUT -p 51 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type echo-request -m limit --limit 1/s -i eth0 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -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 443 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 21 -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 25 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT
These would seem to be a good idea too
-A RH-Firewall-1-INPUT -i eth1 -s eth0 -d 0.0.0.0/0 -j DROP
-A RH-Firewall-1-INPUT -p tcp --syn -m limit --limit 5/s -i eth0 -j ACCEPT
I need to add in traditional iptable terms the NAT stuff and these other FORWARD rules where suggested elsewhere I assume to allow the VNC to operate to the remote machine.
$IPTABLES -A FORWARD -i eth0 -o eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A FORWARD -i eth1 -o eth0 -j ACCEPT
$IPTABLES -A FORWARD -j DROP
$IPTABLES -t nat -A PREROUTE -s 82.108.5.145 -i eth0 --dport 3306
$IPTABLES -t nat -A POSTROUTING -o eth0 -j SNAT --to eth0
Thx.
David