Wednesday, October 18, 2023

To set up a #static #IP #address in #Ubuntu #Server

To set up a static IP address in Ubuntu Server, you'll need to make changes to the network configuration files. Here are the steps to do this:

1. Open a terminal window on your Ubuntu Server. You can do this by either connecting directly to the server or using SSH.

2. Determine the network interface name. You can use the `ifconfig` or `ip a` command to list all available network interfaces. Typically, the primary network interface is named something like "eth0" or "ens32." Note down the name of your interface.

3. Edit the network configuration file for your interface. You can use a text editor like nano or vim. Replace "eth0" with your actual interface name in the following command:

       sudo vim /etc/netplan/01-netcfg.yaml

This file may have a different name depending on your Ubuntu version. The important thing is to edit the YAML file in the `/etc/netplan/` directory.

4. Inside the configuration file, you should see something like this:

yaml

   network:

version: 2

renderer: networkd

ethernets:

   eth0:

dhcp4: true

Change `dhcp4: true` to `dhcp4: false` and add your static IP configuration. Here's an example of a static IP configuration:

yaml

   network:

version: 2

renderer: networkd

ethernets:

   eth0:

dhcp4: false

addresses: [192.168.1.10/24]  # Replace with your desired static IP and subnet mask

gateway4: 192.168.1.1       # Replace with your gateway/router IP

nameservers:

   addresses: [8.8.8.8, 8.8.4.4]  # Replace with your DNS server(s) IP

Customize the IP address, subnet mask, gateway, and DNS server addresses to match your network configuration.

5. Save the changes and close the text editor.

6. Apply the network configuration changes by running:

sudo netplan apply

7. To verify that the static IP address is correctly set up, you can run:

ip a

You should see your configured static IP address associated with your network interface.

8. Finally, to ensure that your changes persist across reboots, you may need to disable the cloud-init network configuration by editing the following file:

   sudo nano /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg

   Add the following lines:

network: {config: disabled}

   Save the file and exit.

9. Reboot your server to apply all changes:

sudo reboot

Your Ubuntu Server should now have a static IP address configured. Make sure that the static IP address you choose is not in use by any other device on your network to avoid IP conflicts.


No comments:

Post a Comment

Thank you for Commenting Will reply soon ......

Featured Posts

Installing And Exploring Auto Dark Mode Software

Windows Auto--Night--Mode: Simplify Your Theme Switching   Windows Auto--Night--Mode is a free and lightweight tool that makes switching bet...