This article will show you how to assign a new IP address to a Linux computer. This will help resolve internet connection problems.
Steps
Method 1 of 2: On Debian-based distributions

Step 1. Upgrade your Linux version
Popular Debian-based Linux distributions are Ubuntu, Mint, and Raspbian.

Step 2. Open a terminal
It is a command line application that is the backbone of all Linux distributions. Depending on the Linux version, the terminal can be opened as follows:
- Press Ctrl + Alt + T or Ctrl + Alt + F1 (on Mac OS X, hold ⌘ Command instead of Ctrl).
- If possible, click on the text box at the top or bottom of the screen.
- Open the "Menu" window and click on "Terminal".

Step 3. Get superuser rights
If you are not logged in as the superuser (root user), type su, press ↵ Enter, enter the superuser password when prompted, and then press ↵ Enter.
The superuser account on Linux is analogous to the administrator account on Windows or Mac OS X

Step 4. Display the list of network interfaces
Type ifconfig and press ↵ Enter. Network interfaces will be displayed on the left side of the window, and information about them on the right.
The list is headed by the active network interface (Wi-Fi or Ethernet). It is labeled “eth0” (Ethernet) or “wifi0” (Wi-Fi)

Step 5. Find the network interface to which you want to assign a new IP address
Pay attention to the name of the interface, which will be displayed on the left side of the window.
In most cases, this interface is "eth0" or "wifi0"

Step 6. Change the IP address of the interface
Enter sudo ifconfig name ip-address netmask 255.255.255.0 up, where replace “name” with the interface name and “ip-address” with the desired IP-address. Press ↵ Enter.
For example, to assign the IP address "192.168.2.100" to an Ethernet connection ("eth0"), enter sudo ifconfig eth0 192.168.0.100 netmask 255.255.255.0

Step 7. Assign a default gateway address
Type route add default gw 192.168.1.1 and press ↵ Enter.

Step 8. Add DNS Server
Type echo "nameserver 8.8.8.8"> /etc/resolv.conf and press ↵ Enter.
If you have a different DNS server address, enter it instead of 8.8.8.8

Step 9. Check if the IP address of the selected network interface has changed
Enter ifconfig, find the network interface and look at the address to the right of the interface name. You will most likely see the IP address you just assigned.
Method 2 of 2: On distributions with an RPM package manager

Step 1. Upgrade your Linux version
Popular Linux distributions with RPM package manager are CentOS, Red Hat, and Fedora.

Step 2. Open a terminal
It is a command line application that is the backbone of all Linux distributions. Depending on the Linux version, the terminal can be opened as follows:
- Press Ctrl + Alt + T or Ctrl + Alt + F1 (on Mac OS X, hold ⌘ Command instead of Ctrl).
- If possible, click on the text box at the top or bottom of the screen.
- Open the "Menu" window and click on "Terminal".

Step 3. Get superuser rights
If you are not logged in as the superuser (root user), type su, press ↵ Enter, enter the superuser password when prompted, and then press ↵ Enter.
The superuser account on Linux is analogous to the administrator account on Windows or Mac OS X

Step 4. Display the list of network interfaces
Enter ip a to display network connections. Step 5. Find the network interface to which you want to assign a new IP address.
This is usually an Ethernet connection or Wi-Fi connection, the current IP address of which can be found on the right side of the window.

Step 6. Go to the network scripts directory
Type cd / etc / sysconfig / network-scripts and press ↵ Enter.

Step 7. Display the network settings
Type ls and press ↵ Enter. The name of the current connection will be displayed in the upper left corner of the network settings.

Step 8. Open the parameters of your network connection
Type vi ifcfg network name and press ↵ Enter. The parameters will open in the Vi editor.
For example, if the network is named “eno12345678,” enter vi ifcfg-eno12345678

Step 9. Change the network settings
Change the following values:
- BOOTPROTO: change dhcp to none.
- Any IPV6 entry: remove all entries from IPV6; to do this, place the cursor next to I (left) and press Del.
- ONBOOT: change no to yes.

Step 10. Create a new category
Press ↵ Enter to go to a new line (from the category ONBOOT), enter
IPADDR =
, enter a new IP address, and then press ↵ Enter.
- For example, if the new IP address is "192.168.2.23", enter
IPADDR = 192.168.2.23
and press ↵ Enter.
Step 11. Enter the netmask, gateway and DNS server address
For this:
- Enter
PREFIX = 24
and press ↵ Enter. You can also enterNETMASK = 255.255.255.0
. - Enter
GATEWAY = 192.168.2.1
and press ↵ Enter. If necessary, replace the gateway address with your own.

Step 12. Save your changes and close the file
To do this, use the File menu or type: wq and press ↵ Enter.