Debian系统下如何配置网络

52次阅读
没有评论

共计 1146 个字符,预计需要花费 3 分钟才能阅读完成。

这篇文章主要介绍“Debian 系统下如何配置网络”,在日常操作中,相信很多人在 Debian 系统下如何配置网络 问题上存在疑惑,丸趣 TV 小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”Debian 系统下如何配置网络”的疑惑有所帮助!接下来,请跟着丸趣 TV 小编一起来学习吧!

1、设置 IP 地址、网关

cp /etc/network/interfaces /etc/network/interfaces.bak # 备份原有配置文件

vi /etc/network/interfaces # 编辑网网卡配置文件

# The loopback network interface

auto lo

iface lo inet loopback

# The primary network interface

auto eth0 # 开机自动连接网络

allow-hotplug eth0

iface eth0 inet static # static 表示使用固定 ip,dhcp 表述使用动态 ip

address 192.168.21.166 # 设置 ip 地址

netmask 255.255.255.0 # 设置子网掩码

gateway 192.168.21.2 # 设置网关

按 ESC 键,然后输入:eq 保存并退出。

下面的版本便于复制,因为配置文件里最好不要有中文:

# The loopback network interface

auto lo

iface lo inet loopback

# The primary network interface

auto eth0

allow-hotplug eth0

iface eth0 inet static

address 192.168.21.166

netmask 255.255.255.0

gateway 192.168.21.1

2、设置 dns

cp /etc/resolv.conf /etc/resolv.conf.bak # 备份原有 dns 配置文件

vi /etc/resolv.conf # 编辑配置文件

nameserver 127.0.0.1

nameserver 8.8.8.8 # 设置首选 dns

nameserver 8.8.4.4 # 设置备用 dns

按 ESC 键,然后输入:eq 保存并退出。

下面的版本便于复制,因为配置文件里最好不要有中文:

nameserver 127.0.0.1

nameserver 8.8.8.8

nameserver 8.8.4.4

3、重启网络

service networking restart # 重启网络

至此,IP 地址、网关、DNS 配置完成,现在系统已经可以上网了。

到此,关于“Debian 系统下如何配置网络”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注丸趣 TV 网站,丸趣 TV 小编会继续努力为大家带来更多实用的文章!

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-07-15发表,共计1146字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)