CARA KONFIGURASI IP ADDRESS PADA LINUX UBUNTU SERVER 22.10 DI VIRTUALBOX - 2022 (Indonesia)

3 min read 4 hours ago
Published on Nov 06, 2024 This response is partially generated with the help of AI. It may contain inaccuracies.

Table of Contents

Introduction

This tutorial provides a step-by-step guide for configuring an IP address on an Ubuntu Server 22.10 running in VirtualBox. Understanding how to set up an IP address is essential for ensuring your server can communicate on a network, whether it's local or the internet. This guide will help you navigate the configuration process smoothly.

Step 1: Accessing the Terminal

To start configuring the IP address, you need to open the terminal on your Ubuntu Server.

  • Launch your VirtualBox.
  • Start your Ubuntu Server virtual machine.
  • Once the server is booted, log in with your username and password.
  • Open the terminal by pressing Ctrl + Alt + T or locating it in your applications menu.

Step 2: Checking Current Network Configuration

Before making changes, it’s good to know the current network settings.

  • Run the following command to display your current IP configuration:
    ip a
    
  • Note the network interface name (usually something like eth0 or ens33) and the current IP address settings.

Step 3: Editing the Netplan Configuration File

Ubuntu Server uses Netplan for network configuration. You will need to edit the appropriate YAML file.

  • Navigate to the Netplan configuration directory:
    cd /etc/netplan
    
  • List the files in this directory to find the YAML configuration file:
    ls
    
  • Open the configuration file (it may be named something like 01-netcfg.yaml) using a text editor such as nano:
    sudo nano 01-netcfg.yaml
    

Step 4: Configuring the Static IP Address

In the configuration file, you will define a static IP address.

  • Identify the section that corresponds to your network interface. It should look something like this:
    network:
      version: 2
      renderer: networkd
      ethernets:
        ens33:  # Replace ens33 with your interface name
          dhcp4: true  # Change this line
    
  • Modify it to configure a static IP address. Here’s an example configuration:
    network:
      version: 2
      renderer: networkd
      ethernets:
        ens33:  # Replace ens33 with your interface name
          dhcp4: no
          addresses:
            - 192.168.1.10/24  # Set your desired static IP and subnet mask
          gateway4: 192.168.1.1  # Set your gateway
          nameservers:
            addresses:
              - 8.8.8.8  # Google DNS
              - 8.8.4.4  # Google DNS
    
  • Save and exit the text editor by pressing Ctrl + X, then Y to confirm changes, and Enter.

Step 5: Applying the Configuration

After editing the configuration file, apply the changes to activate the new settings.

  • Run the following command:
    sudo netplan apply
    
  • To verify that the new IP address has been assigned, use:
    ip a
    

Step 6: Testing the Network Connection

It is important to test if your server can communicate properly over the network.

  • Try pinging your gateway:
    ping -c 4 192.168.1.1  # Replace with your gateway IP
    
  • If successful, you should see replies indicating your server is connected.

Conclusion

You have successfully configured a static IP address on your Ubuntu Server in VirtualBox. This is crucial for managing network connections and ensuring your server is accessible on the network. As a next step, consider setting up additional services or applications that require network connectivity. Always remember to keep your network settings documented for future reference.