温馨提示×

ubuntu如何更改ip地址

小新
19768
2021-04-12 19:27:08
栏目: 智能运维

ubuntu更改ip地址的方法:1.打开终端;2.输入命令打开ubuntu的网络配置文件;3、根据需求修改设置address、gateway、netmask这三个值;4.使用命令使网络设置生效即可。


ubuntu如何更改ip地址


具体操作步骤:

1.首先通过快捷键【Ctrl+Alt+T】打开终端命令行模式。

2.输入以下命令打开ubuntu的网络配置文件。


sudo vi /etc/network/interfaces


3.根据自己的需求修改设置address、gateway、netmask这三个值即可。


# The primary network interface iface eth0 inet static

auto eth0

iface eth0 inet static

address 192.168.2.1 #ip地址

gateway 192.168.2.254 #网关

netmask 255.255.255.0 #子网掩码


4.最后使用以下命令使网络设置生效即可。


sudo /etc/init.d/networking restart


相关操作:

为网卡配置静态IP地址

首先在终端使用“sudo vi /etc/network/interfaces”命令打开网络配置文件。

然后用以下的代码替换有关eth0的行内容,然后输入命令网络配置生效即可。


# 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



sudo /etc/init.d/networking restart #使网络配置生效



0