Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to monitor network traffic under linux

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how to monitor network traffic under linux. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article. Let's follow the editor to have a look.

Build a yum environment on the workstation

[root@zhaoyun ~] # yum install net-snmp installs a network management protocol snmp

[root@zhaoyun] # yum install mrtg-y monitoring software

[root@zhaoyun ~] # yum install httpd-y install the http server because it is to be displayed on the web page

These three must be installed.

Second, after installation, you can install snmp in the managed equipment. I want to monitor a linux server.

Edit / etc/snmp/snmpd.conf

Change systemview to mib2 in line 62

Remove # at line 89

Add the community name rocommunity 123456 on line 395 and add a read-only attribute. The community name password is 123456.

Then start the snmpd service

The next step is to configure on the workstation

First set up a working directory for mrtg, and then generate a configuration file for mrtg

[root@zhaoyun ~] # mkdir / var/www/html/mrtg

[root@zhaoyu # cfgmaker-output / var/www/html/mrtg/mrtg.cfg 123456192.168.0.7

The host being monitored is 192.168.0.7. His group name and password is 123456.

Modify the configuration file of mrtg

[root@zhaoyun ~] # vi / var/www/html/mrtg/mrtg.cfg

Remove the # of WorkDIr:/home/http/mrtg and change it to WorkDir: / var/www/html/mrtg

Remove the Options [_]: growright, bits # and add a line below

Language: Chinese supports Chinese

Modify the main configuration file of apache

Add or modify a line to become AddDefaultCharset GB2312 for apache to support Chinese

It usually takes three times to regenerate the configuration file.

[root@zhaoyun ~] # env LANG=C / usr/bin/mrtg / var/www/html/mrtg/mrtg.cfg

Generate a web page file

[root@zhaoyun] # indexmaker-- output / var/www/html/mrtg/index.html-- title=jiankong-- sort=name-- sort=original / var/www/html/mrtg/mrtg.cfg

Modify another mrtg's file

[root@zhaoyun ~] # vi / etc/httpd/conf.d/mrtg.conf

Change it to the top.

Restart the apache service

[root@zhaoyun ~] # service httpd restart

Stopping httpd: [OK]

Starting httpd: [OK]

Now you can use the browser to see the monitoring device.

Since the web page is generated only once, the status of the generated web page can only be monitored so that the real-time monitoring device can set a scheduled task to generate the web page every 5 minutes.

[root@zhaoyun] # crontab-e

* / 5 * env LANG=C / usr/bin/mrtg / var/www/html/mrtg/mrtg.cfg

Now anyone can access this information and you can set an access password for security.

Now set up a directory for certification.

[root@zhaoyun webauth] # mkdir / etc/webauth

[root@zhaoyun etc] # htpasswd-bc / etc/webauth/web.txt zhaoyun00 123456

Generate a web.txt file under / etc/webauth/. The user name is zhaoyun00 and the password is 123456.

Modify the configuration file of mrtg

[root@zhaoyun webauth] # vi / etc/httpd/conf.d/mrtg.conf

Add

AuthType Basic

AuthName jiankong

AuthuserFile / etc/webauth/web.txt

Require user zhaoyun00

Restart apache for a test

Now you need a user name and password for access. Enter the correct user name and password.

The access will be successful.

The above is how to monitor network traffic under linux. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report