1 minute read

How to Set Static IP for Turtlebot

Introduction

In this tutorial, we will learn how to set a static IP for Turtlebot3 robots using Netplan. We will be using the YAML file provided as an example.

Prerequisites

Before proceeding, ensure that you have the following:

  • A Turtlebot3 robot
  • Access to the YAML file provided in the instructions
  • Basic knowledge of Linux commands

Steps

  1. Open the YAML file in a text editor.
  2. Locate the section that corresponds to the wireless interface (wlan0) as follows:
  3. Change the “dhcp4” parameter from “no” to “yes” as follows:
wifis:
    wlan0:
      dhcp4: no
      addresses:
        - 192.168.0.109/24
      gateway4: 192.168.0.1
      nameservers:
        addresses: [8.8.8.8, 8.8.4.4]
      access-points:
        SSID:
          password: pswd

wifis:
    wlan0:
      dhcp4: yes

  1. Add the following lines to the section:
      dhcp4-overrides:
        use-dns: false
        send-hostname: false

It should look like this

# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: true
      dhcp6: true
      optional: true
  wifis:
    wlan0:
      dhcp4: no
      addresses:
        - 192.168.0.109/24 
      gateway4: 192.168.0.1
      nameservers:
        addresses: [8.8.8.8, 8.8.4.4]
      access-points:
        SSID:
          password: pswd
  1. Save and close the YAML file.
  2. Open a terminal and run the following command to apply the changes:
sudo netplan apply

  1. Check the new IP address assigned to the wireless interface using the following command:
ifconfig wlan0

The output should show the new IP address assigned to the interface.