iptables block access to port 8000 except from IP address

后端 未结 3 1619
被撕碎了的回忆
被撕碎了的回忆 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:33

    This question should be on Server Fault. Nevertheless, the following should do the trick, assuming you're talking about TCP and the IP you want to allow is 1.2.3.4:

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

提交回复
热议问题