|
| 1 | +.. _static_ip: |
| 2 | + |
| 3 | +Using a static IP address |
| 4 | +######################### |
| 5 | + |
| 6 | +When you install ACRN on your system following the :ref:`getting_started`, a |
| 7 | +bridge called ``acrn-br0`` will be created and attached to the Ethernet network |
| 8 | +interface of the platform. By default, the bridge gets its network configuration |
| 9 | +using DHCP. This guide will explain how to modify the system to use a static IP |
| 10 | +address. You need ``root`` privileges to make these changes to the system. |
| 11 | + |
| 12 | +ACRN Network Setup |
| 13 | +****************** |
| 14 | + |
| 15 | +The ACRN Service OS is based on `Clear Linux`_ and it uses `systemd-networkd`_ |
| 16 | +to set up the Service OS networking. A few files are responsible for setting up the |
| 17 | +ACRN bridge (``acrn-br0``), the TAP device (``acrn_tap0``), and how these are all |
| 18 | +connected. Those files are installed in ``/usr/lib/systemd/network`` |
| 19 | +on the target device and can also be found under ``tools/acrnbridge`` in the source code. |
| 20 | + |
| 21 | +Setting up the static IP address |
| 22 | +******************************** |
| 23 | + |
| 24 | +You can set up a static IP address by modifying the |
| 25 | +``/usr/lib/systemd/network/50-eth.network`` file, and more specifically the ``[Network]`` |
| 26 | +section. This is the content of the file used in ACRN by default. |
| 27 | + |
| 28 | +.. literalinclude:: ../../tools/acrnbridge/eth.network |
| 29 | + :caption: tools/acrnbridge/eth.network |
| 30 | + :emphasize-lines: 5 |
| 31 | + |
| 32 | +Edit the file to remove the line highlighted above and add your network settings in |
| 33 | +that ``[Network]`` section. You will typically need to add the ``Address=``, ``Gateway=`` |
| 34 | +and ``DNS=`` parameters in there. There are many more parameters that can be used and |
| 35 | +detailing them is beyond the scope of this document. For an extensive list of those, |
| 36 | +please visit the official `systemd-network`_ page. |
| 37 | + |
| 38 | +This is an example of what a typical ``[Network]`` section would look like, specifying |
| 39 | +a static IP address: |
| 40 | + |
| 41 | +.. code-block:: none |
| 42 | +
|
| 43 | + [Network] |
| 44 | + Address=192.168.1.87/24 |
| 45 | + Gateway=192.168.1.254 |
| 46 | + DNS=192.168.1.254 |
| 47 | +
|
| 48 | +Activate the new configuration |
| 49 | +****************************** |
| 50 | + |
| 51 | +You do not need to reboot the machine after making the changes to the system, the |
| 52 | +following steps that restart the ``systemd-networkd`` service will suffice (run as ``root``): |
| 53 | + |
| 54 | +.. code-block:: console |
| 55 | +
|
| 56 | + systemctl daemon-reload |
| 57 | + systemctl restart systemd-networkd |
| 58 | +
|
| 59 | +If you encounter connectivity issues after following this guide, please contact us on the |
| 60 | +`ACRN-users mailing list`_ or file an issue in `ACRN hypervisor issues`_. Provide the details |
| 61 | +of the configuration you are trying to set up, the modifications you have made to your system, and |
| 62 | +the output of ``journalctl -b -u systemd-networkd`` so we can best assist you. |
| 63 | + |
| 64 | +.. _systemd-networkd: https://www.freedesktop.org/software/systemd/man/systemd-networkd.service.html |
| 65 | +.. _Clear Linux: https://clearlinux.org |
| 66 | +.. _systemd-network: https://www.freedesktop.org/software/systemd/man/systemd.network.html |
| 67 | +.. _ACRN-users mailing list: https://lists.projectacrn.org/g/acrn-users |
| 68 | +.. _ACRN hypervisor issues: https://github.com/projectacrn/acrn-hypervisor/issues |
0 commit comments