Using the Linux netconsole service to send console messages to remote hosts

Most Linux distributions ship with the netconsole service, which allows kernel printk() messages to be sent to a remote destination. This feature can be useful for debugging system hangs and panics, and is handy for archiving console messages to a central location. To configure netconsole, you will need to add the IP address of a remote syslog server to /etc/sysconfig/netconsole. Here is a sample entry:

# The IP address of the remote syslog server to send messages to
SYSLOGADDR=192.168.1.5

Once the IP is added to the configuration file, you can start the netconsole service:

$ service netconsole start

Initializing netconsole                                    [  OK  ]

$ chkconfig netconsole on

This will load the netconsole kernel module, and write the configuration that was used to the system logs:

Aug 5 13:25:57 disarm netconsole: : inserting netconsole module with arguments \ netconsole=6666@192.168.1.6/eth1,514@192.168.1.5/00:24:8C:0B:EB:AB
Aug 5 13:25:57 disarm kernel: netconsole: local port 6666
Aug 5 13:25:57 disarm kernel: netconsole: local IP 192.168.1.6
Aug 5 13:25:57 disarm kernel: netconsole: interface eth1
Aug 5 13:25:57 disarm kernel: netconsole: remote port 514
Aug 5 13:25:57 disarm kernel: netconsole: remote IP 192.168.1.5
Aug 5 13:25:57 disarm kernel: netconsole: remote ethernet address 00:24:8c:0b:eb:ab
Aug 5 13:25:57 disarm kernel: console [netcon0] enabled
Aug 5 13:25:57 disarm kernel: netconsole: network logging started

If the netconsole service starts up successfully, each console message should be routed to the remote syslog server. If you happen to encounter the following error when you try to start the netconsole service:

$ service netconsole start

Initializing netconsole FATAL: Error inserting netconsole \
(/lib/modules/2.6.29.5-191.fc11.x86_64/kernel/drivers/net/netconsole.ko):  \
Unknown error 524
                                                           [FAILED]

You will need to add the Ethernet interface to the “DEV” variable in the netconsole configuration file (the kernel doesn’t appear to allow bonded or bridged interfaces to work with netconsole, which is one of the drawbacks to using it). I dig netconsole, though it’s no substitute for a properly configured serial console.

3 Comments

Randy  on August 6th, 2009

How is this better or worse than having a centralized syslog server?

matty  on August 6th, 2009

Hey Randy,

Theoretically netconsole allows console messages to be sent to a remote endpoint earlier in the boot process, as well as after rsyslog / syslog have shutdown.

Thanks for the feedback,
- Ryan

Thilak  on October 12th, 2009

Hey Ryan – It is wonderful tech site..I find very useful to go through your blog day by day..

Keep it up !! God Bless

Thilak.

Leave a Comment