Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set static IP in Ubuntu

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article is to share with you about how to set static IP in Ubuntu. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article.

1. Modify the network configuration file

Network configuration information is stored in the / etc/network/interfaces file

Sudo vi / etc/network/interfaces

I open it with vi, and my file shows something like this:

# This file describes the network interfaces available on your system

# and how to activate them. For more information, see interfaces (5).

# The loopback network interface

Auto lo

Iface lo inet loopback

There is only one loopback address in my network profile, 127.0.0.1. Add below:

Auto eth0 # indicates that the network card eth0 loads automatically when the system starts up

Iface eth0 inet static # indicates that eth0 uses ipv4 address, inet represents ipv4 address, inet6 represents ipv6 address, static indicates static, and dhcp indicates dynamic

Address 172.22.112.13 # static ip

Netmask 255.255.255.128 # Subnet Mask

Gateway 172.22.112.1 # Gateway address

: wq # Save exit

2. Set up the DNS server

You also need to configure the DNS server under the static ip (as Windows does). The DNS information is stored in / etc/resolv.conf. If you don't have this file, create a new one:

Sudo vi / etc/resolv.conf # Open the file with vi

Enter edit mode, enter a, and then enter the following:

Nameserver 202.202.32.33 # preferred DNS server

Nameserver 61.128.128.68 # standby DNS server

: wq # Save exit

3. After all modifications, you need to restart the Nic to make the changes take effect as follows: enter the following command:

Sudo ifdown eth0 # disable the network card

Sudo ifup eth0 # start the network card

Here are some additions from other netizens

A) set up by command

Tap in the terminal: sudo ifconfig eth0 10.221.20.17 netmask 255.255.255.0

Note that the "0" of eth0 is the number "0"

10.221.20.17:ip address

255.255.255.0: subnet mask

To check whether the setting is successful, tap: ifconfig at the terminal

B) set up through the graphical interface

The above is how to set static IP in Ubuntu. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report