Restricting MySQL 3306 port to localhost with IPTABLES

后端 未结 3 1213
后悔当初
后悔当初 2021-02-01 10:22

I am trying to restrict MySQL 3306 port on a linux machine from making any connections to anything other than localhost to prevent outside attacks. i have the following code, i

3条回答
  •  隐瞒了意图╮
    2021-02-01 11:04

    iptables -A INPUT -p tcp --dport 3306 -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
    iptables -A INPUT -p tcp --dport 3306 -j DROP
    

    If you want to remove the filtering, use this:

    iptables -D INPUT -p tcp --dport 3306 -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
    iptables -D INPUT -p tcp --dport 3306 -j DROP
    

    Note: Both might require root, so: sudo iptables (...)

提交回复
热议问题