debain9 修改静态ip地址

本文详细介绍如何在Ubuntu系统中配置静态IP地址,并修改GRUB启动参数以优化系统启动过程。此外,还介绍了如何设置DNS服务器来改善网络连接的质量。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.nano /etc/network/interfaces

2.将enp0s3注释掉,添加 eth0,如下所示

# This file describes the network interfaces available on your system

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


source /etc/network/interfaces.d/*


# The loopback network interface

auto lo


iface lo inet loopback


# The primary network interface

#allow-hotplug enp0s3

#iface enp0s3 inet dhcp

auto eth0

#allow-hotplug eth0

iface eth0 inet static

        address 192.168.10.12

        netmask 255.255.255.0

        gateway 192.168.10.1

#dhcp



3.修改grub 文件 

nano /etc/default/grub.bak  文件

修改内容如下:


# If you change this file, run 'update-grub' afterwards to update

# /boot/grub/grub.cfg.

# For full documentation of the options in this file, see:

#   info -f grub -n 'Simple configuration'


GRUB_DEFAULT=0

GRUB_TIMEOUT=5

GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`

GRUB_CMDLINE_LINUX_DEFAULT="quiet"

GRUB_CMDLINE_LINUX=""


# Uncomment to enable BadRAM filtering, modify to

找到GRUB_CMDLINE_LINUX将参数的值设置为:GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"

4.grub-mkconfig -o /boot/grub/grub.cfg重新生成GRUB引导配置文件,执行完成后,重启系统 ,如果linux系统是安装是虚拟机里面的如:virtualbox 中的,virtualbox 应该设置网络为桥接模式。

5.重启完成后,修改nano /etc/resolv.conf  增加:nameserver 8.8.8.8


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值