Iptables Rules to allow Git

I have a client that wanted to use Git on their VPS. My firewall was blocking it and I had to do a little research. Git uses port 9418 to communicate. You don’t want to open up the port externally so I used stateful inspection to open the port only if we established the connection.

Here are the iptables rules:

# allow git
iptables -A OUTPUT -o eth0 -p tcp --dport 9418 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --sport 9418 -m state --state ESTABLISHED -j ACCEPT

2 Replies to “Iptables Rules to allow Git”

  1. Thanks that was helpful to have the full answer and I think people should be told when something was useful: (I’m sure others must have used it). I only used the output since my first input clause is: iptables -A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT. Anyway, saved me time. Thanks Nigel “the Internet Destroyer”.

Leave a Reply

Your email address will not be published. Required fields are marked *