歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux管理 >> Linux維護 >> Debian系統下如何配置網絡

Debian系統下如何配置網絡

日期:2017/3/2 10:26:15   编辑:Linux維護

Debian系統的網絡配置和其他一些系統的過程是一樣的,包括配置IP、網關和DNS等等,本文就來簡單介紹一下Debian系統下配置網絡的過程。

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系統下進行網絡配置的方法了,IP地址、網關和DNS設置,每一步都不能省略哦。

Copyright © Linux教程網 All Rights Reserved