summaryrefslogtreecommitdiffstats
path: root/Documentation/user/networking.rst
blob: 5822165281e486df76dbaf9919628b8508bc72ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
.. _networking:

Networking
==========

barebox has IPv4 networking support. Several protocols such as :ref:`DHCP
<command_dhcp>`, NFS and TFTP are supported.

Network configuration
---------------------

Lowlevel network device configuration
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Network devices are configured with a set of device specific variables:

+-------------------+--------------+----------------------------------------------------+
| name              | type         |                                                    |
+===================+==============+====================================================+
| <devname>.mode    | enum         | "dhcp": DHCP is used to get IP address and netmask |
|                   |              | "static": Static IP setup described by variables   |
|                   |              | below                                              |
|                   |              | "disabled": Interface unused                       |
+-------------------+--------------+----------------------------------------------------+
| <devname>.ipaddr  | ipv4 address | The IP address when using static configuration     |
+-------------------+--------------+----------------------------------------------------+
| <devname>.netmask | ipv4 address | The netmask when using static configuration        |
+-------------------+--------------+----------------------------------------------------+
| <devname>.gateway | ipv4 address | Alias for global.net.gateway. For                  |
|                   |              | compatibility, do not use.                         |
+-------------------+--------------+----------------------------------------------------+
| <devname>.serverip| ipv4 address | Alias for global.net.server. For                   |
|                   |              | compatibility, do not use.                         |
+-------------------+--------------+----------------------------------------------------+
| <devname>.ethaddr | MAC address  | The MAC address of this device                     |
+-------------------+--------------+----------------------------------------------------+

Additionally there are some more variables that are not specific to a
device:

+------------------------------+--------------+------------------------------------------------+
| name                         | type         |                                                |
+==============================+==============+================================================+
| global.net.gateway           | ipv4 host    | The network gateway used when a host is not in |
|                              |              | any directly visible subnet. May be set        |
|                              |              | automatically by DHCP.                         |
+------------------------------+--------------+------------------------------------------------+
| global.net.server            | ipv4 host    | The default server address. If unspecified, may|
|                              |              | be set by DHCP                                 |
+------------------------------+--------------+------------------------------------------------+
| global.net.nameserver        | ipv4 address | The DNS server used for resolving host names.  |
|                              |              | May be set by DHCP                             |
+------------------------------+--------------+------------------------------------------------+

The first step for networking is configuring the network device. The network
device is usually ``eth0``. The current configuration can be viewed with the
:ref:`devinfo <command_devinfo>` command:

.. code-block:: sh

  barebox:/ devinfo eth0
  Parameters:
    ethaddr: 00:1c:49:01:03:4b
    ipaddr: 192.168.23.197
    netmask: 255.255.0.0
    [...]

The configuration can be changed on the command line with:

.. code-block:: sh

  eth0.ipaddr=172.0.0.10

The :ref:`dhcp command <command_dhcp>` will change the settings based on the answer
from the DHCP server.

To make the network device settings persistent across reboots there is a nonvolatile
variable (nvvar) for each of the varariables above. The network device specific variables
are:

.. code-block:: sh

  nv.dev.<devname>.mode
  nv.dev.<devname>.ipaddr
  nv.dev.<devname>.netmask
  nv.dev.<devname>.ethaddr

The others are:

.. code-block:: sh

  nv.net.gateway
  nv.net.server
  nv.net.nameserver

A typical simple network setting is to use DHCP. Provided the network interface is eth0
then this would configure the network device for DHCP:

.. code-block:: sh

  nv dev.eth0.mode=dhcp

(In fact DHCP is the default, so the above is not necessary)

A static setup would look like:

.. code-block:: sh

  nv dev.eth0.mode=static
  nv dev.eth0.ipaddr=192.168.0.17
  nv dev.eth0.netmask=255.255.0.0
  nv net.server=192.168.0.1

The settings can be activated with the :ref:`ifup command <command_ifup>`:

.. code-block:: sh

  ifup eth0

or:

.. code-block:: sh

  ifup -a

'ifup -a' will activate all ethernet interfaces, also the ones on USB.

Network filesystems
-------------------

barebox supports NFS and TFTP both with commands (:ref:`nfs <command_nfs>` and
:ref:`tftp <command_tftp>`) and as filesystem implementations; see
:ref:`filesystems_nfs` and :ref:`filesystems_tftp` for more information. After
the network device has been brought up, a network filesystem can be mounted
with:

.. code-block:: sh

  mount -t tftp 192.168.2.1 /mnt

or

.. code-block:: sh

  mount -t nfs 192.168.2.1:/export none /mnt

**NOTE:** The execution of the mount command can often be hidden behind the
:ref:`automount command <command_automount>`, to make mounting transparent to
the user.

Network console
---------------

barebox has a UDP-based network console. If enabled in the config, you will see
something like this during startup::

  registered netconsole as netconsole

By default the network console is disabled during runtime to prevent security
risks. It can be enabled using:

.. code-block:: sh

  netconsole.ip=192.168.23.2
  netconsole.active=ioe

This will send UDP packets to a PC with IP address 192.168.23.2 and port 6666.

The ``netconsole.active`` parameter consists of the fields "input" (i),
"output" (o) and "error" (e); if the fields are set, the respective channel is
activated on the network console.

On the PC side, the ``scripts/netconsole`` script can be used to remote control
barebox:

.. code-block:: sh

  scripts/netconsole <board IP> 6666

The netconsole can be used just like any other console. Note, however, that the
simple console protocol is UDP based, so there is no guarantee about packet
loss.