Linux Static IP Address Configuration

https:‮/‬/www.lautturi.com
Linux Static IP Address Configuration

To configure a static IP address on a Linux system, you will need to edit the network configuration files for the network interface that you want to assign the static IP address to. The specific steps and configuration files will vary depending on your Linux distribution and version.

Here are the general steps for configuring a static IP address on a Linux system:

  1. Determine the name of the network interface that you want to assign the static IP address to. You can use the ip command to list the available network interfaces on your system:
$ ip link show

The name of the network interface will be listed as eth0, wlan0, etc.

  1. Find the network configuration file for the network interface. On most Linux systems, the network configuration files are located in the /etc/network or /etc/sysconfig/network-scripts directory. The name of the configuration file will usually be the name of the network interface with the .conf or .ifcfg extension (e.g., eth0.conf, wlan0.ifcfg).

  2. Edit the network configuration file using a text editor. You will need to set the following options to configure the static IP address:

  • BOOTPROTO: Set this option to static to specify that you want to use a static IP address.
  • IPADDR: Set this option to the static IP address that you want to use.
  • NETMASK: Set this option to the network mask for the subnet that the IP address belongs to.
  • GATEWAY: Set this option to the default gateway for the network.

Here's an example of a network configuration file that sets a static IP address of 192.168.1.100 with a network mask of 255.255.255.0 and a default gateway of 192.168.1.1:

BOOTPROTO=static
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
  1. Save the network configuration file and exit the text editor.

  2. Restart the network interface to apply the changes. You can use the ifdown and ifup commands to bring the interface down and then back up:

$ sudo ifdown <interface>
$ sudo ifup <interface>

Replace <interface> with the name of the network interface that you want to restart (e.g., eth0, wlan0).

  1. Test the static IP address to make sure that it is working correctly. You can use the ping command to test the connectivity to the default gateway and other devices on the network:
$ ping <gateway>
$ ping <IP address>

Replace <gateway> with the default gateway IP address, and replace <IP address> with the IP address of another device on the network.

Created Time:2017-10-30 10:17:39  Author:lautturi