Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> 關於 Linux

Ubuntu 系統配置 IPv4 網路參數完整教學(DHCP、靜態 IP、虛擬 IP、DNS)

編輯:關於 Linux

IPv4 是互聯網基石協議。在 Ubuntu 中配置 IPv4 主要編輯 /etc/network/interfaces(IP、閘道、子網掩碼)與 /etc/resolv.conf(DNS)。以下提供四種常見場景的設定範例。

1. DHCP 自動獲取 IP

sudo vi /etc/network/interfaces
# 替換 eth0 相關行
auto eth0
iface eth0 inet dhcp
sudo /etc/init.d/networking restart
# 或直接執行
sudo dhclient eth0

2. 靜態 IP 設定

sudo vi /etc/network/interfaces
auto eth0
iface eth0 inet static
address 192.168.3.90
gateway 192.168.3.1
netmask 255.255.255.0
#network 192.168.3.0
#broadcast 192.168.3.255
sudo /etc/init.d/networking restart

3. 虛擬 IP (第二 IP)

sudo vi /etc/network/interfaces
auto eth0:1
iface eth0:1 inet static
address 192.168.1.60
netmask 255.255.255.0
network x.x.x.x
broadcast x.x.x.x
gateway x.x.x.x
sudo /etc/init.d/networking restart

4. DNS 設定

編輯 /etc/resolv.conf:

nameserver 192.168.3.2

亦可在 /etc/hosts 加入靜態主機名對應。修改後重啟網路服務即可生效。

Copyright © Windows教程網 All Rights Reserved