It seems like your browser didn't download the required fonts. Please revise your security settings and try again.
Barracuda XDR

Configuring a Static IP in Ubuntu

  • Last updated on
Prerequisites

You need the following to configure a Static IP in Ubuntu for the Barracuda XDR Elastic Collector:

  • An Ubuntu installation
  • sudo rights to modify system configuration files
  • (Optional) – join to domain
  • Familiarity with the Vim text editor
  • Familiarity with Netplan (Required for newer Ubuntu environments)

For more information, see https:https://ubuntu.com/server/docs/network-configuration

When configure a static IP in Ubuntu, you'll need to follow these procedures:

To collect information on the current network

You'll need to collect details of the current network configuration so you can make the necessary changes to your configuration. In this procedure, you'll gather the following:

  • Available adapters
  • Respective IP information

You may also want to verify your default gateway configuration.

  1. Log in as an Administrator with sudo rights.
  2. Run the following command to collect the details of the available adapters and respective IP information:
    sudo ip a
    The results look like the following:
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
           valid_lft forever preferred_lft forever
        inet6 ::1/128 scope host
           valid_lft forever preferred_lft forever
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
        link/ether 00:16:3e:e2:52:42 brd ff:ff:ff:ff:ff:ff link-netnsid 0
        inet 192.168.0.2/24 brd 192.168.0.255 scope global dynamic eth0
           valid_lft 3257sec preferred_lft 3257sec
        inet6 fe80::216:3eff:fee2:5242/64 scope link
           valid_lft forever preferred_lft forever

  3. Make a note of the following to use in the next procedure:
    • Network adapter (in the example above, the network adapter is eth0)
    • Current IP address (in the example above, the IP address is 192.168.0.2/24)

      You can use the current IP address to configure a static IP, or you can choose a different one within the host IP range. The procedure below includes instructions for choosing a different IP.

  4. Optionally, run the following command to verify your default gateway configuration:

    sudo ip route show
    The results look like the following:
    default via 192.168.0.1 dev eth0 proto dhcp src 192.168.0.2 metric 100

  5. Make a note of the default gateway (in the example above, the default gateway is 192.168.0.1).

To configure the network

Netplan is the default network management tool for the latest Ubuntu versions. Configuration files for Netplan are written using YAML and end with the extension .yaml.

One of the most common errors in configuration files is misplaced spaces. Be aware that configuration files read spaces as part of the syntax. Your file won't be read properly if you don't use the proper indentation.

  1. Use the following command to list the files in the /etc/netplan directory:

    ls /etc/netplan

  2. Make a note of the existing configuration file if there is one.
  3. Run one of the following commands:
    • To update the configuration file:
      sudo vim /etc/netplan/[config.yaml], where [config.yaml] is the name of the existing configuration file from step 2 above.
    • To create the configuration file is one doesn't exist:
      sudo vim /etc/netplan/01-netcfg.yaml
      01-netcfg.yaml will be the filename of the created configuration file.
  4. Open the configuration file and edit the file with one of the following configurations:
    • For Ubuntu environments Ubuntu Bionic 18.04 LTS and older:
      network:
        version: 2
        renderer: networkd
        ethernets:
          [ethX]:
            addresses:
              - [XXX.XXX.X.XXX/XX]
            gateway4:  [XXX.XXX.X.X]
            nameservers:
                addresses: [X.X.X.X, X.X.X.X]
      Where [ethX] is your network adapter and [XXX.XXX.X.XXX/XX] is the current IP address from step 1;[XXX.XXX.X.X] is the default gateway from step 4, and [X.X.X.X, X.X.X.X] are the nameserver addresses.
    • For newer Ubuntu environments:
      network:
        version: 2
        renderer: networkd
        ethernets:
          [ethX]:
            addresses:
              - [XXX.XXX.X.XXX/XX]
            routes:
              - to: default
                via: [XXX.XXX.X.X]
            nameservers:
                addresses: [X.X.X.X, X.X.X.X]
      Where [ethX] is your network adapter and [XXX.XXX.X.XXX/XX] is the current IP address from step 1;[XXX.XXX.X.X] is the default gateway from step 4, and [X.X.X.X, X.X.X.X] are the nameserver addresses.

  5. Save the file.

To test and apply your changes

  1. Run the following command: 

    sudo netplan try

  2. Do one of the following:
    • If this command runs with no errors, confirm you want to apply the settings.
    • If the command runs with errors, fix the errors and repeat step 1.
  3. Run the following command to verify the static IP has been applied:
    sudo ip a
    You will see results similar to the following:
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
           valid_lft forever preferred_lft forever
        inet6 ::1/128 scope host 
          valid_lft forever preferred_lft forever
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
        link/ether 00:16:3e:e2:52:42 brd ff:ff:ff:ff:ff:ff link-netnsid 0
        inet 192.168.0.100/24 brd 192.168.0.255 scope global dynamic eth0
           valid_lft 3257sec preferred_lft 3257sec
        inet6 fe80::216:3eff:fee2:5242/64 scope link
           valid_lft forever preferred_lft forever