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 configure IP address in Ubuntu

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

In this issue, the editor will bring you about how to configure IP addresses in Ubuntu. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

Use the command to set the ip address of ubuntu

1. Modify the configuration file blacklist.conf to disable IPV6:

Sudo vi / etc/modprobe.d/blacklist.conf

two。 Add a blacklist ipv6 at the end of the document, and then view the modification result:

Cat / etc/modprobe.d/blacklist.conf

3. Set IP (set the IP address and subnet mask of the Nic eth0)

Sudo ifconfig eth0 192.168.2.1 netmask 255.255.255.0

4. Set up the gateway

Sudo route add default gw 192.168.2.254

5. Set DNS to modify / etc/resolv.conf, in which address 1 of nameserver DNS and address 2 of nameserver DNS are added.

6. Restart the network service (if not, restart ubuntu:sudo reboot):

Sudo / etc/init.d/networking restart

7. View the current IP:

Ifconfig

Second, directly modify the system configuration file

The network configuration file for ubuntu is: / etc/network/interfaces

After opening it, you can set DHCP or manually set static ip. Front auto eth0, let the network card boot and mount automatically.

1. Configure the network card in DHCP mode

Edit the file / etc/network/interfaces:

Sudo vi / etc/network/interfaces

And replace the line about eth0 with the following line:

# The primary network interface-use DHCP to find our address

Auto eth0

Iface eth0 inet dhcp

Use the following command to make the network settings take effect:

Sudo / etc/init.d/networking restart

You can also enter the following command directly from the command line to get the address

Sudo dhclient eth0

two。 Configure a static IP address for the network card

Edit the file / etc/network/interfaces:

Sudo vi / etc/network/interfaces

And replace the line about eth0 with the following line:

# The primary network interface

Auto eth0

Iface eth0 inet static

Address 192.168.2.1

Gateway 192.168.2.254

Netmask 255.255.255.0

# network 192.168.2.0

# broadcast 192.168.2.255

Change the above ip address and other information to yourself. Use the following command to make the network settings take effect:

Sudo / etc/init.d/networking restart

3. Set the second IP address (virtual IP address)

Edit the file / etc/network/interfaces:

Sudo vi / etc/network/interfaces

Add the following line to the file:

Auto eth0:1

Iface eth0:1 inet static

Address x.x.x.x

Netmask x.x.x.x

Network x.x.x.x

Broadcast x.x.x.x

Gateway x.x.x.x

Fill in all the information such as address,netmask,network,broadcast and gateways according to your situation:

Use the following command to make the network settings take effect:

Sudo / etc/init.d/networking restart

4. Set host name (hostname)

Use the following command to view the host name of the current host:

Sudo / bin/hostname

Use the following command to set the host name of the current host:

Sudo / bin/hostname newname

When the system boots, it reads the name of the host from / etc/hostname.

5. Configure DNS

First of all, you can add some host names and IP addresses corresponding to these host names in / etc/hosts, which is a simple native static query. To access the DNS server for query, you need to set the / etc/resolv.conf file. Assuming that the IP address of the DNS server is 192.168.2.2, the content of the / etc/resolv.conf file should be:

Search chotim.com

Nameserver 192.168.2.2

6. Manually restart the network service:

Sudo / etc/init.d/networking restart

The returned result is as follows:

* Reconfiguring network interfaces... [OK]

The above is how to configure the IP address in the Ubuntu shared by the editor. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to 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