IPTABLES help
Im working on my minecraft server so that with the exception of outgoing web acess, incoming minecraft server acess, and incoming ssh, all other ports and services are blocked. This is on the inside of my router. Unfortunately while the ssh works, web acees and the minecraft protocol don't. here is the script im using.
#!/bin/sh SERVER_IP=192.168.1.95 # Flushing all rules iptables -F iptables -X # Setting default filter policy iptables -P INPUT DROP iptables -P OUTPUT DROP iptables -P FORWARD DROP # Allow unlimited traffic on loopback iptables -A INPUT -i lo -j ACCEPT iptables -A OUTPUT -o lo -j ACCEPT #allow http sudo iptables -A INPUT -p udp -m udp --sport 53 -j ACCEPT sudo iptables -A INPUT -p tcp -m tcp --sport 80 -j ACCEPT #allow inbound iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT # Allow incoming ssh only iptables -A INPUT -p tcp -s 0/0 -d $SERVER_IP --sport 513:65535 --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT iptables -A OUTPUT -p tcp -s $SERVER_IP -d 0/0 --sport 22 --dport 513:65535 -m state --state ESTABLISHED -j ACCEPT #allow minecraft iptables -A INPUT -p tcp --dport 25565 -j ACCEPT iptables -A OUTPUT -p tcp --dport 25565 -j ACCEPT # make sure nothing comes or goes out of this box iptables -A INPUT -j DROP iptables -A OUTPUT -j DROP |
It looks like you don't have any rule to allow output for web traffic. Does minecraft actually use the same port for outgoing as incoming? I'm not familiar with the protocol, but most tcp protocols don't.
You can add the following lines before the DROP lines for troubleshooting: Code:
iptables -A INPUT -j LOG --log-prefix "input drop " |
Quote:
|
Code:
#!/bin/sh -- - Unless you host your own Domain Name Service your only inbound DNS traffic will be of state "ESTABLISHED" so the port 53 rule is gone. - I'm not certain Minecraft doesn't need UDP so I added that. - ICMP is used to check connection problems so you should allow some of it. - Some network ranges should not be allowed in. They're called "bogons" which you will find here: http://www.team-cymru.org/Services/B...gon-bn-agg.txt - There are more states that iptables recognizes like INVALID you can filter. See the standard work on iptables for more information: http://www.frozentux.net/iptables-tu...tml/index.html - For running SSH 0) do deny root logins in /etc/sshd_config, 1) use an unprivileged account to login with pubkey auth and only *then* use sudo and 2) install fail2ban. - At a later point you might find your connection saturated: you might want to read up on rate-limiting traffic and bandwidth shaping. - Install Logwatch and read those reports. * And please harden your machine properly before exposing it to the 'net. |
Quote:
|
Quote:
it booted me out of su -. It shot some error i think but i couldnt read it |
also now im locked out even with ssh. Im going to go to the physical source.
|
I'm sorry to hear that, this should not have happened.
|
Its fine. I appreciate the insight either way. If you do happen to realize whats wrong though feel free to pipe up. In the mean time im going to try a few things
|
On this line:
Code:
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT To answer your earlier question: Quote:
|
Quote:
iptables -p tcp -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT but it still kicks me out of su - when I point to it as the source |
Quote:
Code:
~]# /sbin/iptables -t filter -n -v -x --line-numbers -L INPUT|grep EST |
Quote:
|
Quote:
|
Quote:
|
All times are GMT -5. The time now is 06:30 AM. |