Config ip Address interface Linux

Singharat Kanjanasopon
1 min readJan 7, 2022

--

Debian & Ubuntu

In order to change your IP address on Linux, you will have to add your network configuration in the “/etc/network/interfaces” or create this file if it does not exist already

# Content of /etc/network/interfaces
iface eth0 inet static
address <ip_address>
netmask <network_mask>
gateway <gateway_ip>

For example, let’s say that you want to change your IP to be “192.168.10.10” with a subnet mask of “255.255.255.0” and a default gateway of “192.168.10.10”

$ vim /etc/network/interfaces
# Content of /etc/network/interfaces
iface eth0 inet static
address 192.168.10.10
netmask 255.255.255.0
gateway 192.168.10.1

In order for the changes to be applied, you will need to restart your networking service (managed by ifupdown)

# For systemd hosts
$ sudo systemctl restart networking.service
# For pre-systemd hosts
sudo /etc/init.d/networking restart

CentOS & Red Hat

In order to change your IP address on Linux, you will have to add your network configuration in the “/etc/sysconfig/network-scripts” directory.

In the “/etc/sysconfig/network-scripts”, identify the network interface to be modified and start editing it.

In order for the changes to be applied, you will need to restart your networking service

$ systemctl restart network

--

--

Singharat Kanjanasopon

Certificate: Cisco: CCNA // CompTIA: Security+, Pentest+ // Microtik: MTCNA, MTCTCE, MTCSE, MTCRE //