1 2started by Ingo Molnar <mingo@redhat.com>, 2001.09.17 32.6 port and netpoll api by Matt Mackall <mpm@selenic.com>, Sep 9 2003 4IPv6 support by Cong Wang <xiyou.wangcong@gmail.com>, Jan 1 2013 5 6Please send bug reports to Matt Mackall <mpm@selenic.com> 7Satyam Sharma <satyam.sharma@gmail.com>, and Cong Wang <xiyou.wangcong@gmail.com> 8 9Introduction: 10============= 11 12This module logs kernel printk messages over UDP allowing debugging of 13problem where disk logging fails and serial consoles are impractical. 14 15It can be used either built-in or as a module. As a built-in, 16netconsole initializes immediately after NIC cards and will bring up 17the specified interface as soon as possible. While this doesn't allow 18capture of early kernel panics, it does capture most of the boot 19process. 20 21Sender and receiver configuration: 22================================== 23 24It takes a string configuration parameter "netconsole" in the 25following format: 26 27 netconsole=[src-port]@[src-ip]/[<dev>],[tgt-port]@<tgt-ip>/[tgt-macaddr] 28 29 where 30 src-port source for UDP packets (defaults to 6665) 31 src-ip source IP to use (interface address) 32 dev network interface (eth0) 33 tgt-port port for logging agent (6666) 34 tgt-ip IP address for logging agent 35 tgt-macaddr ethernet MAC address for logging agent (broadcast) 36 37Examples: 38 39 linux netconsole=4444@10.0.0.1/eth1,9353@10.0.0.2/12:34:56:78:9a:bc 40 41 or 42 43 insmod netconsole netconsole=@/,@10.0.0.2/ 44 45 or using IPv6 46 47 insmod netconsole netconsole=@/,@fd00:1:2:3::1/ 48 49It also supports logging to multiple remote agents by specifying 50parameters for the multiple agents separated by semicolons and the 51complete string enclosed in "quotes", thusly: 52 53 modprobe netconsole netconsole="@/,@10.0.0.2/;@/eth1,6892@10.0.0.3/" 54 55Built-in netconsole starts immediately after the TCP stack is 56initialized and attempts to bring up the supplied dev at the supplied 57address. 58 59The remote host has several options to receive the kernel messages, 60for example: 61 621) syslogd 63 642) netcat 65 66 On distributions using a BSD-based netcat version (e.g. Fedora, 67 openSUSE and Ubuntu) the listening port must be specified without 68 the -p switch: 69 70 'nc -u -l -p <port>' / 'nc -u -l <port>' or 71 'netcat -u -l -p <port>' / 'netcat -u -l <port>' 72 733) socat 74 75 'socat udp-recv:<port> -' 76 77Dynamic reconfiguration: 78======================== 79 80Dynamic reconfigurability is a useful addition to netconsole that enables 81remote logging targets to be dynamically added, removed, or have their 82parameters reconfigured at runtime from a configfs-based userspace interface. 83[ Note that the parameters of netconsole targets that were specified/created 84from the boot/module option are not exposed via this interface, and hence 85cannot be modified dynamically. ] 86 87To include this feature, select CONFIG_NETCONSOLE_DYNAMIC when building the 88netconsole module (or kernel, if netconsole is built-in). 89 90Some examples follow (where configfs is mounted at the /sys/kernel/config 91mountpoint). 92 93To add a remote logging target (target names can be arbitrary): 94 95 cd /sys/kernel/config/netconsole/ 96 mkdir target1 97 98Note that newly created targets have default parameter values (as mentioned 99above) and are disabled by default -- they must first be enabled by writing 100"1" to the "enabled" attribute (usually after setting parameters accordingly) 101as described below. 102 103To remove a target: 104 105 rmdir /sys/kernel/config/netconsole/othertarget/ 106 107The interface exposes these parameters of a netconsole target to userspace: 108 109 enabled Is this target currently enabled? (read-write) 110 dev_name Local network interface name (read-write) 111 local_port Source UDP port to use (read-write) 112 remote_port Remote agent's UDP port (read-write) 113 local_ip Source IP address to use (read-write) 114 remote_ip Remote agent's IP address (read-write) 115 local_mac Local interface's MAC address (read-only) 116 remote_mac Remote agent's MAC address (read-write) 117 118The "enabled" attribute is also used to control whether the parameters of 119a target can be updated or not -- you can modify the parameters of only 120disabled targets (i.e. if "enabled" is 0). 121 122To update a target's parameters: 123 124 cat enabled # check if enabled is 1 125 echo 0 > enabled # disable the target (if required) 126 echo eth2 > dev_name # set local interface 127 echo 10.0.0.4 > remote_ip # update some parameter 128 echo cb:a9:87:65:43:21 > remote_mac # update more parameters 129 echo 1 > enabled # enable target again 130 131You can also update the local interface dynamically. This is especially 132useful if you want to use interfaces that have newly come up (and may not 133have existed when netconsole was loaded / initialized). 134 135Miscellaneous notes: 136==================== 137 138WARNING: the default target ethernet setting uses the broadcast 139ethernet address to send packets, which can cause increased load on 140other systems on the same ethernet segment. 141 142TIP: some LAN switches may be configured to suppress ethernet broadcasts 143so it is advised to explicitly specify the remote agents' MAC addresses 144from the config parameters passed to netconsole. 145 146TIP: to find out the MAC address of, say, 10.0.0.2, you may try using: 147 148 ping -c 1 10.0.0.2 ; /sbin/arp -n | grep 10.0.0.2 149 150TIP: in case the remote logging agent is on a separate LAN subnet than 151the sender, it is suggested to try specifying the MAC address of the 152default gateway (you may use /sbin/route -n to find it out) as the 153remote MAC address instead. 154 155NOTE: the network device (eth1 in the above case) can run any kind 156of other network traffic, netconsole is not intrusive. Netconsole 157might cause slight delays in other traffic if the volume of kernel 158messages is high, but should have no other impact. 159 160NOTE: if you find that the remote logging agent is not receiving or 161printing all messages from the sender, it is likely that you have set 162the "console_loglevel" parameter (on the sender) to only send high 163priority messages to the console. You can change this at runtime using: 164 165 dmesg -n 8 166 167or by specifying "debug" on the kernel command line at boot, to send 168all kernel messages to the console. A specific value for this parameter 169can also be set using the "loglevel" kernel boot option. See the 170dmesg(8) man page and Documentation/kernel-parameters.txt for details. 171 172Netconsole was designed to be as instantaneous as possible, to 173enable the logging of even the most critical kernel bugs. It works 174from IRQ contexts as well, and does not enable interrupts while 175sending packets. Due to these unique needs, configuration cannot 176be more automatic, and some fundamental limitations will remain: 177only IP networks, UDP packets and ethernet devices are supported. 178