サービス傍受は127.0.0.1と0.0.0.0で、いったいどんな違いがあるのだろうか.

1645 ワード

サービス傍受は127.0.0.1と0.0.0.0で、いったいどんな違いがあるのだろうか.実際の例をあげてみましょう
今日nb 1380のmysqlでnb 1381からつながっていないことを発見しますか?  
1、grantを使用して権限を追加し、失敗した
mysql> select user,host,password from mysql.user;
11 rows in set (0.00 sec)
mysql> grant all privileges on *.* to 'root'@'nb1381' identified by '  ' with grant option;

2、telnetに失敗しました.iptablesの制限かもしれません.ルールを追加します.無効です.
root@nb1380:/var/log/mysql# iptables -I INPUT -p tcp --dport 3306 -j ACCEPT

3、推測は0.0.0.0ではなく127.0.0.1で傍受し、myを表示する可能性がある.cnf、やっぱりそのせい
root@nb1380:/var/log/mysql# vim /etc/mysql/my.cnf 
bind-address            = 127.0.0.1   :
bind-address            = 0.0.0.0

mysqlを再起動して、やはりtelnetが通じました
root@nb1381:~# telnet nb1380 3306
Trying 192.168.64.43...
Connected to nb1380.
Escape character is '^]'.

mysqlも接続できました
root@nb1381:~# mysql -uroot -p -hnb1380
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 40
Server version: 5.6.33-0ubuntu0.14.04.1 (Ubuntu)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>

まとめ:
3306ポートの傍受は127.0.0.1で、ネイティブクライアントのみがアクセスでき、他のサーバはアクセスできません.
3306ポートが0.0.0.0で傍受されている場合、ポート制限がない場合、他のサーバはそのサーバのポートに接続できます.
転載先:https://blog.51cto.com/daixuan/2118213