iptables block access to port 8000 except from IP address

后端 未结 3 1612
被撕碎了的回忆
被撕碎了的回忆 2020-12-07 09:14

I\'ve never used iptables, and the documentation online seems a bit opaque.

I\'d like to block all requests to port 8000 on my server except those coming from a spec

3条回答
  •  感情败类
    2020-12-07 09:35

    Another alternative is;

    sudo iptables -A INPUT -p tcp --dport 8000 -s ! 1.2.3.4 -j DROP
    

    I had similar issue that 3 bridged virtualmachine just need access eachother with different combination, so I have tested this command and it works well.

    Edit**

    According to Fernando comment and this link exclamation mark (!) will be placed before than -s parameter:

    sudo iptables -A INPUT -p tcp --dport 8000 ! -s 1.2.3.4 -j DROP
    

提交回复
热议问题