Home > Computer Tutorials > Computer Knowledge > Super detailed tutorial on setting static IP in Linux system!

Super detailed tutorial on setting static IP in Linux system!

WBOY
Release: 2024-03-02 08:22:13
forward
916 people have browsed it

Super detailed tutorial on setting static IP in Linux system!

Setting a static IP address in a Linux system is a key step to ensure a stable and reliable network connection. A detailed tutorial is provided below on how to set up a static IP address on your Linux system.

Step 1: Determine the network interface

First, determine the name of the network interface for which you want to set a static IP address. You can view the network interfaces available on your system using the following command:

ifconfig -a
Copy after login

or

ip addr show
Copy after login

Write down the name of the network interface you want to set, such as "eth0" or "ens33".

Step 2: Edit Network Configuration File

Open the network configuration file to edit network settings. In most Linux distributions, the network configuration file is located in the "/etc/sysconfig/network-scripts/" directory and is prefixed with "ifcfg-" followed by the network interface name.

Open the corresponding file using your favorite text editor, for example:

sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0
Copy after login

Step 3: Configure static IP

In the opened file, make the following settings:

  • Set static IP address:

    IPADDR=192.168.1.100
    Copy after login

    Replace "192.168.1.100" with the static IP address you want to set.

  • Set subnet mask:

    NETMASK=255.255.255.0
    Copy after login

    Replace "255.255.255.0" with the corresponding subnet mask based on your network configuration.

  • Set default gateway:

    GATEWAY=192.168.1.1
    Copy after login

    Replace "192.168.1.1" with your default gateway address.

  • Set DNS server:

    DNS1=8.8.8.8DNS2=8.8.4.4
    Copy after login

    Set one or more DNS server addresses according to your needs.

Save and close the file.

Step 4: Restart the network service

Execute the following command to restart the network service and make the configuration changes take effect:

sudo systemctl restart network
Copy after login

Alternatively, depending on your Linux distribution, you can use the following command:

sudo systemctl restart networking
Copy after login

Step 5: Verify settings

Use the following command to verify that the static IP address is set up successfully:

ifconfig eth0
Copy after login

Replace "eth0" with your network interface name.

You will see the network interface information displayed, including the static IP address set and other configurations.

Through the above steps, you can set a static IP address in the Linux system. Please make sure to configure it accordingly based on your network environment and needs. This will ensure that the system uses the specified static IP address for network connections.

The above is the detailed content of Super detailed tutorial on setting static IP in Linux system!. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:mryunwei.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template