免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4728 | 回复: 0
打印 上一主题 下一主题

[内核模块] netconsole使用问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2018-08-02 11:36 |只看该作者 |倒序浏览
本帖最后由 tqyou85 于 2018-08-02 15:45 编辑

想启动netconsole将本地主机的内核日志 打印到远程主机上。
本地主机:
1. 修改/etc/sysconfig/netconsole文件
  1. # This is the configuration file for the netconsole service.  By starting
  2. # this service you allow a remote syslog daemon to record console output
  3. # from this system.

  4. # The local port number that the netconsole module will use
  5. LOCALPORT=6666

  6. # The ethernet device to send console messages out of (only set this if it
  7. # can't be automatically determined)
  8. # DEV=

  9. # The IP address of the remote syslog server to send messages to
  10. SYSLOGADDR=172.16.118.118

  11. # The listening port of the remote syslog daemon
  12. SYSLOGPORT=22222

  13. # The MAC address of the remote syslog server (only set this if it can't
  14. # be automatically determined)
  15. # SYSLOGMACADDR=
复制代码


2. 启动netconsole(前提是netconsole已经编译进内核)
/etc/init.d/netconsole start
启动之后dmesg查看有如下信息
  1. [ 2183.363726] netpoll: netconsole: local port 6666
  2. [ 2183.363730] netpoll: netconsole: local IPv4 address 172.16.118.101
  3. [ 2183.363732] netpoll: netconsole: interface 'eth0'
  4. [ 2183.363733] netpoll: netconsole: remote port 22222
  5. [ 2183.363735] netpoll: netconsole: remote IPv4 address 172.16.118.118
  6. [ 2183.363737] netpoll: netconsole: remote ethernet address 00:0c:29:38:8a:35
  7. [ 2183.363762] console [netcon0] enabled
  8. [ 2183.363764] netconsole: network logging started
复制代码

3. 加载自己写的helloworld模块,dmesg查看内核有打印
  1. [ 4278.590553] hello, world!
  2. [ 4280.590391] hello, world!
  3. [ 4282.590218] hello, world!
  4. [ 4284.590041] hello, world!
复制代码




远程主机
执行命令nc -u -l -p 22222
执行完成后,应该能看到“hello, world!”吧?但是现状是什么都没看到。。。

两台主机的防火墙都是关闭的。fedora操作系统,内核版本:3.11.10-301.fc20.i686+PAE
在远程主机上用tcpdump抓包,没有抓到端口22222的udp包

请大侠帮忙看看是怎么回事?




您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP