Linux Static IP Address Configuration

To configure a static IP address in Linux, you will need to edit the network configuration files. The exact steps you need to take depend on the distribution you’re using, but in general, you will need to edit the configuration file for the network interface you want to configure, such as eth0 or wlan0.

Here’s how to configure a static IP address in Linux:

  1. Open a terminal window.
  2. Determine the name of the network interface you want to configure. You can use the ifconfig command to list all of your network interfaces:
ifconfig
  1. Open the network configuration file for the interface you want to configure. In most distributions, the configuration files are located in the /etc/network or /etc/sysconfig/network-scripts directory. The file will be named something like ifcfg-eth0 or ifcfg-wlan0.
  2. Modify the configuration file to set the static IP address. Here’s an example of what the configuration file might look like with a static IP address:
DEVICE=eth0
BOOTPROTO=static
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1

Replace the IP address, netmask, and gateway values with the values that are appropriate for your network.

  1. Save the configuration file and close the editor.
  2. Restart the network interface or restart the entire system to apply the changes:
sudo ifdown eth0
sudo ifup eth0

Replace eth0 with the name of the network interface you’re configuring.

  1. Verify that the IP address was set correctly by using the ifconfig command:
ifconfig

The IP address for the network interface should now be set to the static IP address you specified in the configuration file.

Note: The steps outlined here are just a general guide and may differ slightly depending on the distribution you’re using. For more specific information, you can consult the documentation or man pages for your distribution’s network configuration tools.

Leave a Comment