Ubuntu Linux系统下怎么设置静态IP

2023-04-16 18:59:00 设置 系统 静态

在Ubuntu Linux系统下设置静态IP,需要编辑/etc/network/interfaces文件,在其中添加相应的静态IP配置信息。具体步骤如下:

1. 打开终端,使用sudo命令登录系统,输入sudo gedit /etc/network/interfaces,打开interfaces文件。

2. 在interfaces文件中,添加静态IP配置信息。具体格式如下:

auto eth0
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8 8.8.4.4

其中,auto eth0表示在系统启动时自动加载eth0网卡;iface eth0 inet static表示eth0网卡使用静态IP;address 192.168.1.10表示设置IP地址为192.168.1.10;netmask 255.255.255.0表示设置子网掩码为255.255.255.0;gateway 192.168.1.1表示设置网关为192.168.1.1;dns-nameservers 8.8.8.8 8.8.4.4表示设置DNS为8.8.8.8和8.8.4.4。

3. 保存interfaces文件,使用sudo service networking restart命令重启网络服务,使静态IP配置生效。

4. 使用ifconfig命令查看网络信息,确认静态IP配置是否生效。

以上就是在Ubuntu Linux系统下设置静态IP的具体步骤,只要按照上述步骤操作,就可以轻松完成静态IP的设置。

相关文章