https://wiki.archlinux.org/api.php?action=feedcontributions&user=Binota&feedformat=atomArchWiki - User contributions [en]2024-03-28T14:53:11ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=User:Binota&diff=351744User:Binota2014-12-22T15:07:29Z<p>Binota: Blanked the page</p>
<hr />
<div></div>Binotahttps://wiki.archlinux.org/index.php?title=Network_configuration_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=313055Network configuration (正體中文)2014-05-02T14:33:42Z<p>Binota: /* 更改裝置名稱 */</p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:Networking (正體中文)]]<br />
[[Category:Getting and installing Arch (正體中文)]]<br />
[[cs:Configuring Network]]<br />
[[el:Configuring Network]]<br />
[[en:Configuring Network]]<br />
[[es:Configuring Network]]<br />
[[fr:Connexions reseau]]<br />
[[it:Configuring Network]]<br />
[[ja:Network Configuration]]<br />
[[nl:Configuring Network]]<br />
[[pt:Configuring Network]]<br />
[[ro:Configurare retea]]<br />
[[ru:Configuring Network]]<br />
[[sk:Configuring Network]]<br />
[[tr:Ağ_Yapılandırması]]<br />
[[zh-CN:Network Configuration]]<br />
{{Related articles start (正體中文)}}<br />
{{Related2|Jumbo Frames|巨型封包 (英)}}<br />
{{Related2|Firewalls|防火牆 (英)}}<br />
{{Related2|Wireless Setup|無線網路設定 (英)}}<br />
{{Related2|List of applications#Network managers|應用程式清單#網路管理員 (英)}}<br />
{{Related articles end}}<br />
{{TranslationStatus (正體中文)|Network_Configuration|2014-05-02|311601}}<br />
<br />
本頁將介紹如何設定'''有線'''網路連線。若您需要設定'''無線'''網路,請參考[[Wireless network configuration|無線網路設定]]。<br />
<br />
== 檢查連線 ==<br />
<br />
{{註記|若您在執行 ping 時收到了類似 {{ic|ping: icmp open socket: Operation not permitted}} 這樣的錯誤訊息,請嘗試重新安裝 {{ic|iputils}} 軟體包。}} <br />
<br />
一般來說,基本的安裝過程都已經建立了可運作的網路設定。請執行下列指令以進行檢查:<br />
<br />
{{註記|{{ic|-c 3}} 選項表示將會呼叫三次。詳細請參閱 {{ic|man ping}} 。}}<br />
{{提示|您也可以嘗試使用其他的 Domain ,如 www.hinet.net 。}}<br />
<br />
{{hc|$ ping -c 3 www.google.com|<nowiki><br />
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.<br />
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms<br />
64 bytes from 74.125.224.146: icmp_req=2 ttl=50 time=385 ms<br />
64 bytes from 74.125.224.146: icmp_req=3 ttl=50 time=298 ms<br />
<br />
--- www.l.google.com ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 1999ms<br />
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms<br />
</nowiki>}}<br />
<br />
如果沒問題的話,您可能只是想以本文的下列部分來自定您的設定。<br />
<br />
若剛才的指令出現了 unknown hosts 之類的訊息,代表您的機器無法解析網域。這可能是因為您的網路服務提供商/閘道造成的。您可以嘗試 ping 一個靜態 IP 以實驗您的機器能否存取網際網路。<br />
{{提示|您也可以嘗試使用其他的 IP ,如 168.95.1.1 。}}<br />
<br />
{{hc|$ ping -c 3 8.8.8.8|<nowiki><br />
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.<br />
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms<br />
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms<br />
64 bytes from 8.8.8.8: icmp_req=3 ttl=53 time=70.6 ms<br />
<br />
--- 8.8.8.8 ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 2002ms<br />
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms<br />
</nowiki>}}<br />
<br />
{{註記|{{ic|8.8.8.8}} 為一個好記的靜態 IP 位置。這是 Google 的主要 DNS 伺服器,這表示其有一定的可信度,並且通常不會被系統或代理伺服器擋下。}}<br />
<br />
若您可以 Ping 通 {{ic|8.8.8.8}} ,但 {{ic|www.google.com}} 不能,請檢查您的 DNS 組態設定檔。詳情請參考 [[resolv.conf]]。<br />
<br />
== 設定主機名稱 ==<br />
<br />
[[Wikipedia:Hostname|主機名稱]]為網路中用於識別機器的唯一識別名稱:主機名稱可以通過 {{ic|/etc/hostname}} 檔案來進行設定。一般來說該檔案包含了系統的網域名稱。下面為設定主機名稱的方法:<br />
<br />
# hostnamectl set-hostname '''myhostname'''<br />
<br />
這樣會將 {{ic|''myhostname''}} 寫入 {{ic|/etc/hostname}} 檔案中。<br />
<br />
詳細請參閱 {{ic|man 5 hostname}} 與 {{ic|man 1 hostnamectl}} 。<br />
<br />
在 {{ic|/etc/hosts}} 中加入相同的主機名稱:<br />
<br />
{{hc|/etc/hosts|<br />
<br />
#<ip-address> <hostname.domain.org> <hostname><br />
127.0.0.1 localhost.localdomain localhost ''myhostname''<br />
::1 localhost.localdomain localhost<br />
}}<br />
<br />
使用來自 {{Pkg|inetutils}} 的 ''hostname'' 以設定臨時主機名稱(直到重新啟動):<br />
<br />
# hostname ''myhostname''<br />
<br />
== 裝置驅動程式 ==<br />
<br />
=== 檢查驅動程式狀態 ===<br />
<br />
[[udev]] 應該會檢測您的網路介面卡([[Wikipedia:Network_interface_controller|NIC]])並自動於啟動時載入必要的模組。檢查 {{ic|lspci -v}} 輸出內容中的「Ethernet controller」 項目(或類似的)。這應該會告訴您哪些核心模組包含了網路設備的驅動程式。舉例來說:<br />
<br />
{{hc|$ lspci -v|<br />
02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)<br />
...<br />
Kernel driver in use: atl1<br />
Kernel modules: atl1<br />
}}<br />
<br />
接下來,確認該驅動程式已經通過 {{ic|dmesg <nowiki>|</nowiki> grep ''module_name''}} 載入了。舉例來說:<br />
<br />
$ dmesg | grep atl1<br />
...<br />
atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex<br />
<br />
若驅動程式已成功加載可以跳過接下來這段。否則,您會需要知道哪些模組時您的特定型號的裝置需要哪個模組。<br />
<br />
=== 載入裝置模組 ===<br />
<br />
以 Google 搜尋正確的晶片組模組/驅動程式。常見的驅動模組有 Realtek 晶片組網卡的 {{ic|8139too}} ,或是 SiS 晶片組網卡的 {{ic|sis900}}。當您知道要使用何種模組了之後,試著[[Kernel modules#Manual module handling|手動將其載入]]。若您得到了錯誤訊息告訴您找不到該模組,則該驅動可能未包含於 Arch 核心中。您可以在 [[AUR]] 中搜尋該模組名稱。<br />
<br />
若 udev 未在開機期間檢測與載入正確的模組,請參閱 [[Kernel modules#Loading]]。<br />
<br />
== 網路介面 ==<br />
<br />
=== 裝置名稱 ===<br />
<br />
對於多網路卡的電腦,固定裝置名稱非常重要。許多設定問題都是因為介面卡名稱的改動造成的。<br />
<br />
[[udev]] 負責命名裝置。Systemd v197 則有[http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames 可預測之網路介面名稱]並可自動支配靜態名稱給網路裝置。介面名稱以 {{ic|en}} (乙太網路)、 {{ic|wl}} (無線網路) 或是 {{ic|ww}} (WWAN)作為前置字串並附上一個自動產生的識別名稱,進而產生了類似 {{ic|enp0s25}} 這樣的名稱。 <br />
<br />
要禁用這種行為,可以將 {{ic|1=net.ifnames=0}} 到您的核心指令列。<br />
<br />
{{提示|您可以執行 {{ic|ip link}} 或是 {{ic|ls /sys/class/net}} 以列出所有可用的介面。}}<br />
<br />
{{註記|當您更改了介面名稱規則後,別忘了更新所有跟網路有關的組態檔案與自定的 systemd unit 檔案以因應該更改。特別是當您啟用了 [[netctl#Basic method|netctl 靜態設定檔]] ,請執行 {{ic|netctl reenable ''profile''}} 以更新所有產生的服務檔案。}}<br />
<br />
==== 更改裝置名稱 ====<br />
<br />
您可以使用 udev-rule 來手動定義裝置名稱。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"<br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"<br />
</nowiki>}}<br />
<br />
請注意這兩點:<br />
<br />
* 使用這個指令以取得 MAC 位置:{{ic|cat /sys/class/net/''設備名稱''/address}}。<br />
* 請確定 udev 規則中使用的是小寫的十六進位數值而不是大寫。<br />
<br />
若該網路卡為動態 MAC ,您可以使用 DEVPATH ,例如:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"<br />
</nowiki>}}<br />
<br />
{{註記|當使用了靜態的名稱時,'''應該要避免使用類似 "eth''X''" 與 "wlan''X''"''' 這樣的名稱,因為這可能會導致核心與 udev 在開機時發生衝突。而剛好相反地,最好使用核心預設不會使用的介面名稱,如 {{ic|net0}} 、 {{ic|net1}} 、 {{ic|wifi0}} 、 {{ic|wifi1}} 。詳細說明請參閱 [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames systemd] 文件。}}<br />
<br />
=== 設定裝置的 MTU 與佇列長度 ===<br />
<br />
您可以手動定義 udev 規則來更改裝置的 MTU 與佇列長度。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1480", ATTR{tx_queue_len}="2000"<br />
</nowiki>}}<br />
<br />
=== 取得目前的裝置名稱 ===<br />
<br />
目前的 NIC 名稱可以通過 sysfs 找到<br />
<br />
{{hc|$ ls /sys/class/net|<br />
lo eth0 eth1 firewire0<br />
}}<br />
<br />
=== 啟用與禁用網路介面 ===<br />
<br />
您可以使用下列指令來啟用或禁用網路介面:<br />
<br />
# ip link set eth0 up<br />
# ip link set eth0 down<br />
<br />
要確認結果,請執行:<br />
<br />
{{hc|$ ip link show dev eth0|<br />
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000<br />
...<br />
}}<br />
<br />
== 組態設定 IP 位址 ==<br />
<br />
您有兩個選擇:使用 [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]] 指派動態位址,或是使用「靜態」的位址。<br />
<br />
=== 動態 IP 位址 ===<br />
<br />
==== dhcpcd ====<br />
<br />
最簡單的方式就是使用 [[dhcpcd]],它包含在 {{Grp|base}} 群組中。無論是使用提供服務檔案 {{ic|dhcpcd@.service}} ,以參數方式傳入介面卡名稱,或是手動通過 {{ic|dhcpcd ''interface''}} 將其執行。<br />
<br />
=== 靜態 IP 位址 ===<br />
<br />
您可能因為各種原因而希望在您的網路中指派靜態 IP 位址,例如靜態的位址可以獲得一定程度的可預測性,或是您沒有可用的 DHCP 伺服器。<br />
<br />
{{註記|若您通過 Windows 機器來共享您的網路而不是使用路由器,請確保兩台電腦皆使用了靜態 IP 位址以避免區域網路問題。}}<br />
<br />
您需要:<br />
<br />
* 靜態 IP 位址<br />
* [[Wikipedia:Subnetwork|子網路遮罩]]<br />
* [[Wikipedia:Broadcast_address|廣播位址]]<br />
* [[Wikipedia:Default_gateway|預設閘道器]]的 IP 位址<br />
<br />
若您處在內部網路中,使用 192.168.*.* 這樣的 IP 位址較為安全,搭配其的子網路遮罩 255.255.255.0 ,廣播位址為 192.168.*.255 。而閘道通常是 192.168.*.1 或是 192.168.*.254 。<br />
<br />
{{Tip|You may need to manually set the DNS servers, see [[resolv.conf]] for details.}}<br />
<br />
==== 手動指派 ====<br />
<br />
您可於控制台中指派一靜態 IP 位址:<br />
<br />
# ip addr add ''IP位址''/''子網路遮罩'' broadcast ''廣播'' dev ''介面''<br />
<br />
舉例來說:<br />
<br />
# ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev eth0<br />
<br />
{{註記|子網路遮罩使用了 [[Wikipedia:CIDR_notation|CIDR 表示法]](CIDR,Classless Inter-Domain Routing,無類別網路間路由)。}}<br />
<br />
詳情請參閱 {{ic|man ip}} 。<br />
<br />
以類似下列的方法加上您的 IP 位址:<br />
<br />
# ip route add default via ''預設閘道IP位址''<br />
<br />
舉例來說:<br />
<br />
# ip route add default via 192.168.1.1<br />
<br />
若您得到了 "No such process" 這樣的錯誤訊息,這代表您必須以 root 執行 {{ic|ip link set dev eth0 up}} 。<br />
<br />
==== 永久於啟動時通過 systemd 進行組態設定與 udev 規則 ====<br />
<br />
首先先為 [[systemd]] 服務建立一個組態設定檔,請以網路介面卡名稱取代下列的 {{ic|''interface''}}:<br />
<br />
{{hc|/etc/conf.d/network@''interface''|<nowiki><br />
address=192.168.0.15<br />
netmask=24<br />
broadcast=192.168.0.255<br />
gateway=192.168.0.1<br />
</nowiki>}}<br />
<br />
建立 systemd unit 檔案:<br />
<br />
{{hc|/etc/systemd/system/network@.service|<nowiki><br />
[Unit]<br />
Description=Network connectivity (%i)<br />
Wants=network.target<br />
Before=network.target<br />
BindsTo=sys-subsystem-net-devices-%i.device<br />
After=sys-subsystem-net-devices-%i.device<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
EnvironmentFile=/etc/conf.d/network@%i<br />
<br />
ExecStart=/usr/bin/ip link set dev %i up<br />
ExecStart=/usr/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i<br />
ExecStart=/usr/bin/sh -c 'test -n ${gateway} && /usr/bin/ip route add default via ${gateway}'<br />
<br />
ExecStop=/usr/bin/ip addr flush dev %i<br />
ExecStop=/usr/bin/ip link set dev %i down<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
啟用該 unit 並將其啟動,傳入介面名稱:<br />
<br />
# systemctl enable network@''介面名稱''.service<br />
# systemctl start network@''介面名稱''.service<br />
<br />
==== 計算位址 ====<br />
<br />
您可以使用 {{Pkg|ipcalc}} 提供的 {{ic|ipcalc}} 來計算 IP 廣播、網域、子網路遮罩與主機範圍等進階設定舉例來說,我使用了位於防火牆後的乙太網路來連線 Windows 機器至 Arch。為了安全性與網路組織,我將他們放置於各自獨立的網路,接著組態設定子網路遮罩與廣播位址,如此一來網路中就只有兩台機器。為了找出子網路遮罩跟廣播位址,我使用了 ipcalc ,提供其 Arch firewire nic 的 IP 位址 10.66.66.1 ,並指定 ipcalc 要建立一個只有兩台主機的網路。<br />
<br />
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|<nowiki><br />
Address: 10.66.66.1<br />
<br />
Netmask: 255.255.255.252 = 30<br />
Network: 10.66.66.0/30<br />
HostMin: 10.66.66.1<br />
HostMax: 10.66.66.2<br />
Broadcast: 10.66.66.3<br />
Hosts/Net: 2 Class A, Private Internet<br />
</nowiki>}}<br />
<br />
=== systemd-networkd ===<br />
<br />
若 [[systemd]] 的版本為 209 以上(含),則可使用 [[systemd-networkd]] 來管理網路,可輕鬆地代替在 Containers 與虛擬機中設定網路。並可同時管理動態與靜態 IP 位址。<br />
<br />
== 載入組態設定 ==<br />
<br />
要測試您的設定,您可以重新啟動電腦或是重新載入相關的 systemd 服務。然後嘗試 Ping 您的閘道器、DNS 伺服器、ISP 業者與其他的網際網路站台,用這樣的方式便能檢測哪裡出了問題,舉例來說:<br />
<br />
$ ping -c 3 www.google.com<br />
<br />
== 附加設定 ==<br />
<br />
=== 筆記型電腦之 ifplugd ===<br />
<br />
{{提示|[[dhcpcd]] 提供了開箱即用的相同功能。}}<br />
<br />
[[Official Repositories (正體中文)|官方軟體套件庫]]中的 {{Pkg|ifplugd}} 為一個當網路線插入後自動組態乙太設備;網路線拔除後自動取消組態的 Daemon 。<br />
這對於搭載內建網路介面卡的筆記型電腦特別有用,因為其只會在網路線真正連上後才會對介面進行組態。另一個會用到的情況為,當您需要重新啟動網路,但您並不想重開及或在 Shell 中進行設定。<br />
<br />
預設情況下,其會對 {{ic|eth0}} 裝置進行設定使其運作。這與其他設定類似延遲之類的設定能在 {{ic|/etc/ifplugd/ifplugd.conf}} 中進行設定。<br />
<br />
<br />
{{註記|[[Netctl]] 軟體包包含了 {{ic|netctl-ifplugd@.service}},否則您可以使用來自 {{Pkg|ifplugd}} 軟體包的 {{ic|ifplugd@.service}} 。例如這樣使用:{{ic|systemctl enable ifplugd@eth0.service}}。}}<br />
<br />
=== Bonding 或 LAG ===<br />
<br />
請參閱 [[netctl#Bonding]] 。<br />
<br />
=== IP 別名 ===<br />
<br />
{{Expansion|Manual method using [[Core utilities#ip|ip]] should be added; then move current example using ''netctl'' into [[netctl]].}}<br />
<br />
IP 別名為讓同一個網路介面有多個 IP 位址。如此一來,單個節點的網路就能有多個網路連線,進而實現不同的作用。經典的使用方法為網頁與 FTP 伺服器的虛擬主機,或是重組伺服器而無需更新任何其他的機器(對於名稱伺服器來說特別有用)。<br />
<br />
==== 範例 ====<br />
<br />
您將需要來自[[Official Repositories (正體中文)|官方軟體套件庫]]的 {{Pkg|netctl}} 。<br />
<br />
準備組態設定檔:<br />
<br />
{{hc|/etc/netctl/mynetwork|<nowiki><br />
Connection='ethernet'<br />
Description='Five different addresses on the same NIC.'<br />
Interface='eth0'<br />
IP='static'<br />
Address=('192.168.1.10' '192.168.178.11' '192.168.1.12' '192.168.1.13' '192.168.1.14' '192.168.1.15')<br />
Gateway='192.168.1.1'<br />
DNS=('192.168.1.1')<br />
</nowiki>}}<br />
<br />
接著只需要將其執行即可:<br />
<br />
$ netctl start mynetwork<br />
<br />
=== 更改 MAC/硬體 位址 ===<br />
<br />
請參閱 [[MAC Address Spoofing]] 。<br />
<br />
=== 網路共享 ===<br />
<br />
請參閱 [[Internet Sharing]] 。<br />
<br />
=== 路由組態設定 ===<br />
<br />
請參閱 [[Router]] 。<br />
<br />
=== 區域網路主機名稱解析 ===<br />
<br />
先決條件為[[#.E8.A8.AD.E5.AE.9A.E4.B8.BB.E6.A9.9F.E5.90.8D.E7.A8.B1|設定主機名稱]]之後,主機名稱可在本機系統上解析:<br />
{{hc|$ ping hostname|<br />
PING hostname <nowiki>(192.168.1.2) 56(84) bytes of data.<br />
64 bytes from hostname (192.168.1.2): icmp_seq=1 ttl=64 time=0.043 ms</nowiki>}}<br />
要以其他機器的名稱來解析主機,需要手動設定各自的 {{ic|/etc/hosts}} 檔案或是廣播/解析名稱的服務。<br />
<br />
過度設定 DNS 伺服器,如 [[BIND]] 、 [[Unbound]] ,手動編輯 {{ic|/etc/hosts}} 過於繁瑣,或是您希望對於動態地將主機離開、加入網路有更大的靈活性,您可以在您的區域網路中使用 Zero-configuration networking 來進行主機名稱解析。這裡有兩個可用選擇:<br />
<br />
*[[Samba]] 提供了通過微軟 '''NetBIOS''' 的主機名稱解析。其只需要安裝 {{Pkg|samba}} 並啟用 {{ic|nmbd.service}} 服務。執行 Windows 、OS X 或執行了 {{ic|nmbd}} 的 Linux ,將能夠找到您的機器。<br />
<br />
*[[Avahi]] 提供通過 '''zeroconf''' 的主機名稱解析,也稱作 Avahi 或 Boujour 。它比 Samba 還需要稍微複雜一點的設定:詳情請參考 [[Avahi#Hostname resolution]]。執行 OS X 或執行了 Avahi daemon 的 Linux ,將能夠找到您的機器。Windows 並無內建 Avahi 用戶端或 Daemon 。<br />
<br />
=== 雜亂模式 ===<br />
<br />
Toggling [https://en.wikipedia.org/wiki/Promiscuous_mode promiscuous mode] will make a (wireless) NIC forward all traffic it receives to the OS for further processing. This is opposite to "normal mode" where a NIC will drop frames it is not intended to receive. It is most often used for advanced network troubleshooting and [https://en.wikipedia.org/wiki/Packet_sniffing packet sniffing].<br />
<br />
{{hc|/etc/systemd/system/promiscuous@.service|<nowiki><br />
[Unit]<br />
Description=Set %i interface in promiscuous mode<br />
After=network.target<br />
<br />
[Service]<br />
Type=oneshot<br />
ExecStart=/usr/bin/ip link set dev %i promisc on<br />
RemainAfterExit=yes<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
若您想在介面卡 {{ic|eth0}} 中啟用雜亂模式,請執行:<br />
<br />
# systemctl enable promiscuous@eth0.service<br />
<br />
== 診斷 ==<br />
<br />
=== Swapping computers on the cable modem ===<br />
<br />
Some cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.<br />
<br />
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].<br />
<br />
=== The TCP window scaling problem ===<br />
<br />
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.<br />
<br />
Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html RFC 1323] was written to improve the situation: Window Scaling. The "window" value, provided in all packets, will be modified by a Scale Factor defined once, at the very beginning of the connection.<br />
<br />
That 8-bit Scale Factor allows the Window to be up to 32 times higher than the initial 64Kb.<br />
<br />
It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts.<br />
<br />
The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.<br />
<br />
The resulting connection is at best very slow or broken.<br />
<br />
==== How to diagnose the problem ====<br />
<br />
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).<br />
<br />
When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|ip addr}} will report normal status... and actually everything appears normal.<br />
<br />
If you cannot browse any website, but you can ping some random hosts, chances are great that you're experiencing this problem: ping uses ICMP and is not affected by TCP problems.<br />
<br />
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).<br />
<br />
==== How to fix it (The bad way) ====<br />
<br />
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.<br />
<br />
# echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem<br />
<br />
==== How to fix it (The good way) ====<br />
<br />
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.d/99-disable_window_scaling.conf}} (see also [[sysctl]])<br />
<br />
net.ipv4.tcp_window_scaling = 0<br />
<br />
==== How to fix it (The best way) ====<br />
<br />
This problem is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.<br />
<br />
==== More about it ====<br />
<br />
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].<br />
<br />
There are also several relevant threads on the LKML.<br />
<br />
=== Realtek no link / WOL problem ===<br />
<br />
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice a problem where the NIC seems to be disabled on boot and has no Link light. This can usually be found on a dual boot system where Windows is also installed. It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause. These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots. You will be able to notice if this problem is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off. Normal operation should be that the link light is always on as long as the system is on, even during POST. This problem will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this problem:<br />
<br />
==== Method 1 - Enable the NIC directly in Linux ====<br />
<br />
Get the ethernet NIC name from the output of<br />
<br />
$ ip a<br />
<br />
Bring up the device as root using the NIC name:<br />
<br />
# ip link set dev <NIC_name> up<br />
<br />
For ex, if <NIC_name> is enp7s0<br />
<br />
# ip link set dev enp7s0 up<br />
<br />
If it worked and the card is powered on, you should see {{ic|state UP}} for the given interface in the output of {{ic|ip link}}.<br />
<br />
==== Method 2 - Rollback/change Windows driver ====<br />
<br />
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).<br />
<br />
==== Method 3 - Enable WOL in Windows driver ====<br />
<br />
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems). In Windows, under Device Manager, find your Realtek network adapter and double-click it. Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.<br />
<br />
In Windows XP (example)<br />
Right click my computer<br />
--> Hardware tab<br />
--> Device Manager<br />
--> Network Adapters<br />
--> "double click" Realtek ...<br />
--> Advanced tab<br />
--> Wake-On-Lan After Shutdown<br />
--> Enable<br />
<br />
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{ic|Disable}} has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.}}<br />
<br />
==== Method 4 - Newer Realtek Linux driver ====<br />
<br />
Any newer driver for these Realtek cards can be found for Linux on the realtek site. (untested but believed to also solve the problem).<br />
<br />
==== Method 5 - Enable ''LAN Boot ROM'' in BIOS/CMOS ====<br />
<br />
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.<br />
<br />
{{Note|This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.}}<br />
<br />
=== No interface with Atheros chipsets ===<br />
<br />
Users of some Atheros ethernet chips are reporting it does not work out-of-the-box (with installation media of February 2014). The working solution for this is to install the package {{AUR|backports-patched}} from AUR.<br />
<br />
=== Broadcom BCM57780 ===<br />
<br />
This Broadcom chipset sometimes does not behave well unless you specify the order of the modules to be loaded. The modules are {{ic|broadcom}} and {{ic|tg3}}, the former needing to be loaded first.<br />
<br />
These steps should help if your computer has this chipset:<br />
$ lspci | grep Ethernet<br />
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)<br />
<br />
If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following (as root):<br />
# modprobe -r tg3<br />
# modprobe broadcom<br />
# modprobe tg3<br />
<br />
Now plug you network cable in. If this solves your problems you can make this permanent by adding {{ic|broadcom}} and {{ic|tg3}} (in this order) to the {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}}:<br />
<br />
MODULES=".. broadcom tg3 .."<br />
<br />
Then rebuild the initramfs:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|These methods may work for other chipsets, such as BCM57760.}}</div>Binotahttps://wiki.archlinux.org/index.php?title=Network_configuration_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=313054Network configuration (正體中文)2014-05-02T14:32:44Z<p>Binota: translate....</p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:Networking (正體中文)]]<br />
[[Category:Getting and installing Arch (正體中文)]]<br />
[[cs:Configuring Network]]<br />
[[el:Configuring Network]]<br />
[[en:Configuring Network]]<br />
[[es:Configuring Network]]<br />
[[fr:Connexions reseau]]<br />
[[it:Configuring Network]]<br />
[[ja:Network Configuration]]<br />
[[nl:Configuring Network]]<br />
[[pt:Configuring Network]]<br />
[[ro:Configurare retea]]<br />
[[ru:Configuring Network]]<br />
[[sk:Configuring Network]]<br />
[[tr:Ağ_Yapılandırması]]<br />
[[zh-CN:Network Configuration]]<br />
{{Related articles start (正體中文)}}<br />
{{Related2|Jumbo Frames|巨型封包 (英)}}<br />
{{Related2|Firewalls|防火牆 (英)}}<br />
{{Related2|Wireless Setup|無線網路設定 (英)}}<br />
{{Related2|List of applications#Network managers|應用程式清單#網路管理員 (英)}}<br />
{{Related articles end}}<br />
{{TranslationStatus (正體中文)|Network_Configuration|2014-05-02|311601}}<br />
<br />
本頁將介紹如何設定'''有線'''網路連線。若您需要設定'''無線'''網路,請參考[[Wireless network configuration|無線網路設定]]。<br />
<br />
== 檢查連線 ==<br />
<br />
{{註記|若您在執行 ping 時收到了類似 {{ic|ping: icmp open socket: Operation not permitted}} 這樣的錯誤訊息,請嘗試重新安裝 {{ic|iputils}} 軟體包。}} <br />
<br />
一般來說,基本的安裝過程都已經建立了可運作的網路設定。請執行下列指令以進行檢查:<br />
<br />
{{註記|{{ic|-c 3}} 選項表示將會呼叫三次。詳細請參閱 {{ic|man ping}} 。}}<br />
{{提示|您也可以嘗試使用其他的 Domain ,如 www.hinet.net 。}}<br />
<br />
{{hc|$ ping -c 3 www.google.com|<nowiki><br />
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.<br />
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms<br />
64 bytes from 74.125.224.146: icmp_req=2 ttl=50 time=385 ms<br />
64 bytes from 74.125.224.146: icmp_req=3 ttl=50 time=298 ms<br />
<br />
--- www.l.google.com ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 1999ms<br />
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms<br />
</nowiki>}}<br />
<br />
如果沒問題的話,您可能只是想以本文的下列部分來自定您的設定。<br />
<br />
若剛才的指令出現了 unknown hosts 之類的訊息,代表您的機器無法解析網域。這可能是因為您的網路服務提供商/閘道造成的。您可以嘗試 ping 一個靜態 IP 以實驗您的機器能否存取網際網路。<br />
{{提示|您也可以嘗試使用其他的 IP ,如 168.95.1.1 。}}<br />
<br />
{{hc|$ ping -c 3 8.8.8.8|<nowiki><br />
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.<br />
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms<br />
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms<br />
64 bytes from 8.8.8.8: icmp_req=3 ttl=53 time=70.6 ms<br />
<br />
--- 8.8.8.8 ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 2002ms<br />
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms<br />
</nowiki>}}<br />
<br />
{{註記|{{ic|8.8.8.8}} 為一個好記的靜態 IP 位置。這是 Google 的主要 DNS 伺服器,這表示其有一定的可信度,並且通常不會被系統或代理伺服器擋下。}}<br />
<br />
若您可以 Ping 通 {{ic|8.8.8.8}} ,但 {{ic|www.google.com}} 不能,請檢查您的 DNS 組態設定檔。詳情請參考 [[resolv.conf]]。<br />
<br />
== 設定主機名稱 ==<br />
<br />
[[Wikipedia:Hostname|主機名稱]]為網路中用於識別機器的唯一識別名稱:主機名稱可以通過 {{ic|/etc/hostname}} 檔案來進行設定。一般來說該檔案包含了系統的網域名稱。下面為設定主機名稱的方法:<br />
<br />
# hostnamectl set-hostname '''myhostname'''<br />
<br />
這樣會將 {{ic|''myhostname''}} 寫入 {{ic|/etc/hostname}} 檔案中。<br />
<br />
詳細請參閱 {{ic|man 5 hostname}} 與 {{ic|man 1 hostnamectl}} 。<br />
<br />
在 {{ic|/etc/hosts}} 中加入相同的主機名稱:<br />
<br />
{{hc|/etc/hosts|<br />
<br />
#<ip-address> <hostname.domain.org> <hostname><br />
127.0.0.1 localhost.localdomain localhost ''myhostname''<br />
::1 localhost.localdomain localhost<br />
}}<br />
<br />
使用來自 {{Pkg|inetutils}} 的 ''hostname'' 以設定臨時主機名稱(直到重新啟動):<br />
<br />
# hostname ''myhostname''<br />
<br />
== 裝置驅動程式 ==<br />
<br />
=== 檢查驅動程式狀態 ===<br />
<br />
[[udev]] 應該會檢測您的網路介面卡([[Wikipedia:Network_interface_controller|NIC]])並自動於啟動時載入必要的模組。檢查 {{ic|lspci -v}} 輸出內容中的「Ethernet controller」 項目(或類似的)。這應該會告訴您哪些核心模組包含了網路設備的驅動程式。舉例來說:<br />
<br />
{{hc|$ lspci -v|<br />
02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)<br />
...<br />
Kernel driver in use: atl1<br />
Kernel modules: atl1<br />
}}<br />
<br />
接下來,確認該驅動程式已經通過 {{ic|dmesg <nowiki>|</nowiki> grep ''module_name''}} 載入了。舉例來說:<br />
<br />
$ dmesg | grep atl1<br />
...<br />
atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex<br />
<br />
若驅動程式已成功加載可以跳過接下來這段。否則,您會需要知道哪些模組時您的特定型號的裝置需要哪個模組。<br />
<br />
=== 載入裝置模組 ===<br />
<br />
以 Google 搜尋正確的晶片組模組/驅動程式。常見的驅動模組有 Realtek 晶片組網卡的 {{ic|8139too}} ,或是 SiS 晶片組網卡的 {{ic|sis900}}。當您知道要使用何種模組了之後,試著[[Kernel modules#Manual module handling|手動將其載入]]。若您得到了錯誤訊息告訴您找不到該模組,則該驅動可能未包含於 Arch 核心中。您可以在 [[AUR]] 中搜尋該模組名稱。<br />
<br />
若 udev 未在開機期間檢測與載入正確的模組,請參閱 [[Kernel modules#Loading]]。<br />
<br />
== 網路介面 ==<br />
<br />
=== 裝置名稱 ===<br />
<br />
對於多網路卡的電腦,固定裝置名稱非常重要。許多設定問題都是因為介面卡名稱的改動造成的。<br />
<br />
[[udev]] 負責命名裝置。Systemd v197 則有[http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames 可預測之網路介面名稱]並可自動支配靜態名稱給網路裝置。介面名稱以 {{ic|en}} (乙太網路)、 {{ic|wl}} (無線網路) 或是 {{ic|ww}} (WWAN)作為前置字串並附上一個自動產生的識別名稱,進而產生了類似 {{ic|enp0s25}} 這樣的名稱。 <br />
<br />
要禁用這種行為,可以將 {{ic|1=net.ifnames=0}} 到您的核心指令列。<br />
<br />
{{提示|您可以執行 {{ic|ip link}} 或是 {{ic|ls /sys/class/net}} 以列出所有可用的介面。}}<br />
<br />
{{註記|當您更改了介面名稱規則後,別忘了更新所有跟網路有關的組態檔案與自定的 systemd unit 檔案以因應該更改。特別是當您啟用了 [[netctl#Basic method|netctl 靜態設定檔]] ,請執行 {{ic|netctl reenable ''profile''}} 以更新所有產生的服務檔案。}}<br />
<br />
==== 更改裝置名稱 ====<br />
<br />
您可以使用 udev-rule 來手動定義裝置名稱。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"<br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"<br />
</nowiki>}}<br />
<br />
請注意這兩點:<br />
<br />
* 使用這個指令以取得 MAC 位置:{{ic|cat /sys/class/net/''device_name''/address}}。<br />
* 請確定 udev 規則中使用的是小寫的十六進位數值而不是大寫。<br />
<br />
若該網路卡為動態 MAC ,您可以使用 DEVPATH ,例如:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"<br />
</nowiki>}}<br />
<br />
{{註記|當使用了靜態的名稱時,'''應該要避免使用類似 "eth''X''" 與 "wlan''X''"''' 這樣的名稱,因為這可能會導致核心與 udev 在開機時發生衝突。而剛好相反地,最好使用核心預設不會使用的介面名稱,如 {{ic|net0}} 、 {{ic|net1}} 、 {{ic|wifi0}} 、 {{ic|wifi1}} 。詳細說明請參閱 [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames systemd] 文件。}}<br />
<br />
=== 設定裝置的 MTU 與佇列長度 ===<br />
<br />
您可以手動定義 udev 規則來更改裝置的 MTU 與佇列長度。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1480", ATTR{tx_queue_len}="2000"<br />
</nowiki>}}<br />
<br />
=== 取得目前的裝置名稱 ===<br />
<br />
目前的 NIC 名稱可以通過 sysfs 找到<br />
<br />
{{hc|$ ls /sys/class/net|<br />
lo eth0 eth1 firewire0<br />
}}<br />
<br />
=== 啟用與禁用網路介面 ===<br />
<br />
您可以使用下列指令來啟用或禁用網路介面:<br />
<br />
# ip link set eth0 up<br />
# ip link set eth0 down<br />
<br />
要確認結果,請執行:<br />
<br />
{{hc|$ ip link show dev eth0|<br />
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000<br />
...<br />
}}<br />
<br />
== 組態設定 IP 位址 ==<br />
<br />
您有兩個選擇:使用 [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]] 指派動態位址,或是使用「靜態」的位址。<br />
<br />
=== 動態 IP 位址 ===<br />
<br />
==== dhcpcd ====<br />
<br />
最簡單的方式就是使用 [[dhcpcd]],它包含在 {{Grp|base}} 群組中。無論是使用提供服務檔案 {{ic|dhcpcd@.service}} ,以參數方式傳入介面卡名稱,或是手動通過 {{ic|dhcpcd ''interface''}} 將其執行。<br />
<br />
=== 靜態 IP 位址 ===<br />
<br />
您可能因為各種原因而希望在您的網路中指派靜態 IP 位址,例如靜態的位址可以獲得一定程度的可預測性,或是您沒有可用的 DHCP 伺服器。<br />
<br />
{{註記|若您通過 Windows 機器來共享您的網路而不是使用路由器,請確保兩台電腦皆使用了靜態 IP 位址以避免區域網路問題。}}<br />
<br />
您需要:<br />
<br />
* 靜態 IP 位址<br />
* [[Wikipedia:Subnetwork|子網路遮罩]]<br />
* [[Wikipedia:Broadcast_address|廣播位址]]<br />
* [[Wikipedia:Default_gateway|預設閘道器]]的 IP 位址<br />
<br />
若您處在內部網路中,使用 192.168.*.* 這樣的 IP 位址較為安全,搭配其的子網路遮罩 255.255.255.0 ,廣播位址為 192.168.*.255 。而閘道通常是 192.168.*.1 或是 192.168.*.254 。<br />
<br />
{{Tip|You may need to manually set the DNS servers, see [[resolv.conf]] for details.}}<br />
<br />
==== 手動指派 ====<br />
<br />
您可於控制台中指派一靜態 IP 位址:<br />
<br />
# ip addr add ''IP位址''/''子網路遮罩'' broadcast ''廣播'' dev ''介面''<br />
<br />
舉例來說:<br />
<br />
# ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev eth0<br />
<br />
{{註記|子網路遮罩使用了 [[Wikipedia:CIDR_notation|CIDR 表示法]](CIDR,Classless Inter-Domain Routing,無類別網路間路由)。}}<br />
<br />
詳情請參閱 {{ic|man ip}} 。<br />
<br />
以類似下列的方法加上您的 IP 位址:<br />
<br />
# ip route add default via ''預設閘道IP位址''<br />
<br />
舉例來說:<br />
<br />
# ip route add default via 192.168.1.1<br />
<br />
若您得到了 "No such process" 這樣的錯誤訊息,這代表您必須以 root 執行 {{ic|ip link set dev eth0 up}} 。<br />
<br />
==== 永久於啟動時通過 systemd 進行組態設定與 udev 規則 ====<br />
<br />
首先先為 [[systemd]] 服務建立一個組態設定檔,請以網路介面卡名稱取代下列的 {{ic|''interface''}}:<br />
<br />
{{hc|/etc/conf.d/network@''interface''|<nowiki><br />
address=192.168.0.15<br />
netmask=24<br />
broadcast=192.168.0.255<br />
gateway=192.168.0.1<br />
</nowiki>}}<br />
<br />
建立 systemd unit 檔案:<br />
<br />
{{hc|/etc/systemd/system/network@.service|<nowiki><br />
[Unit]<br />
Description=Network connectivity (%i)<br />
Wants=network.target<br />
Before=network.target<br />
BindsTo=sys-subsystem-net-devices-%i.device<br />
After=sys-subsystem-net-devices-%i.device<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
EnvironmentFile=/etc/conf.d/network@%i<br />
<br />
ExecStart=/usr/bin/ip link set dev %i up<br />
ExecStart=/usr/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i<br />
ExecStart=/usr/bin/sh -c 'test -n ${gateway} && /usr/bin/ip route add default via ${gateway}'<br />
<br />
ExecStop=/usr/bin/ip addr flush dev %i<br />
ExecStop=/usr/bin/ip link set dev %i down<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
啟用該 unit 並將其啟動,傳入介面名稱:<br />
<br />
# systemctl enable network@''介面名稱''.service<br />
# systemctl start network@''介面名稱''.service<br />
<br />
==== 計算位址 ====<br />
<br />
您可以使用 {{Pkg|ipcalc}} 提供的 {{ic|ipcalc}} 來計算 IP 廣播、網域、子網路遮罩與主機範圍等進階設定舉例來說,我使用了位於防火牆後的乙太網路來連線 Windows 機器至 Arch。為了安全性與網路組織,我將他們放置於各自獨立的網路,接著組態設定子網路遮罩與廣播位址,如此一來網路中就只有兩台機器。為了找出子網路遮罩跟廣播位址,我使用了 ipcalc ,提供其 Arch firewire nic 的 IP 位址 10.66.66.1 ,並指定 ipcalc 要建立一個只有兩台主機的網路。<br />
<br />
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|<nowiki><br />
Address: 10.66.66.1<br />
<br />
Netmask: 255.255.255.252 = 30<br />
Network: 10.66.66.0/30<br />
HostMin: 10.66.66.1<br />
HostMax: 10.66.66.2<br />
Broadcast: 10.66.66.3<br />
Hosts/Net: 2 Class A, Private Internet<br />
</nowiki>}}<br />
<br />
=== systemd-networkd ===<br />
<br />
若 [[systemd]] 的版本為 209 以上(含),則可使用 [[systemd-networkd]] 來管理網路,可輕鬆地代替在 Containers 與虛擬機中設定網路。並可同時管理動態與靜態 IP 位址。<br />
<br />
== 載入組態設定 ==<br />
<br />
要測試您的設定,您可以重新啟動電腦或是重新載入相關的 systemd 服務。然後嘗試 Ping 您的閘道器、DNS 伺服器、ISP 業者與其他的網際網路站台,用這樣的方式便能檢測哪裡出了問題,舉例來說:<br />
<br />
$ ping -c 3 www.google.com<br />
<br />
== 附加設定 ==<br />
<br />
=== 筆記型電腦之 ifplugd ===<br />
<br />
{{提示|[[dhcpcd]] 提供了開箱即用的相同功能。}}<br />
<br />
[[Official Repositories (正體中文)|官方軟體套件庫]]中的 {{Pkg|ifplugd}} 為一個當網路線插入後自動組態乙太設備;網路線拔除後自動取消組態的 Daemon 。<br />
這對於搭載內建網路介面卡的筆記型電腦特別有用,因為其只會在網路線真正連上後才會對介面進行組態。另一個會用到的情況為,當您需要重新啟動網路,但您並不想重開及或在 Shell 中進行設定。<br />
<br />
預設情況下,其會對 {{ic|eth0}} 裝置進行設定使其運作。這與其他設定類似延遲之類的設定能在 {{ic|/etc/ifplugd/ifplugd.conf}} 中進行設定。<br />
<br />
<br />
{{註記|[[Netctl]] 軟體包包含了 {{ic|netctl-ifplugd@.service}},否則您可以使用來自 {{Pkg|ifplugd}} 軟體包的 {{ic|ifplugd@.service}} 。例如這樣使用:{{ic|systemctl enable ifplugd@eth0.service}}。}}<br />
<br />
=== Bonding 或 LAG ===<br />
<br />
請參閱 [[netctl#Bonding]] 。<br />
<br />
=== IP 別名 ===<br />
<br />
{{Expansion|Manual method using [[Core utilities#ip|ip]] should be added; then move current example using ''netctl'' into [[netctl]].}}<br />
<br />
IP 別名為讓同一個網路介面有多個 IP 位址。如此一來,單個節點的網路就能有多個網路連線,進而實現不同的作用。經典的使用方法為網頁與 FTP 伺服器的虛擬主機,或是重組伺服器而無需更新任何其他的機器(對於名稱伺服器來說特別有用)。<br />
<br />
==== 範例 ====<br />
<br />
您將需要來自[[Official Repositories (正體中文)|官方軟體套件庫]]的 {{Pkg|netctl}} 。<br />
<br />
準備組態設定檔:<br />
<br />
{{hc|/etc/netctl/mynetwork|<nowiki><br />
Connection='ethernet'<br />
Description='Five different addresses on the same NIC.'<br />
Interface='eth0'<br />
IP='static'<br />
Address=('192.168.1.10' '192.168.178.11' '192.168.1.12' '192.168.1.13' '192.168.1.14' '192.168.1.15')<br />
Gateway='192.168.1.1'<br />
DNS=('192.168.1.1')<br />
</nowiki>}}<br />
<br />
接著只需要將其執行即可:<br />
<br />
$ netctl start mynetwork<br />
<br />
=== 更改 MAC/硬體 位址 ===<br />
<br />
請參閱 [[MAC Address Spoofing]] 。<br />
<br />
=== 網路共享 ===<br />
<br />
請參閱 [[Internet Sharing]] 。<br />
<br />
=== 路由組態設定 ===<br />
<br />
請參閱 [[Router]] 。<br />
<br />
=== 區域網路主機名稱解析 ===<br />
<br />
先決條件為[[#.E8.A8.AD.E5.AE.9A.E4.B8.BB.E6.A9.9F.E5.90.8D.E7.A8.B1|設定主機名稱]]之後,主機名稱可在本機系統上解析:<br />
{{hc|$ ping hostname|<br />
PING hostname <nowiki>(192.168.1.2) 56(84) bytes of data.<br />
64 bytes from hostname (192.168.1.2): icmp_seq=1 ttl=64 time=0.043 ms</nowiki>}}<br />
要以其他機器的名稱來解析主機,需要手動設定各自的 {{ic|/etc/hosts}} 檔案或是廣播/解析名稱的服務。<br />
<br />
過度設定 DNS 伺服器,如 [[BIND]] 、 [[Unbound]] ,手動編輯 {{ic|/etc/hosts}} 過於繁瑣,或是您希望對於動態地將主機離開、加入網路有更大的靈活性,您可以在您的區域網路中使用 Zero-configuration networking 來進行主機名稱解析。這裡有兩個可用選擇:<br />
<br />
*[[Samba]] 提供了通過微軟 '''NetBIOS''' 的主機名稱解析。其只需要安裝 {{Pkg|samba}} 並啟用 {{ic|nmbd.service}} 服務。執行 Windows 、OS X 或執行了 {{ic|nmbd}} 的 Linux ,將能夠找到您的機器。<br />
<br />
*[[Avahi]] 提供通過 '''zeroconf''' 的主機名稱解析,也稱作 Avahi 或 Boujour 。它比 Samba 還需要稍微複雜一點的設定:詳情請參考 [[Avahi#Hostname resolution]]。執行 OS X 或執行了 Avahi daemon 的 Linux ,將能夠找到您的機器。Windows 並無內建 Avahi 用戶端或 Daemon 。<br />
<br />
=== 雜亂模式 ===<br />
<br />
Toggling [https://en.wikipedia.org/wiki/Promiscuous_mode promiscuous mode] will make a (wireless) NIC forward all traffic it receives to the OS for further processing. This is opposite to "normal mode" where a NIC will drop frames it is not intended to receive. It is most often used for advanced network troubleshooting and [https://en.wikipedia.org/wiki/Packet_sniffing packet sniffing].<br />
<br />
{{hc|/etc/systemd/system/promiscuous@.service|<nowiki><br />
[Unit]<br />
Description=Set %i interface in promiscuous mode<br />
After=network.target<br />
<br />
[Service]<br />
Type=oneshot<br />
ExecStart=/usr/bin/ip link set dev %i promisc on<br />
RemainAfterExit=yes<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
若您想在介面卡 {{ic|eth0}} 中啟用雜亂模式,請執行:<br />
<br />
# systemctl enable promiscuous@eth0.service<br />
<br />
== 診斷 ==<br />
<br />
=== Swapping computers on the cable modem ===<br />
<br />
Some cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.<br />
<br />
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].<br />
<br />
=== The TCP window scaling problem ===<br />
<br />
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.<br />
<br />
Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html RFC 1323] was written to improve the situation: Window Scaling. The "window" value, provided in all packets, will be modified by a Scale Factor defined once, at the very beginning of the connection.<br />
<br />
That 8-bit Scale Factor allows the Window to be up to 32 times higher than the initial 64Kb.<br />
<br />
It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts.<br />
<br />
The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.<br />
<br />
The resulting connection is at best very slow or broken.<br />
<br />
==== How to diagnose the problem ====<br />
<br />
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).<br />
<br />
When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|ip addr}} will report normal status... and actually everything appears normal.<br />
<br />
If you cannot browse any website, but you can ping some random hosts, chances are great that you're experiencing this problem: ping uses ICMP and is not affected by TCP problems.<br />
<br />
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).<br />
<br />
==== How to fix it (The bad way) ====<br />
<br />
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.<br />
<br />
# echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem<br />
<br />
==== How to fix it (The good way) ====<br />
<br />
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.d/99-disable_window_scaling.conf}} (see also [[sysctl]])<br />
<br />
net.ipv4.tcp_window_scaling = 0<br />
<br />
==== How to fix it (The best way) ====<br />
<br />
This problem is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.<br />
<br />
==== More about it ====<br />
<br />
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].<br />
<br />
There are also several relevant threads on the LKML.<br />
<br />
=== Realtek no link / WOL problem ===<br />
<br />
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice a problem where the NIC seems to be disabled on boot and has no Link light. This can usually be found on a dual boot system where Windows is also installed. It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause. These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots. You will be able to notice if this problem is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off. Normal operation should be that the link light is always on as long as the system is on, even during POST. This problem will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this problem:<br />
<br />
==== Method 1 - Enable the NIC directly in Linux ====<br />
<br />
Get the ethernet NIC name from the output of<br />
<br />
$ ip a<br />
<br />
Bring up the device as root using the NIC name:<br />
<br />
# ip link set dev <NIC_name> up<br />
<br />
For ex, if <NIC_name> is enp7s0<br />
<br />
# ip link set dev enp7s0 up<br />
<br />
If it worked and the card is powered on, you should see {{ic|state UP}} for the given interface in the output of {{ic|ip link}}.<br />
<br />
==== Method 2 - Rollback/change Windows driver ====<br />
<br />
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).<br />
<br />
==== Method 3 - Enable WOL in Windows driver ====<br />
<br />
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems). In Windows, under Device Manager, find your Realtek network adapter and double-click it. Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.<br />
<br />
In Windows XP (example)<br />
Right click my computer<br />
--> Hardware tab<br />
--> Device Manager<br />
--> Network Adapters<br />
--> "double click" Realtek ...<br />
--> Advanced tab<br />
--> Wake-On-Lan After Shutdown<br />
--> Enable<br />
<br />
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{ic|Disable}} has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.}}<br />
<br />
==== Method 4 - Newer Realtek Linux driver ====<br />
<br />
Any newer driver for these Realtek cards can be found for Linux on the realtek site. (untested but believed to also solve the problem).<br />
<br />
==== Method 5 - Enable ''LAN Boot ROM'' in BIOS/CMOS ====<br />
<br />
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.<br />
<br />
{{Note|This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.}}<br />
<br />
=== No interface with Atheros chipsets ===<br />
<br />
Users of some Atheros ethernet chips are reporting it does not work out-of-the-box (with installation media of February 2014). The working solution for this is to install the package {{AUR|backports-patched}} from AUR.<br />
<br />
=== Broadcom BCM57780 ===<br />
<br />
This Broadcom chipset sometimes does not behave well unless you specify the order of the modules to be loaded. The modules are {{ic|broadcom}} and {{ic|tg3}}, the former needing to be loaded first.<br />
<br />
These steps should help if your computer has this chipset:<br />
$ lspci | grep Ethernet<br />
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)<br />
<br />
If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following (as root):<br />
# modprobe -r tg3<br />
# modprobe broadcom<br />
# modprobe tg3<br />
<br />
Now plug you network cable in. If this solves your problems you can make this permanent by adding {{ic|broadcom}} and {{ic|tg3}} (in this order) to the {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}}:<br />
<br />
MODULES=".. broadcom tg3 .."<br />
<br />
Then rebuild the initramfs:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|These methods may work for other chipsets, such as BCM57760.}}</div>Binotahttps://wiki.archlinux.org/index.php?title=Network_configuration_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=313049Network configuration (正體中文)2014-05-02T14:23:25Z<p>Binota: Updated to version 311601</p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:Networking (正體中文)]]<br />
[[Category:Getting and installing Arch (正體中文)]]<br />
[[cs:Configuring Network]]<br />
[[el:Configuring Network]]<br />
[[en:Configuring Network]]<br />
[[es:Configuring Network]]<br />
[[fr:Connexions reseau]]<br />
[[it:Configuring Network]]<br />
[[ja:Network Configuration]]<br />
[[nl:Configuring Network]]<br />
[[pt:Configuring Network]]<br />
[[ro:Configurare retea]]<br />
[[ru:Configuring Network]]<br />
[[sk:Configuring Network]]<br />
[[tr:Ağ_Yapılandırması]]<br />
[[zh-CN:Network Configuration]]<br />
{{Related articles start (正體中文)}}<br />
{{Related2|Jumbo Frames|巨型封包 (英)}}<br />
{{Related2|Firewalls|防火牆 (英)}}<br />
{{Related2|Wireless Setup|無線網路設定 (英)}}<br />
{{Related2|List of applications#Network managers|應用程式清單#網路管理員 (英)}}<br />
{{Related articles end}}<br />
{{TranslationStatus (正體中文)|Network_Configuration|2014-05-02|311601}}<br />
<br />
本頁將介紹如何設定'''有線'''網路連線。若您需要設定'''無線'''網路,請參考[[Wireless network configuration|無線網路設定]]。<br />
<br />
== 檢查連線 ==<br />
<br />
{{註記|若您在執行 ping 時收到了類似 {{ic|ping: icmp open socket: Operation not permitted}} 這樣的錯誤訊息,請嘗試重新安裝 {{ic|iputils}} 軟體包。}} <br />
<br />
一般來說,基本的安裝過程都已經建立了可運作的網路設定。請執行下列指令以進行檢查:<br />
<br />
{{註記|{{ic|-c 3}} 選項表示將會呼叫三次。詳細請參閱 {{ic|man ping}} 。}}<br />
{{提示|您也可以嘗試使用其他的 Domain ,如 www.hinet.net 。}}<br />
<br />
{{hc|$ ping -c 3 www.google.com|<nowiki><br />
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.<br />
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms<br />
64 bytes from 74.125.224.146: icmp_req=2 ttl=50 time=385 ms<br />
64 bytes from 74.125.224.146: icmp_req=3 ttl=50 time=298 ms<br />
<br />
--- www.l.google.com ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 1999ms<br />
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms<br />
</nowiki>}}<br />
<br />
如果沒問題的話,您可能只是想以本文的下列部分來自定您的設定。<br />
<br />
若剛才的指令出現了 unknown hosts 之類的訊息,代表您的機器無法解析網域。這可能是因為您的網路服務提供商/閘道造成的。您可以嘗試 ping 一個靜態 IP 以實驗您的機器能否存取網際網路。<br />
{{提示|您也可以嘗試使用其他的 IP ,如 168.95.1.1 。}}<br />
<br />
{{hc|$ ping -c 3 8.8.8.8|<nowiki><br />
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.<br />
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms<br />
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms<br />
64 bytes from 8.8.8.8: icmp_req=3 ttl=53 time=70.6 ms<br />
<br />
--- 8.8.8.8 ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 2002ms<br />
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms<br />
</nowiki>}}<br />
<br />
{{註記|{{ic|8.8.8.8}} 為一個好記的靜態 IP 位置。這是 Google 的主要 DNS 伺服器,這表示其有一定的可信度,並且通常不會被系統或代理伺服器擋下。}}<br />
<br />
若您可以 Ping 通 {{ic|8.8.8.8}} ,但 {{ic|www.google.com}} 不能,請檢查您的 DNS 組態設定檔。詳情請參考 [[resolv.conf]]。<br />
<br />
== 設定主機名稱 ==<br />
<br />
[[Wikipedia:Hostname|主機名稱]]為網路中用於識別機器的唯一識別名稱:主機名稱可以通過 {{ic|/etc/hostname}} 檔案來進行設定。一般來說該檔案包含了系統的網域名稱。下面為設定主機名稱的方法:<br />
<br />
# hostnamectl set-hostname '''myhostname'''<br />
<br />
這樣會將 {{ic|''myhostname''}} 寫入 {{ic|/etc/hostname}} 檔案中。<br />
<br />
詳細請參閱 {{ic|man 5 hostname}} 與 {{ic|man 1 hostnamectl}} 。<br />
<br />
在 {{ic|/etc/hosts}} 中加入相同的主機名稱:<br />
<br />
{{hc|/etc/hosts|<br />
<br />
#<ip-address> <hostname.domain.org> <hostname><br />
127.0.0.1 localhost.localdomain localhost ''myhostname''<br />
::1 localhost.localdomain localhost<br />
}}<br />
<br />
使用來自 {{Pkg|inetutils}} 的 ''hostname'' 以設定臨時主機名稱(直到重新啟動):<br />
<br />
# hostname ''myhostname''<br />
<br />
== 裝置驅動程式 ==<br />
<br />
=== 檢查驅動程式狀態 ===<br />
<br />
[[udev]] 應該會檢測您的網路介面卡([[Wikipedia:Network_interface_controller|NIC]])並自動於啟動時載入必要的模組。檢查 {{ic|lspci -v}} 輸出內容中的「Ethernet controller」 項目(或類似的)。這應該會告訴您哪些核心模組包含了網路設備的驅動程式。舉例來說:<br />
<br />
{{hc|$ lspci -v|<br />
02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)<br />
...<br />
Kernel driver in use: atl1<br />
Kernel modules: atl1<br />
}}<br />
<br />
接下來,確認該驅動程式已經通過 {{ic|dmesg <nowiki>|</nowiki> grep ''module_name''}} 載入了。舉例來說:<br />
<br />
$ dmesg | grep atl1<br />
...<br />
atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex<br />
<br />
若驅動程式已成功加載可以跳過接下來這段。否則,您會需要知道哪些模組時您的特定型號的裝置需要哪個模組。<br />
<br />
=== 載入裝置模組 ===<br />
<br />
以 Google 搜尋正確的晶片組模組/驅動程式。常見的驅動模組有 Realtek 晶片組網卡的 {{ic|8139too}} ,或是 SiS 晶片組網卡的 {{ic|sis900}}。當您知道要使用何種模組了之後,試著[[Kernel modules#Manual module handling|手動將其載入]]。若您得到了錯誤訊息告訴您找不到該模組,則該驅動可能未包含於 Arch 核心中。您可以在 [[AUR]] 中搜尋該模組名稱。<br />
<br />
若 udev 未在開機期間檢測與載入正確的模組,請參閱 [[Kernel modules#Loading]]。<br />
<br />
== 網路介面 ==<br />
<br />
=== 裝置名稱 ===<br />
<br />
對於多網路卡的電腦,固定裝置名稱非常重要。許多設定問題都是因為介面卡名稱的改動造成的。<br />
<br />
[[udev]] 負責命名裝置。Systemd v197 則有[http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames 可預測之網路介面名稱]並可自動支配靜態名稱給網路裝置。介面名稱以 {{ic|en}} (乙太網路)、 {{ic|wl}} (無線網路) 或是 {{ic|ww}} (WWAN)作為前置字串並附上一個自動產生的識別名稱,進而產生了類似 {{ic|enp0s25}} 這樣的名稱。 <br />
<br />
要禁用這種行為,可以將 {{ic|1=net.ifnames=0}} 到您的核心指令列。<br />
<br />
{{提示|您可以執行 {{ic|ip link}} 或是 {{ic|ls /sys/class/net}} 以列出所有可用的介面。}}<br />
<br />
{{註記|當您更改了介面名稱規則後,別忘了更新所有跟網路有關的組態檔案與自定的 systemd unit 檔案以因應該更改。特別是當您啟用了 [[netctl#Basic method|netctl 靜態設定檔]] ,請執行 {{ic|netctl reenable ''profile''}} 以更新所有產生的服務檔案。}}<br />
<br />
==== 更改裝置名稱 ====<br />
<br />
您可以使用 udev-rule 來手動定義裝置名稱。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"<br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"<br />
</nowiki>}}<br />
<br />
請注意這兩點:<br />
<br />
* 使用這個指令以取得 MAC 位置:{{ic|cat /sys/class/net/''device_name''/address}}。<br />
* 請確定 udev 規則中使用的是小寫的十六進位數值而不是大寫。<br />
<br />
若該網路卡為動態 MAC ,您可以使用 DEVPATH ,例如:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"<br />
</nowiki>}}<br />
<br />
{{註記|當使用了靜態的名稱時,'''應該要避免使用類似 "eth''X''" 與 "wlan''X''"''' 這樣的名稱,因為這可能會導致核心與 udev 在開機時發生衝突。而剛好相反地,最好使用核心預設不會使用的介面名稱,如 {{ic|net0}} 、 {{ic|net1}} 、 {{ic|wifi0}} 、 {{ic|wifi1}} 。詳細說明請參閱 [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames systemd] 文件。}}<br />
<br />
=== 設定裝置的 MTU 與佇列長度 ===<br />
<br />
您可以手動定義 udev 規則來更改裝置的 MTU 與佇列長度。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1480", ATTR{tx_queue_len}="2000"<br />
</nowiki>}}<br />
<br />
=== 取得目前的裝置名稱 ===<br />
<br />
目前的 NIC 名稱可以通過 sysfs 找到<br />
<br />
{{hc|$ ls /sys/class/net|<br />
lo eth0 eth1 firewire0<br />
}}<br />
<br />
=== 啟用與禁用網路介面 ===<br />
<br />
您可以使用下列指令來啟用或禁用網路介面:<br />
<br />
# ip link set eth0 up<br />
# ip link set eth0 down<br />
<br />
要確認結果,請執行:<br />
<br />
{{hc|$ ip link show dev eth0|<br />
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000<br />
...<br />
}}<br />
<br />
== 組態設定 IP 位址 ==<br />
<br />
您有兩個選擇:使用 [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]] 指派動態位址,或是使用「靜態」的位址。<br />
<br />
=== 動態 IP 位址 ===<br />
<br />
==== dhcpcd ====<br />
<br />
最簡單的方式就是使用 [[dhcpcd]],它包含在 {{Grp|base}} 群組中。無論是使用提供服務檔案 {{ic|dhcpcd@.service}} ,以參數方式傳入介面卡名稱,或是手動通過 {{ic|dhcpcd ''interface''}} 將其執行。<br />
<br />
=== 靜態 IP 位址 ===<br />
<br />
您可能因為各種原因而希望在您的網路中指派靜態 IP 位址,例如靜態的位址可以獲得一定程度的可預測性,或是您沒有可用的 DHCP 伺服器。<br />
<br />
{{註記|若您通過 Windows 機器來共享您的網路而不是使用路由器,請確保兩台電腦皆使用了靜態 IP 位址以避免區域網路問題。}}<br />
<br />
您需要:<br />
<br />
* 靜態 IP 位址<br />
* [[Wikipedia:Subnetwork|子網路遮罩]]<br />
* [[Wikipedia:Broadcast_address|廣播位址]]<br />
* [[Wikipedia:Default_gateway|預設閘道器]]的 IP 位址<br />
<br />
若您處在內部網路中,使用 192.168.*.* 這樣的 IP 位址較為安全,搭配其的子網路遮罩 255.255.255.0 ,廣播位址為 192.168.*.255 。而閘道通常是 192.168.*.1 或是 192.168.*.254 。<br />
<br />
{{Tip|You may need to manually set the DNS servers, see [[resolv.conf]] for details.}}<br />
<br />
==== 手動指派 ====<br />
<br />
您可於控制台中指派一靜態 IP 位址:<br />
<br />
# ip addr add ''IP位址''/''子網路遮罩'' broadcast ''廣播'' dev ''介面''<br />
<br />
舉例來說:<br />
<br />
# ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev eth0<br />
<br />
{{註記|子網路遮罩使用了 [[Wikipedia:CIDR_notation|CIDR 表示法]](CIDR,Classless Inter-Domain Routing,無類別網路間路由)。}}<br />
<br />
詳情請參閱 {{ic|man ip}} 。<br />
<br />
以類似下列的方法加上您的 IP 位址:<br />
<br />
# ip route add default via ''預設閘道IP位址''<br />
<br />
舉例來說:<br />
<br />
# ip route add default via 192.168.1.1<br />
<br />
若您得到了 "No such process" 這樣的錯誤訊息,這代表您必須以 root 執行 {{ic|ip link set dev eth0 up}} 。<br />
<br />
==== 永久於啟動時通過 systemd 進行組態設定與 udev 規則 ====<br />
<br />
首先先為 [[systemd]] 服務建立一個組態設定檔,請以網路介面卡名稱取代下列的 {{ic|''interface''}}:<br />
<br />
{{hc|/etc/conf.d/network@''interface''|<nowiki><br />
address=192.168.0.15<br />
netmask=24<br />
broadcast=192.168.0.255<br />
gateway=192.168.0.1<br />
</nowiki>}}<br />
<br />
建立 systemd unit 檔案:<br />
<br />
{{hc|/etc/systemd/system/network@.service|<nowiki><br />
[Unit]<br />
Description=Network connectivity (%i)<br />
Wants=network.target<br />
Before=network.target<br />
BindsTo=sys-subsystem-net-devices-%i.device<br />
After=sys-subsystem-net-devices-%i.device<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
EnvironmentFile=/etc/conf.d/network@%i<br />
<br />
ExecStart=/usr/bin/ip link set dev %i up<br />
ExecStart=/usr/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i<br />
ExecStart=/usr/bin/sh -c 'test -n ${gateway} && /usr/bin/ip route add default via ${gateway}'<br />
<br />
ExecStop=/usr/bin/ip addr flush dev %i<br />
ExecStop=/usr/bin/ip link set dev %i down<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
啟用該 unit 並將其啟動,傳入介面名稱:<br />
<br />
# systemctl enable network@''介面名稱''.service<br />
# systemctl start network@''介面名稱''.service<br />
<br />
==== 計算位址 ====<br />
<br />
您可以使用 {{Pkg|ipcalc}} 提供的 {{ic|ipcalc}} 來計算 IP 廣播、網域、子網路遮罩與主機範圍等進階設定舉例來說,我使用了位於防火牆後的乙太網路來連線 Windows 機器至 Arch。為了安全性與網路組織,我將他們放置於各自獨立的網路,接著組態設定子網路遮罩與廣播位址,如此一來網路中就只有兩台機器。為了找出子網路遮罩跟廣播位址,我使用了 ipcalc ,提供其 Arch firewire nic 的 IP 位址 10.66.66.1 ,並指定 ipcalc 要建立一個只有兩台主機的網路。<br />
<br />
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|<nowiki><br />
Address: 10.66.66.1<br />
<br />
Netmask: 255.255.255.252 = 30<br />
Network: 10.66.66.0/30<br />
HostMin: 10.66.66.1<br />
HostMax: 10.66.66.2<br />
Broadcast: 10.66.66.3<br />
Hosts/Net: 2 Class A, Private Internet<br />
</nowiki>}}<br />
<br />
=== systemd-networkd ===<br />
<br />
With [[systemd]] version >= 209, it is possible to manage network connections with [[systemd-networkd]], which is intended to easily set up network on containers and virtual machines. It can manage both dynamic and static IP addresses.<br />
<br />
== 載入組態設定 ==<br />
<br />
要測試您的設定,您可以重新啟動電腦或是重新載入相關的 systemd 服務。然後嘗試 Ping 您的閘道器、DNS 伺服器、ISP 業者與其他的網際網路站台,用這樣的方式便能檢測哪裡出了問題,舉例來說:<br />
<br />
$ ping -c 3 www.google.com<br />
<br />
== 附加設定 ==<br />
<br />
=== 筆記型電腦之 ifplugd ===<br />
<br />
{{提示|[[dhcpcd]] 提供了開箱即用的相同功能。}}<br />
<br />
[[Official Repositories (正體中文)|官方軟體套件庫]]中的 {{Pkg|ifplugd}} 為一個當網路線插入後自動組態乙太設備;網路線拔除後自動取消組態的 Daemon 。<br />
這對於搭載內建網路介面卡的筆記型電腦特別有用,因為其只會在網路線真正連上後才會對介面進行組態。另一個會用到的情況為,當您需要重新啟動網路,但您並不想重開及或在 Shell 中進行設定。<br />
<br />
預設情況下,其會對 {{ic|eth0}} 裝置進行設定使其運作。這與其他設定類似延遲之類的設定能在 {{ic|/etc/ifplugd/ifplugd.conf}} 中進行設定。<br />
<br />
<br />
{{註記|[[Netctl]] 軟體包包含了 {{ic|netctl-ifplugd@.service}},否則您可以使用來自 {{Pkg|ifplugd}} 軟體包的 {{ic|ifplugd@.service}} 。例如這樣使用:{{ic|systemctl enable ifplugd@eth0.service}}。}}<br />
<br />
=== Bonding 或 LAG ===<br />
<br />
請參閱 [[netctl#Bonding]] 。<br />
<br />
=== IP 別名 ===<br />
<br />
{{Expansion|Manual method using [[Core utilities#ip|ip]] should be added; then move current example using ''netctl'' into [[netctl]].}}<br />
<br />
IP 別名為讓同一個網路介面有多個 IP 位址。如此一來,單個節點的網路就能有多個網路連線,進而實現不同的作用。經典的使用方法為網頁與 FTP 伺服器的虛擬主機,或是重組伺服器而無需更新任何其他的機器(對於名稱伺服器來說特別有用)。<br />
<br />
==== 範例 ====<br />
<br />
您將需要來自[[Official Repositories (正體中文)|官方軟體套件庫]]的 {{Pkg|netctl}} 。<br />
<br />
準備組態設定檔:<br />
<br />
{{hc|/etc/netctl/mynetwork|<nowiki><br />
Connection='ethernet'<br />
Description='Five different addresses on the same NIC.'<br />
Interface='eth0'<br />
IP='static'<br />
Address=('192.168.1.10' '192.168.178.11' '192.168.1.12' '192.168.1.13' '192.168.1.14' '192.168.1.15')<br />
Gateway='192.168.1.1'<br />
DNS=('192.168.1.1')<br />
</nowiki>}}<br />
<br />
接著只需要將其執行即可:<br />
<br />
$ netctl start mynetwork<br />
<br />
=== 更改 MAC/硬體 位址 ===<br />
<br />
請參閱 [[MAC Address Spoofing]] 。<br />
<br />
=== 網路共享 ===<br />
<br />
請參閱 [[Internet Sharing]] 。<br />
<br />
=== 路由組態設定 ===<br />
<br />
請參閱 [[Router]] 。<br />
<br />
=== 區域網路主機名稱解析 ===<br />
<br />
先決條件為[[#.E8.A8.AD.E5.AE.9A.E4.B8.BB.E6.A9.9F.E5.90.8D.E7.A8.B1|設定主機名稱]]之後,主機名稱可在本機系統上解析:<br />
{{hc|$ ping hostname|<br />
PING hostname <nowiki>(192.168.1.2) 56(84) bytes of data.<br />
64 bytes from hostname (192.168.1.2): icmp_seq=1 ttl=64 time=0.043 ms</nowiki>}}<br />
要以其他機器的名稱來解析主機,需要手動設定各自的 {{ic|/etc/hosts}} 檔案或是廣播/解析名稱的服務。<br />
<br />
過度設定 DNS 伺服器,如 [[BIND]] 、 [[Unbound]] ,手動編輯 {{ic|/etc/hosts}} 過於繁瑣,或是您希望對於動態地將主機離開、加入網路有更大的靈活性,您可以在您的區域網路中使用 Zero-configuration networking 來進行主機名稱解析。這裡有兩個可用選擇:<br />
<br />
*[[Samba]] 提供了通過微軟 '''NetBIOS''' 的主機名稱解析。其只需要安裝 {{Pkg|samba}} 並啟用 {{ic|nmbd.service}} 服務。執行 Windows 、OS X 或執行了 {{ic|nmbd}} 的 Linux ,將能夠找到您的機器。<br />
<br />
*[[Avahi]] 提供通過 '''zeroconf''' 的主機名稱解析,也稱作 Avahi 或 Boujour 。它比 Samba 還需要稍微複雜一點的設定:詳情請參考 [[Avahi#Hostname resolution]]。執行 OS X 或執行了 Avahi daemon 的 Linux ,將能夠找到您的機器。Windows 並無內建 Avahi 用戶端或 Daemon 。<br />
<br />
=== Promiscuous mode ===<br />
<br />
Toggling [https://en.wikipedia.org/wiki/Promiscuous_mode promiscuous mode] will make a (wireless) NIC forward all traffic it receives to the OS for further processing. This is opposite to "normal mode" where a NIC will drop frames it is not intended to receive. It is most often used for advanced network troubleshooting and [https://en.wikipedia.org/wiki/Packet_sniffing packet sniffing].<br />
<br />
{{hc|/etc/systemd/system/promiscuous@.service|<nowiki><br />
[Unit]<br />
Description=Set %i interface in promiscuous mode<br />
After=network.target<br />
<br />
[Service]<br />
Type=oneshot<br />
ExecStart=/usr/bin/ip link set dev %i promisc on<br />
RemainAfterExit=yes<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
If you want to enable promiscuous mode on interface {{ic|eth0}} run:<br />
<br />
# systemctl enable promiscuous@eth0.service<br />
<br />
== 診斷 ==<br />
<br />
=== Swapping computers on the cable modem ===<br />
<br />
Some cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.<br />
<br />
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].<br />
<br />
=== The TCP window scaling problem ===<br />
<br />
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.<br />
<br />
Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html RFC 1323] was written to improve the situation: Window Scaling. The "window" value, provided in all packets, will be modified by a Scale Factor defined once, at the very beginning of the connection.<br />
<br />
That 8-bit Scale Factor allows the Window to be up to 32 times higher than the initial 64Kb.<br />
<br />
It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts.<br />
<br />
The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.<br />
<br />
The resulting connection is at best very slow or broken.<br />
<br />
==== How to diagnose the problem ====<br />
<br />
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).<br />
<br />
When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|ip addr}} will report normal status... and actually everything appears normal.<br />
<br />
If you cannot browse any website, but you can ping some random hosts, chances are great that you're experiencing this problem: ping uses ICMP and is not affected by TCP problems.<br />
<br />
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).<br />
<br />
==== How to fix it (The bad way) ====<br />
<br />
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.<br />
<br />
# echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem<br />
<br />
==== How to fix it (The good way) ====<br />
<br />
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.d/99-disable_window_scaling.conf}} (see also [[sysctl]])<br />
<br />
net.ipv4.tcp_window_scaling = 0<br />
<br />
==== How to fix it (The best way) ====<br />
<br />
This problem is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.<br />
<br />
==== More about it ====<br />
<br />
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].<br />
<br />
There are also several relevant threads on the LKML.<br />
<br />
=== Realtek no link / WOL problem ===<br />
<br />
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice a problem where the NIC seems to be disabled on boot and has no Link light. This can usually be found on a dual boot system where Windows is also installed. It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause. These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots. You will be able to notice if this problem is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off. Normal operation should be that the link light is always on as long as the system is on, even during POST. This problem will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this problem:<br />
<br />
==== Method 1 - Enable the NIC directly in Linux ====<br />
<br />
Get the ethernet NIC name from the output of<br />
<br />
$ ip a<br />
<br />
Bring up the device as root using the NIC name:<br />
<br />
# ip link set dev <NIC_name> up<br />
<br />
For ex, if <NIC_name> is enp7s0<br />
<br />
# ip link set dev enp7s0 up<br />
<br />
If it worked and the card is powered on, you should see {{ic|state UP}} for the given interface in the output of {{ic|ip link}}.<br />
<br />
==== Method 2 - Rollback/change Windows driver ====<br />
<br />
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).<br />
<br />
==== Method 3 - Enable WOL in Windows driver ====<br />
<br />
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems). In Windows, under Device Manager, find your Realtek network adapter and double-click it. Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.<br />
<br />
In Windows XP (example)<br />
Right click my computer<br />
--> Hardware tab<br />
--> Device Manager<br />
--> Network Adapters<br />
--> "double click" Realtek ...<br />
--> Advanced tab<br />
--> Wake-On-Lan After Shutdown<br />
--> Enable<br />
<br />
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{ic|Disable}} has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.}}<br />
<br />
==== Method 4 - Newer Realtek Linux driver ====<br />
<br />
Any newer driver for these Realtek cards can be found for Linux on the realtek site. (untested but believed to also solve the problem).<br />
<br />
==== Method 5 - Enable ''LAN Boot ROM'' in BIOS/CMOS ====<br />
<br />
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.<br />
<br />
{{Note|This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.}}<br />
<br />
=== No interface with Atheros chipsets ===<br />
<br />
Users of some Atheros ethernet chips are reporting it does not work out-of-the-box (with installation media of February 2014). The working solution for this is to install the package {{AUR|backports-patched}} from AUR.<br />
<br />
=== Broadcom BCM57780 ===<br />
<br />
This Broadcom chipset sometimes does not behave well unless you specify the order of the modules to be loaded. The modules are {{ic|broadcom}} and {{ic|tg3}}, the former needing to be loaded first.<br />
<br />
These steps should help if your computer has this chipset:<br />
$ lspci | grep Ethernet<br />
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)<br />
<br />
If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following (as root):<br />
# modprobe -r tg3<br />
# modprobe broadcom<br />
# modprobe tg3<br />
<br />
Now plug you network cable in. If this solves your problems you can make this permanent by adding {{ic|broadcom}} and {{ic|tg3}} (in this order) to the {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}}:<br />
<br />
MODULES=".. broadcom tg3 .."<br />
<br />
Then rebuild the initramfs:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|These methods may work for other chipsets, such as BCM57760.}}</div>Binotahttps://wiki.archlinux.org/index.php?title=User:Binota&diff=313042User:Binota2014-05-02T14:07:40Z<p>Binota: </p>
<hr />
<div>Hi there~<br />
<br />
I'm a new member of Arch Linux,<br />
<br />
also a new member of Linux:P<br />
<br />
translate is my hobby,<br />
<br />
that I'm help this wiki to translate some page to Chinese Traditional.<br />
<br />
If you want to know me more,<br />
<br />
you can contact me via e-mail~<br />
<br />
<br />
My E-Mail: binota【!!AT!!】gmx【!!DOT!!】com</div>Binotahttps://wiki.archlinux.org/index.php?title=Network_configuration_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=298929Network configuration (正體中文)2014-02-19T14:00:35Z<p>Binota: /* 載入組態設定 */ Translated</p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:Networking (正體中文)]]<br />
[[Category:Getting and installing Arch (正體中文)]]<br />
[[cs:Configuring Network]]<br />
[[el:Configuring Network]]<br />
[[en:Configuring Network]]<br />
[[es:Configuring Network]]<br />
[[fr:Connexions reseau]]<br />
[[it:Configuring Network]]<br />
[[ja:Network Configuration]]<br />
[[nl:Configuring Network]]<br />
[[pt:Configuring Network]]<br />
[[ro:Configurare retea]]<br />
[[ru:Configuring Network]]<br />
[[sk:Configuring Network]]<br />
[[tr:Ağ_Yapılandırması]]<br />
[[zh-CN:Network Configuration]]<br />
{{Related articles start (正體中文)}}<br />
{{Related2|Jumbo Frames|巨型封包 (英)}}<br />
{{Related2|Firewalls|防火牆 (英)}}<br />
{{Related2|Wireless Setup|無線網路設定 (英)}}<br />
{{Related2|List of Applications#Network Managers|應用程式清單#網路管理員 (英)}}<br />
{{Related articles end}}<br />
{{TranslationStatus (正體中文)|Network_Configuration|2014-02-20|298590}}<br />
<br />
本頁將介紹如何設定'''有線'''網路連線。若您需要設定'''無線'''網路,請參考[[Wireless network configuration|無線網路設定]]。<br />
<br />
== 檢查連線 ==<br />
<br />
{{註記|若您在執行 ping 時收到了類似 {{ic|ping: icmp open socket: Operation not permitted}} 這樣的錯誤訊息,請嘗試重新安裝 {{ic|iputils}} 軟體包。}} <br />
<br />
一般來說,基本的安裝過程都已經建立了可運作的網路設定。請執行下列指令以進行檢查:<br />
<br />
{{註記|{{ic|-c 3}} 選項表示將會呼叫三次。詳細請參閱 {{ic|man ping}} 。}}<br />
{{提示|您也可以嘗試使用其他的 Domain ,如 www.hinet.net 。}}<br />
<br />
{{hc|$ ping -c 3 www.google.com|<nowiki><br />
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.<br />
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms<br />
64 bytes from 74.125.224.146: icmp_req=2 ttl=50 time=385 ms<br />
64 bytes from 74.125.224.146: icmp_req=3 ttl=50 time=298 ms<br />
<br />
--- www.l.google.com ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 1999ms<br />
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms<br />
</nowiki>}}<br />
<br />
如果沒問題的話,您可能只是想以本文的下列部分來自定您的設定。<br />
<br />
若剛才的指令出現了 unknown hosts 之類的訊息,代表您的機器無法解析網域。這可能是因為您的網路服務提供商/閘道造成的。您可以嘗試 ping 一個靜態 IP 以實驗您的機器能否存取網際網路。<br />
{{提示|您也可以嘗試使用其他的 IP ,如 168.95.1.1 。}}<br />
<br />
{{hc|$ ping -c 3 8.8.8.8|<nowiki><br />
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.<br />
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms<br />
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms<br />
64 bytes from 8.8.8.8: icmp_req=3 ttl=53 time=70.6 ms<br />
<br />
--- 8.8.8.8 ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 2002ms<br />
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms<br />
</nowiki>}}<br />
<br />
{{註記|{{ic|8.8.8.8}} 為一個好記的靜態 IP 位置。這是 Google 的主要 DNS 伺服器,這表示其有一定的可信度,並且通常不會被系統或代理伺服器擋下。}}<br />
<br />
若您可以 Ping 通 {{ic|8.8.8.8}} ,但 {{ic|www.google.com}} 不能,請檢查您的 DNS 組態設定檔。詳情請參考 [[resolv.conf]]。<br />
<br />
== 設定主機名稱 ==<br />
<br />
[[Wikipedia:Hostname|主機名稱]]為網路中用於識別機器的唯一識別名稱:主機名稱可以通過 {{ic|/etc/hostname}} 檔案來進行設定。一般來說該檔案包含了系統的網域名稱。下面為設定主機名稱的方法:<br />
<br />
# hostnamectl set-hostname '''myhostname'''<br />
<br />
這樣會將 {{ic|''myhostname''}} 寫入 {{ic|/etc/hostname}} 檔案中。<br />
<br />
詳細請參閱 {{ic|man 5 hostname}} 與 {{ic|man 1 hostnamectl}} 。<br />
<br />
{{註記|<br />
* {{ic|hostnamectl}} 支援 FQDN<br />
* 您不需要編輯 {{ic|/etc/hosts}} 檔案,{{pkg|systemd}} 會提供主機名稱解析且預設安裝於所有系統。<br />
}}<br />
<br />
使用來自 {{Pkg|inetutils}} 的 ''hostname'' 以設定臨時主機名稱(直到重新啟動):<br />
<br />
# hostname ''myhostname''<br />
<br />
== 裝置驅動程式 ==<br />
<br />
=== 檢查驅動程式狀態 ===<br />
<br />
[[udev]] 應該會檢測您的網路介面卡([[Wikipedia:Network_interface_controller|NIC]])並自動於啟動時載入必要的模組。檢查 {{ic|lspci -v}} 輸出內容中的「Ethernet controller」 項目(或類似的)。這應該會告訴您哪些核心模組包含了網路設備的驅動程式。舉例來說:<br />
<br />
{{hc|$ lspci -v|<br />
02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)<br />
...<br />
Kernel driver in use: atl1<br />
Kernel modules: atl1<br />
}}<br />
<br />
接下來,確認該驅動程式已經通過 {{ic|dmesg <nowiki>|</nowiki> grep ''module_name''}} 載入了。舉例來說:<br />
<br />
$ dmesg | grep atl1<br />
...<br />
atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex<br />
<br />
若驅動程式已成功加載可以跳過接下來這段。否則,您會需要知道哪些模組時您的特定型號的裝置需要哪個模組。<br />
<br />
=== 載入裝置模組 ===<br />
<br />
以 Google 搜尋正確的晶片組模組/驅動程式。常見的驅動模組有 Realtek 晶片組網卡的 {{ic|8139too}} ,或是 SiS 晶片組網卡的 {{ic|sis900}}。當您知道要使用何種模組了之後,試著[[Kernel modules#Manual module handling|手動將其載入]]。若您得到了錯誤訊息告訴您找不到該模組,則該驅動可能未包含於 Arch 核心中。您可以在 [[AUR]] 中搜尋該模組名稱。<br />
<br />
若 udev 未在開機期間檢測與載入正確的模組,請參閱 [[Kernel modules#Loading]]。<br />
<br />
== 網路介面 ==<br />
<br />
=== 裝置名稱 ===<br />
<br />
對於多網路卡的電腦,固定裝置名稱非常重要。許多設定問題都是因為介面卡名稱的改動造成的。<br />
<br />
[[udev]] 負責命名裝置。Systemd v197 則有[http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames 可預測之網路介面名稱]並可自動支配靜態名稱給網路裝置。介面名稱以 {{ic|en}} (乙太網路)、 {{ic|wl}} (無線網路) 或是 {{ic|ww}} (WWAN)作為前置字串並附上一個自動產生的識別名稱,進而產生了類似 {{ic|enp0s25}} 這樣的名稱。 <br />
<br />
要禁用這種行為,可以加上一個連接:<br />
<br />
# ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules<br />
<br />
自早期版本升級 systemd 的使用者會有一自動建立的空規則檔案。因此,若您想使用一貫的裝置名稱,只需要刪除該檔案。<br />
<br />
{{提示|您可以執行 {{ic|ip link}} 或是 {{ic|ls /sys/class/net}} 以列出所有可用的介面。}}<br />
<br />
{{註記|當您更改了介面名稱規則後,別忘了更新所有跟網路有關的組態檔案與自定的 systemd unit 檔案以因應該更改。特別是當您啟用了 [[netctl#Basic method|netctl 靜態設定檔]] ,請執行 {{ic|netctl reenable ''profile''}} 以更新所有產生的服務檔案。}}<br />
<br />
==== 更改裝置名稱 ====<br />
<br />
您可以使用 udev-rule 來手動定義裝置名稱。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"<br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"<br />
</nowiki>}}<br />
<br />
請注意這兩點:<br />
<br />
* 使用這個指令以取得 MAC 位置:{{ic|cat /sys/class/net/''device_name''/address}}。<br />
* 請確定 udev 規則中使用的是小寫的十六進位數值而不是大寫。<br />
<br />
若您的網路卡為動態 MAC ,您可以使用 DEVPATH ,例如:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"<br />
</nowiki>}}<br />
<br />
{{註記|當使用了靜態的名稱時,'''應該要避免使用類似 "eth''X''" 與 "wlan''X''"''' 這樣的名稱,因為這可能會導致核心與 udev 在開機時發生衝突。而剛好相反地,最好使用核心預設不會使用的介面名稱,如 {{ic|net0}} 、 {{ic|net1}} 、 {{ic|wifi0}} 、 {{ic|wifi1}} 。詳細說明請參閱 [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames systemd] 文件。}}<br />
<br />
=== 設定裝置的 MTU 與佇列長度 ===<br />
<br />
您可以手動定義 udev 規則來更改裝置的 MTU 與佇列長度。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1480", ATTR{tx_queue_len}="2000"<br />
</nowiki>}}<br />
<br />
=== 取得目前的裝置名稱 ===<br />
<br />
目前的 NIC 名稱可以通過 sysfs 找到<br />
<br />
{{hc|$ ls /sys/class/net|<br />
lo eth0 eth1 firewire0<br />
}}<br />
<br />
=== 啟用與禁用網路介面 ===<br />
<br />
您可以使用下列指令來啟用或禁用網路介面:<br />
<br />
# ip link set eth0 up<br />
# ip link set eth0 down<br />
<br />
要確認結果,請執行:<br />
<br />
{{hc|$ ip link show dev eth0|<br />
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000<br />
...<br />
}}<br />
<br />
== 組態設定 IP 位址 ==<br />
<br />
您有兩個選擇:使用 [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]] 指派動態位址,或是使用「靜態」的位址。<br />
<br />
=== 動態 IP 位址 ===<br />
<br />
最簡單的方式就是使用 [[dhcpcd]],它包含在 {{Grp|base}} 群組中。無論是使用提供服務檔案 {{ic|dhcpcd@.service}} ,以參數方式傳入介面卡名稱,或是手動通過 {{ic|dhcpcd ''interface''}} 將其執行。<br />
<br />
=== 靜態 IP 位址 ===<br />
<br />
您可能因為各種原因而希望在您的網路中指派靜態 IP 位址,例如靜態的位址可以獲得一定程度的可預測性,或是您沒有可用的 DHCP 伺服器。<br />
<br />
{{註記|若您通過 Windows 機器來共享您的網路而不是使用路由器,請確保兩台電腦皆使用了靜態 IP 位址以避免區域網路問題。}}<br />
<br />
您需要:<br />
<br />
* 靜態 IP 位址<br />
* [[Wikipedia:Subnetwork|子網路遮罩]]<br />
* [[Wikipedia:Broadcast_address|廣播位址]]<br />
* [[Wikipedia:Default_gateway|預設閘道器]]的 IP 位址<br />
<br />
若您處在內部網路中,使用 192.168.*.* 這樣的 IP 位址較為安全,搭配其的子網路遮罩 255.255.255.0 ,廣播位址為 192.168.*.255 。而閘道通常是 192.168.*.1 或是 192.168.*.254 。<br />
<br />
{{Tip|You may need to manually set the DNS servers, see [[resolv.conf]] for details.}}<br />
<br />
==== 手動指派 ====<br />
<br />
您可於控制台中指派一靜態 IP 位址:<br />
<br />
# ip addr add <IP 位址>/<子網路遮罩> broadcast <廣播> dev <介面><br />
<br />
舉例來說:<br />
<br />
# ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev eth0<br />
<br />
{{註記|子網路遮罩使用了 [[Wikipedia:CIDR_notation|CIDR 表示法]](CIDR,Classless Inter-Domain Routing,無類別網路間路由)。}}<br />
<br />
詳情請參閱 {{ic|man ip}} 。<br />
<br />
以類似下列方法加上您的閘道:<br />
<br />
# ip route add default via <預設閘道 IP 位址><br />
<br />
舉例來說:<br />
<br />
# ip route add default via 192.168.1.1<br />
<br />
若您得到了 "No such process" 這樣的錯誤訊息,這代表您必須以 root 執行 {{ic|ip link set dev eth0 up}} 。<br />
<br />
==== 於啟動時通過 systemd 手動連線 ====<br />
<br />
首先先為 [[systemd]] 服務建立一個組態設定檔,請以網路介面卡名稱取代下列的 {{ic|<interface>}}:<br />
<br />
{{hc|/etc/conf.d/network@<interface>|<nowiki><br />
address=192.168.0.15<br />
netmask=24<br />
broadcast=192.168.0.255<br />
gateway=192.168.0.1<br />
</nowiki>}}<br />
<br />
建立 systemd unit 檔案:<br />
<br />
{{hc|/etc/systemd/system/network@.service|<nowiki><br />
[Unit]<br />
Description=Network connectivity (%i)<br />
Wants=network.target<br />
Before=network.target<br />
BindsTo=sys-subsystem-net-devices-%i.device<br />
After=sys-subsystem-net-devices-%i.device<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
EnvironmentFile=/etc/conf.d/network@%i<br />
<br />
ExecStart=/usr/bin/ip link set dev %i up<br />
ExecStart=/usr/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i<br />
ExecStart=/usr/bin/ip route add default via ${gateway}<br />
<br />
ExecStop=/usr/bin/ip addr flush dev %i<br />
ExecStop=/usr/bin/ip link set dev %i down<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
啟用該 unit 並將其啟動,傳入介面名稱:<br />
<br />
# systemctl enable network@''介面名稱''.service<br />
# systemctl start network@''介面名稱''.service<br />
<br />
==== 計算位址 ====<br />
<br />
您可以使用 {{Pkg|ipcalc}} 提供的 {{ic|ipcalc}} 來計算 IP 廣播、網域、子網路遮罩與主機範圍等進階設定舉例來說,我使用了位於防火牆後的乙太網路來連線 Windows 機器至 Arch。為了安全性與網路組織,我將他們放置於各自獨立的網路,接著組態設定子網路遮罩與廣播位址,如此一來網路中就只有兩台機器。為了找出子網路遮罩跟廣播位址,我使用了 ipcalc ,提供其 Arch firewire nic 的 IP 位址 10.66.66.1 ,並指定 ipcalc 要建立一個只有兩台主機的網路。<br />
<br />
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|<nowiki><br />
Address: 10.66.66.1<br />
<br />
Netmask: 255.255.255.252 = 30<br />
Network: 10.66.66.0/30<br />
HostMin: 10.66.66.1<br />
HostMax: 10.66.66.2<br />
Broadcast: 10.66.66.3<br />
Hosts/Net: 2 Class A, Private Internet<br />
</nowiki>}}<br />
<br />
== 載入組態設定 ==<br />
<br />
要測試您的設定,您可以重新啟動電腦或是重新載入相關的 systemd 服務。然後嘗試 Ping 您的閘道器、DNS 伺服器、ISP 業者與其他的網際網路站台,用這樣的方式便能檢測哪裡出了問題,舉例來說:<br />
<br />
$ ping -c 3 www.google.com<br />
<br />
== 附加設定 ==<br />
<br />
=== 筆記型電腦之 ifplugd ===<br />
<br />
{{提示|[[dhcpcd]] 提供了開箱即用的相同功能。}}<br />
<br />
[[Official Repositories (正體中文)|官方軟體套件庫]]中的 {{Pkg|ifplugd}} 為一個當網路線插入後自動組態乙太設備;網路線拔除後自動取消組態的 Daemon 。<br />
這對於搭載內建網路介面卡的筆記型電腦特別有用,因為其只會在網路線真正連上後才會對介面進行組態。另一個會用到的情況為,當您需要重新啟動網路,但您並不想重開及或在 Shell 中進行設定。<br />
<br />
預設情況下,其會對 {{ic|eth0}} 裝置進行設定使其運作。這與其他設定類似延遲之類的設定能在 {{ic|/etc/ifplugd/ifplugd.conf}} 中進行設定。<br />
<br />
<br />
{{註記|[[Netctl]] 軟體包包含了 {{ic|netctl-ifplugd@.service}},否則您可以使用來自 {{Pkg|ifplugd}} 軟體包的 {{ic|ifplugd@.service}} 。例如這樣使用:{{ic|systemctl enable ifplugd@eth0.service}}。}}<br />
<br />
=== Bonding 或 LAG ===<br />
<br />
請參閱 [[netctl#Bonding]] 。<br />
<br />
=== IP 別名 ===<br />
<br />
{{Expansion|Manual method using [[Core Utilities#ip|ip]] should be added; then move current example using ''netctl'' into [[netctl]].}}<br />
<br />
IP 別名為讓同一個網路介面有多個 IP 位址。如此一來,單個節點的網路就能有多個網路連線,進而實現不同的作用。經典的使用方法為網頁與 FTP 伺服器的虛擬主機,或是重組伺服器而無需更新任何其他的機器(對於名稱伺服器來說特別有用)。<br />
<br />
==== 範例 ====<br />
<br />
您將需要來自[[Official Repositories (正體中文)|官方軟體套件庫]]的 {{Pkg|netctl}} 。<br />
<br />
準備組態設定檔:<br />
<br />
{{hc|/etc/netctl/mynetwork|<nowiki><br />
Connection='ethernet'<br />
Description='Five different addresses on the same NIC.'<br />
Interface='eth0'<br />
IP='static'<br />
Address=('192.168.1.10' '192.168.178.11' '192.168.1.12' '192.168.1.13' '192.168.1.14' '192.168.1.15')<br />
Gateway='192.168.1.1'<br />
DNS=('192.168.1.1')<br />
</nowiki>}}<br />
<br />
接著只需要將其執行即可:<br />
<br />
$ netctl start mynetwork<br />
<br />
=== 更改 MAC/硬體 位址 ===<br />
<br />
請參閱 [[MAC Address Spoofing]] 。<br />
<br />
=== 網路共享 ===<br />
<br />
請參閱 [[Internet Sharing]] 。<br />
<br />
=== 路由組態設定 ===<br />
<br />
請參閱 [[Router]] 。<br />
<br />
=== 區域網路主機名稱解析 ===<br />
<br />
先決條件為[[#.E8.A8.AD.E5.AE.9A.E4.B8.BB.E6.A9.9F.E5.90.8D.E7.A8.B1|設定主機名稱]]之後,主機名稱可在本機系統上解析:<br />
{{hc|$ ping hostname|<br />
PING hostname <nowiki>(192.168.1.2) 56(84) bytes of data.<br />
64 bytes from hostname (192.168.1.2): icmp_seq=1 ttl=64 time=0.043 ms</nowiki>}}<br />
要以其他機器的名稱來解析主機,需要手動設定各自的 {{ic|/etc/hosts}} 檔案或是廣播/解析名稱的服務。<br />
<br />
過度設定 DNS 伺服器,如 [[BIND]] 、 [[Unbound]] ,手動編輯 {{ic|/etc/hosts}} 過於繁瑣,或是您希望對於動態地將主機離開、加入網路有更大的靈活性,您可以在您的區域網路中使用 Zero-configuration networking 來進行主機名稱解析。這裡有兩個可用選擇:<br />
<br />
*[[Samba]] 提供了通過微軟 '''NetBIOS''' 的主機名稱解析。其只需要安裝 {{Pkg|samba}} 並啟用 {{ic|nmbd.service}} 服務。執行 Windows 、OS X 或執行了 {{ic|nmbd}} 的 Linux ,將能夠找到您的機器。<br />
<br />
*[[Avahi]] 提供通過 '''zeroconf''' 的主機名稱解析,也稱作 Avahi 或 Boujour 。它比 Samba 還需要稍微複雜一點的設定:詳情請參考 [[Avahi#Hostname resolution]]。執行 OS X 或執行了 Avahi daemon 的 Linux ,將能夠找到您的機器。Windows 並無內建 Avahi 用戶端或 Daemon 。<br />
<br />
== 診斷 ==<br />
<br />
=== Swapping computers on the cable modem ===<br />
<br />
Some cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.<br />
<br />
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].<br />
<br />
=== The TCP window scaling problem ===<br />
<br />
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.<br />
<br />
Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html RFC 1323] was written to improve the situation: Window Scaling. The "window" value, provided in all packets, will be modified by a Scale Factor defined once, at the very beginning of the connection.<br />
<br />
That 8-bit Scale Factor allows the Window to be up to 32 times higher than the initial 64Kb.<br />
<br />
It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts.<br />
<br />
The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.<br />
<br />
The resulting connection is at best very slow or broken.<br />
<br />
==== How to diagnose the problem ====<br />
<br />
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).<br />
<br />
When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|ip addr}} will report normal status... and actually everything appears normal.<br />
<br />
If you cannot browse any website, but you can ping some random hosts, chances are great that you're experiencing this problem: ping uses ICMP and is not affected by TCP problems.<br />
<br />
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).<br />
<br />
==== How to fix it (The bad way) ====<br />
<br />
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.<br />
<br />
# echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem<br />
<br />
==== How to fix it (The good way) ====<br />
<br />
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.d/99-disable_window_scaling.conf}} (see also [[sysctl]])<br />
<br />
net.ipv4.tcp_window_scaling = 0<br />
<br />
==== How to fix it (The best way) ====<br />
<br />
This problem is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.<br />
<br />
==== More about it ====<br />
<br />
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].<br />
<br />
There are also several relevant threads on the LKML.<br />
<br />
=== Realtek no link / WOL problem ===<br />
<br />
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice a problem where the NIC seems to be disabled on boot and has no Link light. This can usually be found on a dual boot system where Windows is also installed. It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause. These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots. You will be able to notice if this problem is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off. Normal operation should be that the link light is always on as long as the system is on, even during POST. This problem will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this problem:<br />
<br />
==== Method 1 - Rollback/change Windows driver ====<br />
<br />
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).<br />
<br />
==== Method 2 - Enable WOL in Windows driver ====<br />
<br />
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems). In Windows, under Device Manager, find your Realtek network adapter and double-click it. Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.<br />
<br />
In Windows XP (example)<br />
Right click my computer<br />
--> Hardware tab<br />
--> Device Manager<br />
--> Network Adapters<br />
--> "double click" Realtek ...<br />
--> Advanced tab<br />
--> Wake-On-Lan After Shutdown<br />
--> Enable<br />
<br />
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{ic|Disable}} has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.}}<br />
<br />
==== Method 3 - Newer Realtek Linux driver ====<br />
<br />
Any newer driver for these Realtek cards can be found for Linux on the realtek site. (untested but believed to also solve the problem).<br />
<br />
==== Method 4 - Enable ''LAN Boot ROM'' in BIOS/CMOS ====<br />
<br />
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.<br />
<br />
{{Note|This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.}}<br />
<br />
=== No eth0 with Atheros AR8161 ===<br />
<br />
{{Note|With the 3.10.2-1-ARCH kernel update, the alx ethernet driver module is included in the package.}}<br />
<br />
With the Atheros AR8161 Gigabit Ethernet card, the ethernet connection is not working out-of-the-box (with the installation media of March 2013). The module "alx" needs to be loaded but is not present.<br />
<br />
The driver from [http://linuxwireless.org/en/users/Download/stable/#compat-wireless_stable_releases compat-wireless] (that has become [https://backports.wiki.kernel.org/index.php/Releases compat-drives] since linux 3.7) need to be installed. The "-u" postfix annotates that Qualcomm have applied a driver under a unified driver.<br />
<br />
$ wget https://www.kernel.org/pub/linux/kernel/projects/backports/2013/03/28/compat-drivers-2013-03-28-5-u.tar.bz2<br />
$ tar xjf compat*<br />
$ cd compat*<br />
$ ./scripts/driver-select alx<br />
$ make<br />
$ sudo make install<br />
$ sudo modprobe alx<br />
<br />
The alx driver has not been added to Linux kernel due to various problems. Compatibility between the different kernel versions has been spotty. For better support follow the [http://lists.infradead.org/mailman/listinfo/unified-drivers mailing list]and [http://www.linuxfoundation.org/collaborate/workgroups/networking/alx alx page]for latest working solution for alx.<br />
<br />
The driver must be built and installed after every kernel change.<br />
<br />
Alternatively you can use the AUR package for [https://aur.archlinux.org/packages/compat-drivers-patched/ compat drivers], which installs many other drivers.<br />
<br />
=== No eth0 with Atheros AR9485 ===<br />
<br />
The ethernet (eth0) for Atheros AR9485 are not working out-of-the-box (with installation media of March 2013). The working solution for this is to install the package [https://aur.archlinux.org/packages/compat-drivers-patched/ compat-drivers-patched] from AUR.<br />
<br />
=== No carrier / no connection after suspend ===<br />
After suspend to RAM no connection is found although the network cable is plugged in. <br />
This may be caused by PCI power management. What is the output of<br />
<br />
# ip link show eth0<br />
<br />
If the line contains "NO-CARRIER" even though there's a cable connected to your eth0 port, it is possible that the device was auto-suspended and the media sense feature doesn't work. To solve this, first you need to find your ethernet controllers PCI address by<br />
<br />
# lspci<br />
<br />
This should look similar to this:<br />
<br />
...<br />
00:19.0 Ethernet controller: Intel Corporation 82577LM Gigabit Network Connection (rev 06)<br />
...<br />
<br />
So the address is 00:19.0.<br />
Now check the PM status of the device by issuing<br />
<br />
# cat "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
substituting 00:19.0 with the address obtained from lspci.<br />
If the output reads "auto", you can try to bring the device out of suspend by<br />
<br />
# echo on > "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
Don't forget to substitute the address again.<br />
<br />
{{Note|1=This appears to be a bug in kernel 3.8.4.1- (3.8.8.1 is still affected): [https://bbs.archlinux.org/viewtopic.php?id=159837&p=2 Forum discussion.] It also appears a fix is [https://lkml.org/lkml/2013/1/18/147 on the way. (It will be likely fixed in 3.9.)] In the meantime, the above is a suitable workaround.}}<br />
<br />
=== Broadcom BCM57780 ===<br />
<br />
This Broadcom chipset sometimes does not behave well unless you specify the order of the modules to be loaded. The modules are {{ic|broadcom}} and {{ic|tg3}}, the former needing to be loaded first.<br />
<br />
These steps should help if your computer has this chipset:<br />
$ lspci | grep Ethernet<br />
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)<br />
<br />
If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following (as root):<br />
# modprobe -r tg3<br />
# modprobe broadcom<br />
# modprobe tg3<br />
<br />
Now plug you network cable in. If this solves your problems you can make this permanent by adding {{ic|broadcom}} and {{ic|tg3}} (in this order) to the {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}}:<br />
<br />
MODULES=".. broadcom tg3 .."<br />
<br />
Then rebuild the initramfs:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|These methods may work for other chipsets, such as BCM57760.}}</div>Binotahttps://wiki.archlinux.org/index.php?title=Network_configuration_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=298928Network configuration (正體中文)2014-02-19T13:58:49Z<p>Binota: /* 於啟動時通過 systemd 手動連線 */ Translated</p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:Networking (正體中文)]]<br />
[[Category:Getting and installing Arch (正體中文)]]<br />
[[cs:Configuring Network]]<br />
[[el:Configuring Network]]<br />
[[en:Configuring Network]]<br />
[[es:Configuring Network]]<br />
[[fr:Connexions reseau]]<br />
[[it:Configuring Network]]<br />
[[ja:Network Configuration]]<br />
[[nl:Configuring Network]]<br />
[[pt:Configuring Network]]<br />
[[ro:Configurare retea]]<br />
[[ru:Configuring Network]]<br />
[[sk:Configuring Network]]<br />
[[tr:Ağ_Yapılandırması]]<br />
[[zh-CN:Network Configuration]]<br />
{{Related articles start (正體中文)}}<br />
{{Related2|Jumbo Frames|巨型封包 (英)}}<br />
{{Related2|Firewalls|防火牆 (英)}}<br />
{{Related2|Wireless Setup|無線網路設定 (英)}}<br />
{{Related2|List of Applications#Network Managers|應用程式清單#網路管理員 (英)}}<br />
{{Related articles end}}<br />
{{TranslationStatus (正體中文)|Network_Configuration|2014-02-20|298590}}<br />
<br />
本頁將介紹如何設定'''有線'''網路連線。若您需要設定'''無線'''網路,請參考[[Wireless network configuration|無線網路設定]]。<br />
<br />
== 檢查連線 ==<br />
<br />
{{註記|若您在執行 ping 時收到了類似 {{ic|ping: icmp open socket: Operation not permitted}} 這樣的錯誤訊息,請嘗試重新安裝 {{ic|iputils}} 軟體包。}} <br />
<br />
一般來說,基本的安裝過程都已經建立了可運作的網路設定。請執行下列指令以進行檢查:<br />
<br />
{{註記|{{ic|-c 3}} 選項表示將會呼叫三次。詳細請參閱 {{ic|man ping}} 。}}<br />
{{提示|您也可以嘗試使用其他的 Domain ,如 www.hinet.net 。}}<br />
<br />
{{hc|$ ping -c 3 www.google.com|<nowiki><br />
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.<br />
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms<br />
64 bytes from 74.125.224.146: icmp_req=2 ttl=50 time=385 ms<br />
64 bytes from 74.125.224.146: icmp_req=3 ttl=50 time=298 ms<br />
<br />
--- www.l.google.com ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 1999ms<br />
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms<br />
</nowiki>}}<br />
<br />
如果沒問題的話,您可能只是想以本文的下列部分來自定您的設定。<br />
<br />
若剛才的指令出現了 unknown hosts 之類的訊息,代表您的機器無法解析網域。這可能是因為您的網路服務提供商/閘道造成的。您可以嘗試 ping 一個靜態 IP 以實驗您的機器能否存取網際網路。<br />
{{提示|您也可以嘗試使用其他的 IP ,如 168.95.1.1 。}}<br />
<br />
{{hc|$ ping -c 3 8.8.8.8|<nowiki><br />
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.<br />
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms<br />
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms<br />
64 bytes from 8.8.8.8: icmp_req=3 ttl=53 time=70.6 ms<br />
<br />
--- 8.8.8.8 ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 2002ms<br />
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms<br />
</nowiki>}}<br />
<br />
{{註記|{{ic|8.8.8.8}} 為一個好記的靜態 IP 位置。這是 Google 的主要 DNS 伺服器,這表示其有一定的可信度,並且通常不會被系統或代理伺服器擋下。}}<br />
<br />
若您可以 Ping 通 {{ic|8.8.8.8}} ,但 {{ic|www.google.com}} 不能,請檢查您的 DNS 組態設定檔。詳情請參考 [[resolv.conf]]。<br />
<br />
== 設定主機名稱 ==<br />
<br />
[[Wikipedia:Hostname|主機名稱]]為網路中用於識別機器的唯一識別名稱:主機名稱可以通過 {{ic|/etc/hostname}} 檔案來進行設定。一般來說該檔案包含了系統的網域名稱。下面為設定主機名稱的方法:<br />
<br />
# hostnamectl set-hostname '''myhostname'''<br />
<br />
這樣會將 {{ic|''myhostname''}} 寫入 {{ic|/etc/hostname}} 檔案中。<br />
<br />
詳細請參閱 {{ic|man 5 hostname}} 與 {{ic|man 1 hostnamectl}} 。<br />
<br />
{{註記|<br />
* {{ic|hostnamectl}} 支援 FQDN<br />
* 您不需要編輯 {{ic|/etc/hosts}} 檔案,{{pkg|systemd}} 會提供主機名稱解析且預設安裝於所有系統。<br />
}}<br />
<br />
使用來自 {{Pkg|inetutils}} 的 ''hostname'' 以設定臨時主機名稱(直到重新啟動):<br />
<br />
# hostname ''myhostname''<br />
<br />
== 裝置驅動程式 ==<br />
<br />
=== 檢查驅動程式狀態 ===<br />
<br />
[[udev]] 應該會檢測您的網路介面卡([[Wikipedia:Network_interface_controller|NIC]])並自動於啟動時載入必要的模組。檢查 {{ic|lspci -v}} 輸出內容中的「Ethernet controller」 項目(或類似的)。這應該會告訴您哪些核心模組包含了網路設備的驅動程式。舉例來說:<br />
<br />
{{hc|$ lspci -v|<br />
02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)<br />
...<br />
Kernel driver in use: atl1<br />
Kernel modules: atl1<br />
}}<br />
<br />
接下來,確認該驅動程式已經通過 {{ic|dmesg <nowiki>|</nowiki> grep ''module_name''}} 載入了。舉例來說:<br />
<br />
$ dmesg | grep atl1<br />
...<br />
atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex<br />
<br />
若驅動程式已成功加載可以跳過接下來這段。否則,您會需要知道哪些模組時您的特定型號的裝置需要哪個模組。<br />
<br />
=== 載入裝置模組 ===<br />
<br />
以 Google 搜尋正確的晶片組模組/驅動程式。常見的驅動模組有 Realtek 晶片組網卡的 {{ic|8139too}} ,或是 SiS 晶片組網卡的 {{ic|sis900}}。當您知道要使用何種模組了之後,試著[[Kernel modules#Manual module handling|手動將其載入]]。若您得到了錯誤訊息告訴您找不到該模組,則該驅動可能未包含於 Arch 核心中。您可以在 [[AUR]] 中搜尋該模組名稱。<br />
<br />
若 udev 未在開機期間檢測與載入正確的模組,請參閱 [[Kernel modules#Loading]]。<br />
<br />
== 網路介面 ==<br />
<br />
=== 裝置名稱 ===<br />
<br />
對於多網路卡的電腦,固定裝置名稱非常重要。許多設定問題都是因為介面卡名稱的改動造成的。<br />
<br />
[[udev]] 負責命名裝置。Systemd v197 則有[http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames 可預測之網路介面名稱]並可自動支配靜態名稱給網路裝置。介面名稱以 {{ic|en}} (乙太網路)、 {{ic|wl}} (無線網路) 或是 {{ic|ww}} (WWAN)作為前置字串並附上一個自動產生的識別名稱,進而產生了類似 {{ic|enp0s25}} 這樣的名稱。 <br />
<br />
要禁用這種行為,可以加上一個連接:<br />
<br />
# ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules<br />
<br />
自早期版本升級 systemd 的使用者會有一自動建立的空規則檔案。因此,若您想使用一貫的裝置名稱,只需要刪除該檔案。<br />
<br />
{{提示|您可以執行 {{ic|ip link}} 或是 {{ic|ls /sys/class/net}} 以列出所有可用的介面。}}<br />
<br />
{{註記|當您更改了介面名稱規則後,別忘了更新所有跟網路有關的組態檔案與自定的 systemd unit 檔案以因應該更改。特別是當您啟用了 [[netctl#Basic method|netctl 靜態設定檔]] ,請執行 {{ic|netctl reenable ''profile''}} 以更新所有產生的服務檔案。}}<br />
<br />
==== 更改裝置名稱 ====<br />
<br />
您可以使用 udev-rule 來手動定義裝置名稱。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"<br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"<br />
</nowiki>}}<br />
<br />
請注意這兩點:<br />
<br />
* 使用這個指令以取得 MAC 位置:{{ic|cat /sys/class/net/''device_name''/address}}。<br />
* 請確定 udev 規則中使用的是小寫的十六進位數值而不是大寫。<br />
<br />
若您的網路卡為動態 MAC ,您可以使用 DEVPATH ,例如:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"<br />
</nowiki>}}<br />
<br />
{{註記|當使用了靜態的名稱時,'''應該要避免使用類似 "eth''X''" 與 "wlan''X''"''' 這樣的名稱,因為這可能會導致核心與 udev 在開機時發生衝突。而剛好相反地,最好使用核心預設不會使用的介面名稱,如 {{ic|net0}} 、 {{ic|net1}} 、 {{ic|wifi0}} 、 {{ic|wifi1}} 。詳細說明請參閱 [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames systemd] 文件。}}<br />
<br />
=== 設定裝置的 MTU 與佇列長度 ===<br />
<br />
您可以手動定義 udev 規則來更改裝置的 MTU 與佇列長度。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1480", ATTR{tx_queue_len}="2000"<br />
</nowiki>}}<br />
<br />
=== 取得目前的裝置名稱 ===<br />
<br />
目前的 NIC 名稱可以通過 sysfs 找到<br />
<br />
{{hc|$ ls /sys/class/net|<br />
lo eth0 eth1 firewire0<br />
}}<br />
<br />
=== 啟用與禁用網路介面 ===<br />
<br />
您可以使用下列指令來啟用或禁用網路介面:<br />
<br />
# ip link set eth0 up<br />
# ip link set eth0 down<br />
<br />
要確認結果,請執行:<br />
<br />
{{hc|$ ip link show dev eth0|<br />
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000<br />
...<br />
}}<br />
<br />
== 組態設定 IP 位址 ==<br />
<br />
您有兩個選擇:使用 [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]] 指派動態位址,或是使用「靜態」的位址。<br />
<br />
=== 動態 IP 位址 ===<br />
<br />
最簡單的方式就是使用 [[dhcpcd]],它包含在 {{Grp|base}} 群組中。無論是使用提供服務檔案 {{ic|dhcpcd@.service}} ,以參數方式傳入介面卡名稱,或是手動通過 {{ic|dhcpcd ''interface''}} 將其執行。<br />
<br />
=== 靜態 IP 位址 ===<br />
<br />
您可能因為各種原因而希望在您的網路中指派靜態 IP 位址,例如靜態的位址可以獲得一定程度的可預測性,或是您沒有可用的 DHCP 伺服器。<br />
<br />
{{註記|若您通過 Windows 機器來共享您的網路而不是使用路由器,請確保兩台電腦皆使用了靜態 IP 位址以避免區域網路問題。}}<br />
<br />
您需要:<br />
<br />
* 靜態 IP 位址<br />
* [[Wikipedia:Subnetwork|子網路遮罩]]<br />
* [[Wikipedia:Broadcast_address|廣播位址]]<br />
* [[Wikipedia:Default_gateway|預設閘道器]]的 IP 位址<br />
<br />
若您處在內部網路中,使用 192.168.*.* 這樣的 IP 位址較為安全,搭配其的子網路遮罩 255.255.255.0 ,廣播位址為 192.168.*.255 。而閘道通常是 192.168.*.1 或是 192.168.*.254 。<br />
<br />
{{Tip|You may need to manually set the DNS servers, see [[resolv.conf]] for details.}}<br />
<br />
==== 手動指派 ====<br />
<br />
您可於控制台中指派一靜態 IP 位址:<br />
<br />
# ip addr add <IP 位址>/<子網路遮罩> broadcast <廣播> dev <介面><br />
<br />
舉例來說:<br />
<br />
# ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev eth0<br />
<br />
{{註記|子網路遮罩使用了 [[Wikipedia:CIDR_notation|CIDR 表示法]](CIDR,Classless Inter-Domain Routing,無類別網路間路由)。}}<br />
<br />
詳情請參閱 {{ic|man ip}} 。<br />
<br />
以類似下列方法加上您的閘道:<br />
<br />
# ip route add default via <預設閘道 IP 位址><br />
<br />
舉例來說:<br />
<br />
# ip route add default via 192.168.1.1<br />
<br />
若您得到了 "No such process" 這樣的錯誤訊息,這代表您必須以 root 執行 {{ic|ip link set dev eth0 up}} 。<br />
<br />
==== 於啟動時通過 systemd 手動連線 ====<br />
<br />
首先先為 [[systemd]] 服務建立一個組態設定檔,請以網路介面卡名稱取代下列的 {{ic|<interface>}}:<br />
<br />
{{hc|/etc/conf.d/network@<interface>|<nowiki><br />
address=192.168.0.15<br />
netmask=24<br />
broadcast=192.168.0.255<br />
gateway=192.168.0.1<br />
</nowiki>}}<br />
<br />
建立 systemd unit 檔案:<br />
<br />
{{hc|/etc/systemd/system/network@.service|<nowiki><br />
[Unit]<br />
Description=Network connectivity (%i)<br />
Wants=network.target<br />
Before=network.target<br />
BindsTo=sys-subsystem-net-devices-%i.device<br />
After=sys-subsystem-net-devices-%i.device<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
EnvironmentFile=/etc/conf.d/network@%i<br />
<br />
ExecStart=/usr/bin/ip link set dev %i up<br />
ExecStart=/usr/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i<br />
ExecStart=/usr/bin/ip route add default via ${gateway}<br />
<br />
ExecStop=/usr/bin/ip addr flush dev %i<br />
ExecStop=/usr/bin/ip link set dev %i down<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
啟用該 unit 並將其啟動,傳入介面名稱:<br />
<br />
# systemctl enable network@''介面名稱''.service<br />
# systemctl start network@''介面名稱''.service<br />
<br />
==== 計算位址 ====<br />
<br />
您可以使用 {{Pkg|ipcalc}} 提供的 {{ic|ipcalc}} 來計算 IP 廣播、網域、子網路遮罩與主機範圍等進階設定舉例來說,我使用了位於防火牆後的乙太網路來連線 Windows 機器至 Arch。為了安全性與網路組織,我將他們放置於各自獨立的網路,接著組態設定子網路遮罩與廣播位址,如此一來網路中就只有兩台機器。為了找出子網路遮罩跟廣播位址,我使用了 ipcalc ,提供其 Arch firewire nic 的 IP 位址 10.66.66.1 ,並指定 ipcalc 要建立一個只有兩台主機的網路。<br />
<br />
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|<nowiki><br />
Address: 10.66.66.1<br />
<br />
Netmask: 255.255.255.252 = 30<br />
Network: 10.66.66.0/30<br />
HostMin: 10.66.66.1<br />
HostMax: 10.66.66.2<br />
Broadcast: 10.66.66.3<br />
Hosts/Net: 2 Class A, Private Internet<br />
</nowiki>}}<br />
<br />
== 載入組態設定 ==<br />
<br />
要測試您的設定,您可以重新啟動電腦或是重新載入相關的 systemd 服務。Then try pinging your gateway, DNS server, ISP provider and other Internet sites, in that order, to detect any connection problems along the way, as in this example:<br />
<br />
$ ping -c 3 www.google.com<br />
<br />
== 附加設定 ==<br />
<br />
=== 筆記型電腦之 ifplugd ===<br />
<br />
{{提示|[[dhcpcd]] 提供了開箱即用的相同功能。}}<br />
<br />
[[Official Repositories (正體中文)|官方軟體套件庫]]中的 {{Pkg|ifplugd}} 為一個當網路線插入後自動組態乙太設備;網路線拔除後自動取消組態的 Daemon 。<br />
這對於搭載內建網路介面卡的筆記型電腦特別有用,因為其只會在網路線真正連上後才會對介面進行組態。另一個會用到的情況為,當您需要重新啟動網路,但您並不想重開及或在 Shell 中進行設定。<br />
<br />
預設情況下,其會對 {{ic|eth0}} 裝置進行設定使其運作。這與其他設定類似延遲之類的設定能在 {{ic|/etc/ifplugd/ifplugd.conf}} 中進行設定。<br />
<br />
<br />
{{註記|[[Netctl]] 軟體包包含了 {{ic|netctl-ifplugd@.service}},否則您可以使用來自 {{Pkg|ifplugd}} 軟體包的 {{ic|ifplugd@.service}} 。例如這樣使用:{{ic|systemctl enable ifplugd@eth0.service}}。}}<br />
<br />
=== Bonding 或 LAG ===<br />
<br />
請參閱 [[netctl#Bonding]] 。<br />
<br />
=== IP 別名 ===<br />
<br />
{{Expansion|Manual method using [[Core Utilities#ip|ip]] should be added; then move current example using ''netctl'' into [[netctl]].}}<br />
<br />
IP 別名為讓同一個網路介面有多個 IP 位址。如此一來,單個節點的網路就能有多個網路連線,進而實現不同的作用。經典的使用方法為網頁與 FTP 伺服器的虛擬主機,或是重組伺服器而無需更新任何其他的機器(對於名稱伺服器來說特別有用)。<br />
<br />
==== 範例 ====<br />
<br />
您將需要來自[[Official Repositories (正體中文)|官方軟體套件庫]]的 {{Pkg|netctl}} 。<br />
<br />
準備組態設定檔:<br />
<br />
{{hc|/etc/netctl/mynetwork|<nowiki><br />
Connection='ethernet'<br />
Description='Five different addresses on the same NIC.'<br />
Interface='eth0'<br />
IP='static'<br />
Address=('192.168.1.10' '192.168.178.11' '192.168.1.12' '192.168.1.13' '192.168.1.14' '192.168.1.15')<br />
Gateway='192.168.1.1'<br />
DNS=('192.168.1.1')<br />
</nowiki>}}<br />
<br />
接著只需要將其執行即可:<br />
<br />
$ netctl start mynetwork<br />
<br />
=== 更改 MAC/硬體 位址 ===<br />
<br />
請參閱 [[MAC Address Spoofing]] 。<br />
<br />
=== 網路共享 ===<br />
<br />
請參閱 [[Internet Sharing]] 。<br />
<br />
=== 路由組態設定 ===<br />
<br />
請參閱 [[Router]] 。<br />
<br />
=== 區域網路主機名稱解析 ===<br />
<br />
先決條件為[[#.E8.A8.AD.E5.AE.9A.E4.B8.BB.E6.A9.9F.E5.90.8D.E7.A8.B1|設定主機名稱]]之後,主機名稱可在本機系統上解析:<br />
{{hc|$ ping hostname|<br />
PING hostname <nowiki>(192.168.1.2) 56(84) bytes of data.<br />
64 bytes from hostname (192.168.1.2): icmp_seq=1 ttl=64 time=0.043 ms</nowiki>}}<br />
要以其他機器的名稱來解析主機,需要手動設定各自的 {{ic|/etc/hosts}} 檔案或是廣播/解析名稱的服務。<br />
<br />
過度設定 DNS 伺服器,如 [[BIND]] 、 [[Unbound]] ,手動編輯 {{ic|/etc/hosts}} 過於繁瑣,或是您希望對於動態地將主機離開、加入網路有更大的靈活性,您可以在您的區域網路中使用 Zero-configuration networking 來進行主機名稱解析。這裡有兩個可用選擇:<br />
<br />
*[[Samba]] 提供了通過微軟 '''NetBIOS''' 的主機名稱解析。其只需要安裝 {{Pkg|samba}} 並啟用 {{ic|nmbd.service}} 服務。執行 Windows 、OS X 或執行了 {{ic|nmbd}} 的 Linux ,將能夠找到您的機器。<br />
<br />
*[[Avahi]] 提供通過 '''zeroconf''' 的主機名稱解析,也稱作 Avahi 或 Boujour 。它比 Samba 還需要稍微複雜一點的設定:詳情請參考 [[Avahi#Hostname resolution]]。執行 OS X 或執行了 Avahi daemon 的 Linux ,將能夠找到您的機器。Windows 並無內建 Avahi 用戶端或 Daemon 。<br />
<br />
== 診斷 ==<br />
<br />
=== Swapping computers on the cable modem ===<br />
<br />
Some cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.<br />
<br />
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].<br />
<br />
=== The TCP window scaling problem ===<br />
<br />
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.<br />
<br />
Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html RFC 1323] was written to improve the situation: Window Scaling. The "window" value, provided in all packets, will be modified by a Scale Factor defined once, at the very beginning of the connection.<br />
<br />
That 8-bit Scale Factor allows the Window to be up to 32 times higher than the initial 64Kb.<br />
<br />
It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts.<br />
<br />
The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.<br />
<br />
The resulting connection is at best very slow or broken.<br />
<br />
==== How to diagnose the problem ====<br />
<br />
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).<br />
<br />
When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|ip addr}} will report normal status... and actually everything appears normal.<br />
<br />
If you cannot browse any website, but you can ping some random hosts, chances are great that you're experiencing this problem: ping uses ICMP and is not affected by TCP problems.<br />
<br />
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).<br />
<br />
==== How to fix it (The bad way) ====<br />
<br />
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.<br />
<br />
# echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem<br />
<br />
==== How to fix it (The good way) ====<br />
<br />
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.d/99-disable_window_scaling.conf}} (see also [[sysctl]])<br />
<br />
net.ipv4.tcp_window_scaling = 0<br />
<br />
==== How to fix it (The best way) ====<br />
<br />
This problem is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.<br />
<br />
==== More about it ====<br />
<br />
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].<br />
<br />
There are also several relevant threads on the LKML.<br />
<br />
=== Realtek no link / WOL problem ===<br />
<br />
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice a problem where the NIC seems to be disabled on boot and has no Link light. This can usually be found on a dual boot system where Windows is also installed. It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause. These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots. You will be able to notice if this problem is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off. Normal operation should be that the link light is always on as long as the system is on, even during POST. This problem will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this problem:<br />
<br />
==== Method 1 - Rollback/change Windows driver ====<br />
<br />
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).<br />
<br />
==== Method 2 - Enable WOL in Windows driver ====<br />
<br />
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems). In Windows, under Device Manager, find your Realtek network adapter and double-click it. Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.<br />
<br />
In Windows XP (example)<br />
Right click my computer<br />
--> Hardware tab<br />
--> Device Manager<br />
--> Network Adapters<br />
--> "double click" Realtek ...<br />
--> Advanced tab<br />
--> Wake-On-Lan After Shutdown<br />
--> Enable<br />
<br />
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{ic|Disable}} has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.}}<br />
<br />
==== Method 3 - Newer Realtek Linux driver ====<br />
<br />
Any newer driver for these Realtek cards can be found for Linux on the realtek site. (untested but believed to also solve the problem).<br />
<br />
==== Method 4 - Enable ''LAN Boot ROM'' in BIOS/CMOS ====<br />
<br />
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.<br />
<br />
{{Note|This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.}}<br />
<br />
=== No eth0 with Atheros AR8161 ===<br />
<br />
{{Note|With the 3.10.2-1-ARCH kernel update, the alx ethernet driver module is included in the package.}}<br />
<br />
With the Atheros AR8161 Gigabit Ethernet card, the ethernet connection is not working out-of-the-box (with the installation media of March 2013). The module "alx" needs to be loaded but is not present.<br />
<br />
The driver from [http://linuxwireless.org/en/users/Download/stable/#compat-wireless_stable_releases compat-wireless] (that has become [https://backports.wiki.kernel.org/index.php/Releases compat-drives] since linux 3.7) need to be installed. The "-u" postfix annotates that Qualcomm have applied a driver under a unified driver.<br />
<br />
$ wget https://www.kernel.org/pub/linux/kernel/projects/backports/2013/03/28/compat-drivers-2013-03-28-5-u.tar.bz2<br />
$ tar xjf compat*<br />
$ cd compat*<br />
$ ./scripts/driver-select alx<br />
$ make<br />
$ sudo make install<br />
$ sudo modprobe alx<br />
<br />
The alx driver has not been added to Linux kernel due to various problems. Compatibility between the different kernel versions has been spotty. For better support follow the [http://lists.infradead.org/mailman/listinfo/unified-drivers mailing list]and [http://www.linuxfoundation.org/collaborate/workgroups/networking/alx alx page]for latest working solution for alx.<br />
<br />
The driver must be built and installed after every kernel change.<br />
<br />
Alternatively you can use the AUR package for [https://aur.archlinux.org/packages/compat-drivers-patched/ compat drivers], which installs many other drivers.<br />
<br />
=== No eth0 with Atheros AR9485 ===<br />
<br />
The ethernet (eth0) for Atheros AR9485 are not working out-of-the-box (with installation media of March 2013). The working solution for this is to install the package [https://aur.archlinux.org/packages/compat-drivers-patched/ compat-drivers-patched] from AUR.<br />
<br />
=== No carrier / no connection after suspend ===<br />
After suspend to RAM no connection is found although the network cable is plugged in. <br />
This may be caused by PCI power management. What is the output of<br />
<br />
# ip link show eth0<br />
<br />
If the line contains "NO-CARRIER" even though there's a cable connected to your eth0 port, it is possible that the device was auto-suspended and the media sense feature doesn't work. To solve this, first you need to find your ethernet controllers PCI address by<br />
<br />
# lspci<br />
<br />
This should look similar to this:<br />
<br />
...<br />
00:19.0 Ethernet controller: Intel Corporation 82577LM Gigabit Network Connection (rev 06)<br />
...<br />
<br />
So the address is 00:19.0.<br />
Now check the PM status of the device by issuing<br />
<br />
# cat "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
substituting 00:19.0 with the address obtained from lspci.<br />
If the output reads "auto", you can try to bring the device out of suspend by<br />
<br />
# echo on > "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
Don't forget to substitute the address again.<br />
<br />
{{Note|1=This appears to be a bug in kernel 3.8.4.1- (3.8.8.1 is still affected): [https://bbs.archlinux.org/viewtopic.php?id=159837&p=2 Forum discussion.] It also appears a fix is [https://lkml.org/lkml/2013/1/18/147 on the way. (It will be likely fixed in 3.9.)] In the meantime, the above is a suitable workaround.}}<br />
<br />
=== Broadcom BCM57780 ===<br />
<br />
This Broadcom chipset sometimes does not behave well unless you specify the order of the modules to be loaded. The modules are {{ic|broadcom}} and {{ic|tg3}}, the former needing to be loaded first.<br />
<br />
These steps should help if your computer has this chipset:<br />
$ lspci | grep Ethernet<br />
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)<br />
<br />
If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following (as root):<br />
# modprobe -r tg3<br />
# modprobe broadcom<br />
# modprobe tg3<br />
<br />
Now plug you network cable in. If this solves your problems you can make this permanent by adding {{ic|broadcom}} and {{ic|tg3}} (in this order) to the {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}}:<br />
<br />
MODULES=".. broadcom tg3 .."<br />
<br />
Then rebuild the initramfs:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|These methods may work for other chipsets, such as BCM57760.}}</div>Binotahttps://wiki.archlinux.org/index.php?title=Network_configuration_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=298927Network configuration (正體中文)2014-02-19T13:57:37Z<p>Binota: /* 動態 IP 位址 */ Translated</p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:Networking (正體中文)]]<br />
[[Category:Getting and installing Arch (正體中文)]]<br />
[[cs:Configuring Network]]<br />
[[el:Configuring Network]]<br />
[[en:Configuring Network]]<br />
[[es:Configuring Network]]<br />
[[fr:Connexions reseau]]<br />
[[it:Configuring Network]]<br />
[[ja:Network Configuration]]<br />
[[nl:Configuring Network]]<br />
[[pt:Configuring Network]]<br />
[[ro:Configurare retea]]<br />
[[ru:Configuring Network]]<br />
[[sk:Configuring Network]]<br />
[[tr:Ağ_Yapılandırması]]<br />
[[zh-CN:Network Configuration]]<br />
{{Related articles start (正體中文)}}<br />
{{Related2|Jumbo Frames|巨型封包 (英)}}<br />
{{Related2|Firewalls|防火牆 (英)}}<br />
{{Related2|Wireless Setup|無線網路設定 (英)}}<br />
{{Related2|List of Applications#Network Managers|應用程式清單#網路管理員 (英)}}<br />
{{Related articles end}}<br />
{{TranslationStatus (正體中文)|Network_Configuration|2014-02-20|298590}}<br />
<br />
本頁將介紹如何設定'''有線'''網路連線。若您需要設定'''無線'''網路,請參考[[Wireless network configuration|無線網路設定]]。<br />
<br />
== 檢查連線 ==<br />
<br />
{{註記|若您在執行 ping 時收到了類似 {{ic|ping: icmp open socket: Operation not permitted}} 這樣的錯誤訊息,請嘗試重新安裝 {{ic|iputils}} 軟體包。}} <br />
<br />
一般來說,基本的安裝過程都已經建立了可運作的網路設定。請執行下列指令以進行檢查:<br />
<br />
{{註記|{{ic|-c 3}} 選項表示將會呼叫三次。詳細請參閱 {{ic|man ping}} 。}}<br />
{{提示|您也可以嘗試使用其他的 Domain ,如 www.hinet.net 。}}<br />
<br />
{{hc|$ ping -c 3 www.google.com|<nowiki><br />
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.<br />
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms<br />
64 bytes from 74.125.224.146: icmp_req=2 ttl=50 time=385 ms<br />
64 bytes from 74.125.224.146: icmp_req=3 ttl=50 time=298 ms<br />
<br />
--- www.l.google.com ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 1999ms<br />
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms<br />
</nowiki>}}<br />
<br />
如果沒問題的話,您可能只是想以本文的下列部分來自定您的設定。<br />
<br />
若剛才的指令出現了 unknown hosts 之類的訊息,代表您的機器無法解析網域。這可能是因為您的網路服務提供商/閘道造成的。您可以嘗試 ping 一個靜態 IP 以實驗您的機器能否存取網際網路。<br />
{{提示|您也可以嘗試使用其他的 IP ,如 168.95.1.1 。}}<br />
<br />
{{hc|$ ping -c 3 8.8.8.8|<nowiki><br />
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.<br />
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms<br />
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms<br />
64 bytes from 8.8.8.8: icmp_req=3 ttl=53 time=70.6 ms<br />
<br />
--- 8.8.8.8 ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 2002ms<br />
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms<br />
</nowiki>}}<br />
<br />
{{註記|{{ic|8.8.8.8}} 為一個好記的靜態 IP 位置。這是 Google 的主要 DNS 伺服器,這表示其有一定的可信度,並且通常不會被系統或代理伺服器擋下。}}<br />
<br />
若您可以 Ping 通 {{ic|8.8.8.8}} ,但 {{ic|www.google.com}} 不能,請檢查您的 DNS 組態設定檔。詳情請參考 [[resolv.conf]]。<br />
<br />
== 設定主機名稱 ==<br />
<br />
[[Wikipedia:Hostname|主機名稱]]為網路中用於識別機器的唯一識別名稱:主機名稱可以通過 {{ic|/etc/hostname}} 檔案來進行設定。一般來說該檔案包含了系統的網域名稱。下面為設定主機名稱的方法:<br />
<br />
# hostnamectl set-hostname '''myhostname'''<br />
<br />
這樣會將 {{ic|''myhostname''}} 寫入 {{ic|/etc/hostname}} 檔案中。<br />
<br />
詳細請參閱 {{ic|man 5 hostname}} 與 {{ic|man 1 hostnamectl}} 。<br />
<br />
{{註記|<br />
* {{ic|hostnamectl}} 支援 FQDN<br />
* 您不需要編輯 {{ic|/etc/hosts}} 檔案,{{pkg|systemd}} 會提供主機名稱解析且預設安裝於所有系統。<br />
}}<br />
<br />
使用來自 {{Pkg|inetutils}} 的 ''hostname'' 以設定臨時主機名稱(直到重新啟動):<br />
<br />
# hostname ''myhostname''<br />
<br />
== 裝置驅動程式 ==<br />
<br />
=== 檢查驅動程式狀態 ===<br />
<br />
[[udev]] 應該會檢測您的網路介面卡([[Wikipedia:Network_interface_controller|NIC]])並自動於啟動時載入必要的模組。檢查 {{ic|lspci -v}} 輸出內容中的「Ethernet controller」 項目(或類似的)。這應該會告訴您哪些核心模組包含了網路設備的驅動程式。舉例來說:<br />
<br />
{{hc|$ lspci -v|<br />
02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)<br />
...<br />
Kernel driver in use: atl1<br />
Kernel modules: atl1<br />
}}<br />
<br />
接下來,確認該驅動程式已經通過 {{ic|dmesg <nowiki>|</nowiki> grep ''module_name''}} 載入了。舉例來說:<br />
<br />
$ dmesg | grep atl1<br />
...<br />
atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex<br />
<br />
若驅動程式已成功加載可以跳過接下來這段。否則,您會需要知道哪些模組時您的特定型號的裝置需要哪個模組。<br />
<br />
=== 載入裝置模組 ===<br />
<br />
以 Google 搜尋正確的晶片組模組/驅動程式。常見的驅動模組有 Realtek 晶片組網卡的 {{ic|8139too}} ,或是 SiS 晶片組網卡的 {{ic|sis900}}。當您知道要使用何種模組了之後,試著[[Kernel modules#Manual module handling|手動將其載入]]。若您得到了錯誤訊息告訴您找不到該模組,則該驅動可能未包含於 Arch 核心中。您可以在 [[AUR]] 中搜尋該模組名稱。<br />
<br />
若 udev 未在開機期間檢測與載入正確的模組,請參閱 [[Kernel modules#Loading]]。<br />
<br />
== 網路介面 ==<br />
<br />
=== 裝置名稱 ===<br />
<br />
對於多網路卡的電腦,固定裝置名稱非常重要。許多設定問題都是因為介面卡名稱的改動造成的。<br />
<br />
[[udev]] 負責命名裝置。Systemd v197 則有[http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames 可預測之網路介面名稱]並可自動支配靜態名稱給網路裝置。介面名稱以 {{ic|en}} (乙太網路)、 {{ic|wl}} (無線網路) 或是 {{ic|ww}} (WWAN)作為前置字串並附上一個自動產生的識別名稱,進而產生了類似 {{ic|enp0s25}} 這樣的名稱。 <br />
<br />
要禁用這種行為,可以加上一個連接:<br />
<br />
# ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules<br />
<br />
自早期版本升級 systemd 的使用者會有一自動建立的空規則檔案。因此,若您想使用一貫的裝置名稱,只需要刪除該檔案。<br />
<br />
{{提示|您可以執行 {{ic|ip link}} 或是 {{ic|ls /sys/class/net}} 以列出所有可用的介面。}}<br />
<br />
{{註記|當您更改了介面名稱規則後,別忘了更新所有跟網路有關的組態檔案與自定的 systemd unit 檔案以因應該更改。特別是當您啟用了 [[netctl#Basic method|netctl 靜態設定檔]] ,請執行 {{ic|netctl reenable ''profile''}} 以更新所有產生的服務檔案。}}<br />
<br />
==== 更改裝置名稱 ====<br />
<br />
您可以使用 udev-rule 來手動定義裝置名稱。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"<br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"<br />
</nowiki>}}<br />
<br />
請注意這兩點:<br />
<br />
* 使用這個指令以取得 MAC 位置:{{ic|cat /sys/class/net/''device_name''/address}}。<br />
* 請確定 udev 規則中使用的是小寫的十六進位數值而不是大寫。<br />
<br />
若您的網路卡為動態 MAC ,您可以使用 DEVPATH ,例如:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"<br />
</nowiki>}}<br />
<br />
{{註記|當使用了靜態的名稱時,'''應該要避免使用類似 "eth''X''" 與 "wlan''X''"''' 這樣的名稱,因為這可能會導致核心與 udev 在開機時發生衝突。而剛好相反地,最好使用核心預設不會使用的介面名稱,如 {{ic|net0}} 、 {{ic|net1}} 、 {{ic|wifi0}} 、 {{ic|wifi1}} 。詳細說明請參閱 [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames systemd] 文件。}}<br />
<br />
=== 設定裝置的 MTU 與佇列長度 ===<br />
<br />
您可以手動定義 udev 規則來更改裝置的 MTU 與佇列長度。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1480", ATTR{tx_queue_len}="2000"<br />
</nowiki>}}<br />
<br />
=== 取得目前的裝置名稱 ===<br />
<br />
目前的 NIC 名稱可以通過 sysfs 找到<br />
<br />
{{hc|$ ls /sys/class/net|<br />
lo eth0 eth1 firewire0<br />
}}<br />
<br />
=== 啟用與禁用網路介面 ===<br />
<br />
您可以使用下列指令來啟用或禁用網路介面:<br />
<br />
# ip link set eth0 up<br />
# ip link set eth0 down<br />
<br />
要確認結果,請執行:<br />
<br />
{{hc|$ ip link show dev eth0|<br />
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000<br />
...<br />
}}<br />
<br />
== 組態設定 IP 位址 ==<br />
<br />
您有兩個選擇:使用 [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]] 指派動態位址,或是使用「靜態」的位址。<br />
<br />
=== 動態 IP 位址 ===<br />
<br />
最簡單的方式就是使用 [[dhcpcd]],它包含在 {{Grp|base}} 群組中。無論是使用提供服務檔案 {{ic|dhcpcd@.service}} ,以參數方式傳入介面卡名稱,或是手動通過 {{ic|dhcpcd ''interface''}} 將其執行。<br />
<br />
=== 靜態 IP 位址 ===<br />
<br />
您可能因為各種原因而希望在您的網路中指派靜態 IP 位址,例如靜態的位址可以獲得一定程度的可預測性,或是您沒有可用的 DHCP 伺服器。<br />
<br />
{{註記|若您通過 Windows 機器來共享您的網路而不是使用路由器,請確保兩台電腦皆使用了靜態 IP 位址以避免區域網路問題。}}<br />
<br />
您需要:<br />
<br />
* 靜態 IP 位址<br />
* [[Wikipedia:Subnetwork|子網路遮罩]]<br />
* [[Wikipedia:Broadcast_address|廣播位址]]<br />
* [[Wikipedia:Default_gateway|預設閘道器]]的 IP 位址<br />
<br />
若您處在內部網路中,使用 192.168.*.* 這樣的 IP 位址較為安全,搭配其的子網路遮罩 255.255.255.0 ,廣播位址為 192.168.*.255 。而閘道通常是 192.168.*.1 或是 192.168.*.254 。<br />
<br />
{{Tip|You may need to manually set the DNS servers, see [[resolv.conf]] for details.}}<br />
<br />
==== 手動指派 ====<br />
<br />
您可於控制台中指派一靜態 IP 位址:<br />
<br />
# ip addr add <IP 位址>/<子網路遮罩> broadcast <廣播> dev <介面><br />
<br />
舉例來說:<br />
<br />
# ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev eth0<br />
<br />
{{註記|子網路遮罩使用了 [[Wikipedia:CIDR_notation|CIDR 表示法]](CIDR,Classless Inter-Domain Routing,無類別網路間路由)。}}<br />
<br />
詳情請參閱 {{ic|man ip}} 。<br />
<br />
以類似下列方法加上您的閘道:<br />
<br />
# ip route add default via <預設閘道 IP 位址><br />
<br />
舉例來說:<br />
<br />
# ip route add default via 192.168.1.1<br />
<br />
若您得到了 "No such process" 這樣的錯誤訊息,這代表您必須以 root 執行 {{ic|ip link set dev eth0 up}} 。<br />
<br />
==== 於啟動時通過 systemd 手動連線 ====<br />
<br />
First create a configuration file for the [[systemd]] service, replace {{ic|<interface>}} with the proper network interface name:<br />
<br />
{{hc|/etc/conf.d/network@<interface>|<nowiki><br />
address=192.168.0.15<br />
netmask=24<br />
broadcast=192.168.0.255<br />
gateway=192.168.0.1<br />
</nowiki>}}<br />
<br />
建立 systemd unit 檔案:<br />
<br />
{{hc|/etc/systemd/system/network@.service|<nowiki><br />
[Unit]<br />
Description=Network connectivity (%i)<br />
Wants=network.target<br />
Before=network.target<br />
BindsTo=sys-subsystem-net-devices-%i.device<br />
After=sys-subsystem-net-devices-%i.device<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
EnvironmentFile=/etc/conf.d/network@%i<br />
<br />
ExecStart=/usr/bin/ip link set dev %i up<br />
ExecStart=/usr/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i<br />
ExecStart=/usr/bin/ip route add default via ${gateway}<br />
<br />
ExecStop=/usr/bin/ip addr flush dev %i<br />
ExecStop=/usr/bin/ip link set dev %i down<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
啟用該 unit 並將其啟動,傳入介面名稱:<br />
<br />
# systemctl enable network@''介面名稱''.service<br />
# systemctl start network@''介面名稱''.service<br />
<br />
==== 計算位址 ====<br />
<br />
您可以使用 {{Pkg|ipcalc}} 提供的 {{ic|ipcalc}} 來計算 IP 廣播、網域、子網路遮罩與主機範圍等進階設定舉例來說,我使用了位於防火牆後的乙太網路來連線 Windows 機器至 Arch。為了安全性與網路組織,我將他們放置於各自獨立的網路,接著組態設定子網路遮罩與廣播位址,如此一來網路中就只有兩台機器。為了找出子網路遮罩跟廣播位址,我使用了 ipcalc ,提供其 Arch firewire nic 的 IP 位址 10.66.66.1 ,並指定 ipcalc 要建立一個只有兩台主機的網路。<br />
<br />
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|<nowiki><br />
Address: 10.66.66.1<br />
<br />
Netmask: 255.255.255.252 = 30<br />
Network: 10.66.66.0/30<br />
HostMin: 10.66.66.1<br />
HostMax: 10.66.66.2<br />
Broadcast: 10.66.66.3<br />
Hosts/Net: 2 Class A, Private Internet<br />
</nowiki>}}<br />
<br />
== 載入組態設定 ==<br />
<br />
要測試您的設定,您可以重新啟動電腦或是重新載入相關的 systemd 服務。Then try pinging your gateway, DNS server, ISP provider and other Internet sites, in that order, to detect any connection problems along the way, as in this example:<br />
<br />
$ ping -c 3 www.google.com<br />
<br />
== 附加設定 ==<br />
<br />
=== 筆記型電腦之 ifplugd ===<br />
<br />
{{提示|[[dhcpcd]] 提供了開箱即用的相同功能。}}<br />
<br />
[[Official Repositories (正體中文)|官方軟體套件庫]]中的 {{Pkg|ifplugd}} 為一個當網路線插入後自動組態乙太設備;網路線拔除後自動取消組態的 Daemon 。<br />
這對於搭載內建網路介面卡的筆記型電腦特別有用,因為其只會在網路線真正連上後才會對介面進行組態。另一個會用到的情況為,當您需要重新啟動網路,但您並不想重開及或在 Shell 中進行設定。<br />
<br />
預設情況下,其會對 {{ic|eth0}} 裝置進行設定使其運作。這與其他設定類似延遲之類的設定能在 {{ic|/etc/ifplugd/ifplugd.conf}} 中進行設定。<br />
<br />
<br />
{{註記|[[Netctl]] 軟體包包含了 {{ic|netctl-ifplugd@.service}},否則您可以使用來自 {{Pkg|ifplugd}} 軟體包的 {{ic|ifplugd@.service}} 。例如這樣使用:{{ic|systemctl enable ifplugd@eth0.service}}。}}<br />
<br />
=== Bonding 或 LAG ===<br />
<br />
請參閱 [[netctl#Bonding]] 。<br />
<br />
=== IP 別名 ===<br />
<br />
{{Expansion|Manual method using [[Core Utilities#ip|ip]] should be added; then move current example using ''netctl'' into [[netctl]].}}<br />
<br />
IP 別名為讓同一個網路介面有多個 IP 位址。如此一來,單個節點的網路就能有多個網路連線,進而實現不同的作用。經典的使用方法為網頁與 FTP 伺服器的虛擬主機,或是重組伺服器而無需更新任何其他的機器(對於名稱伺服器來說特別有用)。<br />
<br />
==== 範例 ====<br />
<br />
您將需要來自[[Official Repositories (正體中文)|官方軟體套件庫]]的 {{Pkg|netctl}} 。<br />
<br />
準備組態設定檔:<br />
<br />
{{hc|/etc/netctl/mynetwork|<nowiki><br />
Connection='ethernet'<br />
Description='Five different addresses on the same NIC.'<br />
Interface='eth0'<br />
IP='static'<br />
Address=('192.168.1.10' '192.168.178.11' '192.168.1.12' '192.168.1.13' '192.168.1.14' '192.168.1.15')<br />
Gateway='192.168.1.1'<br />
DNS=('192.168.1.1')<br />
</nowiki>}}<br />
<br />
接著只需要將其執行即可:<br />
<br />
$ netctl start mynetwork<br />
<br />
=== 更改 MAC/硬體 位址 ===<br />
<br />
請參閱 [[MAC Address Spoofing]] 。<br />
<br />
=== 網路共享 ===<br />
<br />
請參閱 [[Internet Sharing]] 。<br />
<br />
=== 路由組態設定 ===<br />
<br />
請參閱 [[Router]] 。<br />
<br />
=== 區域網路主機名稱解析 ===<br />
<br />
先決條件為[[#.E8.A8.AD.E5.AE.9A.E4.B8.BB.E6.A9.9F.E5.90.8D.E7.A8.B1|設定主機名稱]]之後,主機名稱可在本機系統上解析:<br />
{{hc|$ ping hostname|<br />
PING hostname <nowiki>(192.168.1.2) 56(84) bytes of data.<br />
64 bytes from hostname (192.168.1.2): icmp_seq=1 ttl=64 time=0.043 ms</nowiki>}}<br />
要以其他機器的名稱來解析主機,需要手動設定各自的 {{ic|/etc/hosts}} 檔案或是廣播/解析名稱的服務。<br />
<br />
過度設定 DNS 伺服器,如 [[BIND]] 、 [[Unbound]] ,手動編輯 {{ic|/etc/hosts}} 過於繁瑣,或是您希望對於動態地將主機離開、加入網路有更大的靈活性,您可以在您的區域網路中使用 Zero-configuration networking 來進行主機名稱解析。這裡有兩個可用選擇:<br />
<br />
*[[Samba]] 提供了通過微軟 '''NetBIOS''' 的主機名稱解析。其只需要安裝 {{Pkg|samba}} 並啟用 {{ic|nmbd.service}} 服務。執行 Windows 、OS X 或執行了 {{ic|nmbd}} 的 Linux ,將能夠找到您的機器。<br />
<br />
*[[Avahi]] 提供通過 '''zeroconf''' 的主機名稱解析,也稱作 Avahi 或 Boujour 。它比 Samba 還需要稍微複雜一點的設定:詳情請參考 [[Avahi#Hostname resolution]]。執行 OS X 或執行了 Avahi daemon 的 Linux ,將能夠找到您的機器。Windows 並無內建 Avahi 用戶端或 Daemon 。<br />
<br />
== 診斷 ==<br />
<br />
=== Swapping computers on the cable modem ===<br />
<br />
Some cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.<br />
<br />
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].<br />
<br />
=== The TCP window scaling problem ===<br />
<br />
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.<br />
<br />
Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html RFC 1323] was written to improve the situation: Window Scaling. The "window" value, provided in all packets, will be modified by a Scale Factor defined once, at the very beginning of the connection.<br />
<br />
That 8-bit Scale Factor allows the Window to be up to 32 times higher than the initial 64Kb.<br />
<br />
It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts.<br />
<br />
The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.<br />
<br />
The resulting connection is at best very slow or broken.<br />
<br />
==== How to diagnose the problem ====<br />
<br />
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).<br />
<br />
When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|ip addr}} will report normal status... and actually everything appears normal.<br />
<br />
If you cannot browse any website, but you can ping some random hosts, chances are great that you're experiencing this problem: ping uses ICMP and is not affected by TCP problems.<br />
<br />
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).<br />
<br />
==== How to fix it (The bad way) ====<br />
<br />
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.<br />
<br />
# echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem<br />
<br />
==== How to fix it (The good way) ====<br />
<br />
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.d/99-disable_window_scaling.conf}} (see also [[sysctl]])<br />
<br />
net.ipv4.tcp_window_scaling = 0<br />
<br />
==== How to fix it (The best way) ====<br />
<br />
This problem is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.<br />
<br />
==== More about it ====<br />
<br />
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].<br />
<br />
There are also several relevant threads on the LKML.<br />
<br />
=== Realtek no link / WOL problem ===<br />
<br />
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice a problem where the NIC seems to be disabled on boot and has no Link light. This can usually be found on a dual boot system where Windows is also installed. It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause. These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots. You will be able to notice if this problem is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off. Normal operation should be that the link light is always on as long as the system is on, even during POST. This problem will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this problem:<br />
<br />
==== Method 1 - Rollback/change Windows driver ====<br />
<br />
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).<br />
<br />
==== Method 2 - Enable WOL in Windows driver ====<br />
<br />
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems). In Windows, under Device Manager, find your Realtek network adapter and double-click it. Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.<br />
<br />
In Windows XP (example)<br />
Right click my computer<br />
--> Hardware tab<br />
--> Device Manager<br />
--> Network Adapters<br />
--> "double click" Realtek ...<br />
--> Advanced tab<br />
--> Wake-On-Lan After Shutdown<br />
--> Enable<br />
<br />
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{ic|Disable}} has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.}}<br />
<br />
==== Method 3 - Newer Realtek Linux driver ====<br />
<br />
Any newer driver for these Realtek cards can be found for Linux on the realtek site. (untested but believed to also solve the problem).<br />
<br />
==== Method 4 - Enable ''LAN Boot ROM'' in BIOS/CMOS ====<br />
<br />
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.<br />
<br />
{{Note|This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.}}<br />
<br />
=== No eth0 with Atheros AR8161 ===<br />
<br />
{{Note|With the 3.10.2-1-ARCH kernel update, the alx ethernet driver module is included in the package.}}<br />
<br />
With the Atheros AR8161 Gigabit Ethernet card, the ethernet connection is not working out-of-the-box (with the installation media of March 2013). The module "alx" needs to be loaded but is not present.<br />
<br />
The driver from [http://linuxwireless.org/en/users/Download/stable/#compat-wireless_stable_releases compat-wireless] (that has become [https://backports.wiki.kernel.org/index.php/Releases compat-drives] since linux 3.7) need to be installed. The "-u" postfix annotates that Qualcomm have applied a driver under a unified driver.<br />
<br />
$ wget https://www.kernel.org/pub/linux/kernel/projects/backports/2013/03/28/compat-drivers-2013-03-28-5-u.tar.bz2<br />
$ tar xjf compat*<br />
$ cd compat*<br />
$ ./scripts/driver-select alx<br />
$ make<br />
$ sudo make install<br />
$ sudo modprobe alx<br />
<br />
The alx driver has not been added to Linux kernel due to various problems. Compatibility between the different kernel versions has been spotty. For better support follow the [http://lists.infradead.org/mailman/listinfo/unified-drivers mailing list]and [http://www.linuxfoundation.org/collaborate/workgroups/networking/alx alx page]for latest working solution for alx.<br />
<br />
The driver must be built and installed after every kernel change.<br />
<br />
Alternatively you can use the AUR package for [https://aur.archlinux.org/packages/compat-drivers-patched/ compat drivers], which installs many other drivers.<br />
<br />
=== No eth0 with Atheros AR9485 ===<br />
<br />
The ethernet (eth0) for Atheros AR9485 are not working out-of-the-box (with installation media of March 2013). The working solution for this is to install the package [https://aur.archlinux.org/packages/compat-drivers-patched/ compat-drivers-patched] from AUR.<br />
<br />
=== No carrier / no connection after suspend ===<br />
After suspend to RAM no connection is found although the network cable is plugged in. <br />
This may be caused by PCI power management. What is the output of<br />
<br />
# ip link show eth0<br />
<br />
If the line contains "NO-CARRIER" even though there's a cable connected to your eth0 port, it is possible that the device was auto-suspended and the media sense feature doesn't work. To solve this, first you need to find your ethernet controllers PCI address by<br />
<br />
# lspci<br />
<br />
This should look similar to this:<br />
<br />
...<br />
00:19.0 Ethernet controller: Intel Corporation 82577LM Gigabit Network Connection (rev 06)<br />
...<br />
<br />
So the address is 00:19.0.<br />
Now check the PM status of the device by issuing<br />
<br />
# cat "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
substituting 00:19.0 with the address obtained from lspci.<br />
If the output reads "auto", you can try to bring the device out of suspend by<br />
<br />
# echo on > "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
Don't forget to substitute the address again.<br />
<br />
{{Note|1=This appears to be a bug in kernel 3.8.4.1- (3.8.8.1 is still affected): [https://bbs.archlinux.org/viewtopic.php?id=159837&p=2 Forum discussion.] It also appears a fix is [https://lkml.org/lkml/2013/1/18/147 on the way. (It will be likely fixed in 3.9.)] In the meantime, the above is a suitable workaround.}}<br />
<br />
=== Broadcom BCM57780 ===<br />
<br />
This Broadcom chipset sometimes does not behave well unless you specify the order of the modules to be loaded. The modules are {{ic|broadcom}} and {{ic|tg3}}, the former needing to be loaded first.<br />
<br />
These steps should help if your computer has this chipset:<br />
$ lspci | grep Ethernet<br />
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)<br />
<br />
If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following (as root):<br />
# modprobe -r tg3<br />
# modprobe broadcom<br />
# modprobe tg3<br />
<br />
Now plug you network cable in. If this solves your problems you can make this permanent by adding {{ic|broadcom}} and {{ic|tg3}} (in this order) to the {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}}:<br />
<br />
MODULES=".. broadcom tg3 .."<br />
<br />
Then rebuild the initramfs:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|These methods may work for other chipsets, such as BCM57760.}}</div>Binotahttps://wiki.archlinux.org/index.php?title=Network_configuration_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=298926Network configuration (正體中文)2014-02-19T13:54:32Z<p>Binota: Update to Version 298590, but not translated in Chinese</p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:Networking (正體中文)]]<br />
[[Category:Getting and installing Arch (正體中文)]]<br />
[[cs:Configuring Network]]<br />
[[el:Configuring Network]]<br />
[[en:Configuring Network]]<br />
[[es:Configuring Network]]<br />
[[fr:Connexions reseau]]<br />
[[it:Configuring Network]]<br />
[[ja:Network Configuration]]<br />
[[nl:Configuring Network]]<br />
[[pt:Configuring Network]]<br />
[[ro:Configurare retea]]<br />
[[ru:Configuring Network]]<br />
[[sk:Configuring Network]]<br />
[[tr:Ağ_Yapılandırması]]<br />
[[zh-CN:Network Configuration]]<br />
{{Related articles start (正體中文)}}<br />
{{Related2|Jumbo Frames|巨型封包 (英)}}<br />
{{Related2|Firewalls|防火牆 (英)}}<br />
{{Related2|Wireless Setup|無線網路設定 (英)}}<br />
{{Related2|List of Applications#Network Managers|應用程式清單#網路管理員 (英)}}<br />
{{Related articles end}}<br />
{{TranslationStatus (正體中文)|Network_Configuration|2014-02-20|298590}}<br />
<br />
本頁將介紹如何設定'''有線'''網路連線。若您需要設定'''無線'''網路,請參考[[Wireless network configuration|無線網路設定]]。<br />
<br />
== 檢查連線 ==<br />
<br />
{{註記|若您在執行 ping 時收到了類似 {{ic|ping: icmp open socket: Operation not permitted}} 這樣的錯誤訊息,請嘗試重新安裝 {{ic|iputils}} 軟體包。}} <br />
<br />
一般來說,基本的安裝過程都已經建立了可運作的網路設定。請執行下列指令以進行檢查:<br />
<br />
{{註記|{{ic|-c 3}} 選項表示將會呼叫三次。詳細請參閱 {{ic|man ping}} 。}}<br />
{{提示|您也可以嘗試使用其他的 Domain ,如 www.hinet.net 。}}<br />
<br />
{{hc|$ ping -c 3 www.google.com|<nowiki><br />
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.<br />
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms<br />
64 bytes from 74.125.224.146: icmp_req=2 ttl=50 time=385 ms<br />
64 bytes from 74.125.224.146: icmp_req=3 ttl=50 time=298 ms<br />
<br />
--- www.l.google.com ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 1999ms<br />
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms<br />
</nowiki>}}<br />
<br />
如果沒問題的話,您可能只是想以本文的下列部分來自定您的設定。<br />
<br />
若剛才的指令出現了 unknown hosts 之類的訊息,代表您的機器無法解析網域。這可能是因為您的網路服務提供商/閘道造成的。您可以嘗試 ping 一個靜態 IP 以實驗您的機器能否存取網際網路。<br />
{{提示|您也可以嘗試使用其他的 IP ,如 168.95.1.1 。}}<br />
<br />
{{hc|$ ping -c 3 8.8.8.8|<nowiki><br />
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.<br />
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms<br />
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms<br />
64 bytes from 8.8.8.8: icmp_req=3 ttl=53 time=70.6 ms<br />
<br />
--- 8.8.8.8 ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 2002ms<br />
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms<br />
</nowiki>}}<br />
<br />
{{註記|{{ic|8.8.8.8}} 為一個好記的靜態 IP 位置。這是 Google 的主要 DNS 伺服器,這表示其有一定的可信度,並且通常不會被系統或代理伺服器擋下。}}<br />
<br />
若您可以 Ping 通 {{ic|8.8.8.8}} ,但 {{ic|www.google.com}} 不能,請檢查您的 DNS 組態設定檔。詳情請參考 [[resolv.conf]]。<br />
<br />
== 設定主機名稱 ==<br />
<br />
[[Wikipedia:Hostname|主機名稱]]為網路中用於識別機器的唯一識別名稱:主機名稱可以通過 {{ic|/etc/hostname}} 檔案來進行設定。一般來說該檔案包含了系統的網域名稱。下面為設定主機名稱的方法:<br />
<br />
# hostnamectl set-hostname '''myhostname'''<br />
<br />
這樣會將 {{ic|''myhostname''}} 寫入 {{ic|/etc/hostname}} 檔案中。<br />
<br />
詳細請參閱 {{ic|man 5 hostname}} 與 {{ic|man 1 hostnamectl}} 。<br />
<br />
{{註記|<br />
* {{ic|hostnamectl}} 支援 FQDN<br />
* 您不需要編輯 {{ic|/etc/hosts}} 檔案,{{pkg|systemd}} 會提供主機名稱解析且預設安裝於所有系統。<br />
}}<br />
<br />
使用來自 {{Pkg|inetutils}} 的 ''hostname'' 以設定臨時主機名稱(直到重新啟動):<br />
<br />
# hostname ''myhostname''<br />
<br />
== 裝置驅動程式 ==<br />
<br />
=== 檢查驅動程式狀態 ===<br />
<br />
[[udev]] 應該會檢測您的網路介面卡([[Wikipedia:Network_interface_controller|NIC]])並自動於啟動時載入必要的模組。檢查 {{ic|lspci -v}} 輸出內容中的「Ethernet controller」 項目(或類似的)。這應該會告訴您哪些核心模組包含了網路設備的驅動程式。舉例來說:<br />
<br />
{{hc|$ lspci -v|<br />
02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)<br />
...<br />
Kernel driver in use: atl1<br />
Kernel modules: atl1<br />
}}<br />
<br />
接下來,確認該驅動程式已經通過 {{ic|dmesg <nowiki>|</nowiki> grep ''module_name''}} 載入了。舉例來說:<br />
<br />
$ dmesg | grep atl1<br />
...<br />
atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex<br />
<br />
若驅動程式已成功加載可以跳過接下來這段。否則,您會需要知道哪些模組時您的特定型號的裝置需要哪個模組。<br />
<br />
=== 載入裝置模組 ===<br />
<br />
以 Google 搜尋正確的晶片組模組/驅動程式。常見的驅動模組有 Realtek 晶片組網卡的 {{ic|8139too}} ,或是 SiS 晶片組網卡的 {{ic|sis900}}。當您知道要使用何種模組了之後,試著[[Kernel modules#Manual module handling|手動將其載入]]。若您得到了錯誤訊息告訴您找不到該模組,則該驅動可能未包含於 Arch 核心中。您可以在 [[AUR]] 中搜尋該模組名稱。<br />
<br />
若 udev 未在開機期間檢測與載入正確的模組,請參閱 [[Kernel modules#Loading]]。<br />
<br />
== 網路介面 ==<br />
<br />
=== 裝置名稱 ===<br />
<br />
對於多網路卡的電腦,固定裝置名稱非常重要。許多設定問題都是因為介面卡名稱的改動造成的。<br />
<br />
[[udev]] 負責命名裝置。Systemd v197 則有[http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames 可預測之網路介面名稱]並可自動支配靜態名稱給網路裝置。介面名稱以 {{ic|en}} (乙太網路)、 {{ic|wl}} (無線網路) 或是 {{ic|ww}} (WWAN)作為前置字串並附上一個自動產生的識別名稱,進而產生了類似 {{ic|enp0s25}} 這樣的名稱。 <br />
<br />
要禁用這種行為,可以加上一個連接:<br />
<br />
# ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules<br />
<br />
自早期版本升級 systemd 的使用者會有一自動建立的空規則檔案。因此,若您想使用一貫的裝置名稱,只需要刪除該檔案。<br />
<br />
{{提示|您可以執行 {{ic|ip link}} 或是 {{ic|ls /sys/class/net}} 以列出所有可用的介面。}}<br />
<br />
{{註記|當您更改了介面名稱規則後,別忘了更新所有跟網路有關的組態檔案與自定的 systemd unit 檔案以因應該更改。特別是當您啟用了 [[netctl#Basic method|netctl 靜態設定檔]] ,請執行 {{ic|netctl reenable ''profile''}} 以更新所有產生的服務檔案。}}<br />
<br />
==== 更改裝置名稱 ====<br />
<br />
您可以使用 udev-rule 來手動定義裝置名稱。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"<br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"<br />
</nowiki>}}<br />
<br />
請注意這兩點:<br />
<br />
* 使用這個指令以取得 MAC 位置:{{ic|cat /sys/class/net/''device_name''/address}}。<br />
* 請確定 udev 規則中使用的是小寫的十六進位數值而不是大寫。<br />
<br />
若您的網路卡為動態 MAC ,您可以使用 DEVPATH ,例如:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"<br />
</nowiki>}}<br />
<br />
{{註記|當使用了靜態的名稱時,'''應該要避免使用類似 "eth''X''" 與 "wlan''X''"''' 這樣的名稱,因為這可能會導致核心與 udev 在開機時發生衝突。而剛好相反地,最好使用核心預設不會使用的介面名稱,如 {{ic|net0}} 、 {{ic|net1}} 、 {{ic|wifi0}} 、 {{ic|wifi1}} 。詳細說明請參閱 [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames systemd] 文件。}}<br />
<br />
=== 設定裝置的 MTU 與佇列長度 ===<br />
<br />
您可以手動定義 udev 規則來更改裝置的 MTU 與佇列長度。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1480", ATTR{tx_queue_len}="2000"<br />
</nowiki>}}<br />
<br />
=== 取得目前的裝置名稱 ===<br />
<br />
目前的 NIC 名稱可以通過 sysfs 找到<br />
<br />
{{hc|$ ls /sys/class/net|<br />
lo eth0 eth1 firewire0<br />
}}<br />
<br />
=== 啟用與禁用網路介面 ===<br />
<br />
您可以使用下列指令來啟用或禁用網路介面:<br />
<br />
# ip link set eth0 up<br />
# ip link set eth0 down<br />
<br />
要確認結果,請執行:<br />
<br />
{{hc|$ ip link show dev eth0|<br />
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000<br />
...<br />
}}<br />
<br />
== 組態設定 IP 位址 ==<br />
<br />
您有兩個選擇:使用 [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]] 指派動態位址,或是使用「靜態」的位址。<br />
<br />
=== 動態 IP 位址 ===<br />
<br />
The easiest is to use [[dhcpcd]], which is included in the {{Grp|base}} group. Either use the provided service file {{ic|dhcpcd@.service}}, passing the interface name as an argument, or start it manually by running {{ic|dhcpcd ''interface''}}.<br />
<br />
=== 靜態 IP 位址 ===<br />
<br />
您可能因為各種原因而希望在您的網路中指派靜態 IP 位址,例如靜態的位址可以獲得一定程度的可預測性,或是您沒有可用的 DHCP 伺服器。<br />
<br />
{{註記|若您通過 Windows 機器來共享您的網路而不是使用路由器,請確保兩台電腦皆使用了靜態 IP 位址以避免區域網路問題。}}<br />
<br />
您需要:<br />
<br />
* 靜態 IP 位址<br />
* [[Wikipedia:Subnetwork|子網路遮罩]]<br />
* [[Wikipedia:Broadcast_address|廣播位址]]<br />
* [[Wikipedia:Default_gateway|預設閘道器]]的 IP 位址<br />
<br />
若您處在內部網路中,使用 192.168.*.* 這樣的 IP 位址較為安全,搭配其的子網路遮罩 255.255.255.0 ,廣播位址為 192.168.*.255 。而閘道通常是 192.168.*.1 或是 192.168.*.254 。<br />
<br />
{{Tip|You may need to manually set the DNS servers, see [[resolv.conf]] for details.}}<br />
<br />
==== 手動指派 ====<br />
<br />
您可於控制台中指派一靜態 IP 位址:<br />
<br />
# ip addr add <IP 位址>/<子網路遮罩> broadcast <廣播> dev <介面><br />
<br />
舉例來說:<br />
<br />
# ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev eth0<br />
<br />
{{註記|子網路遮罩使用了 [[Wikipedia:CIDR_notation|CIDR 表示法]](CIDR,Classless Inter-Domain Routing,無類別網路間路由)。}}<br />
<br />
詳情請參閱 {{ic|man ip}} 。<br />
<br />
以類似下列方法加上您的閘道:<br />
<br />
# ip route add default via <預設閘道 IP 位址><br />
<br />
舉例來說:<br />
<br />
# ip route add default via 192.168.1.1<br />
<br />
若您得到了 "No such process" 這樣的錯誤訊息,這代表您必須以 root 執行 {{ic|ip link set dev eth0 up}} 。<br />
<br />
==== 於啟動時通過 systemd 手動連線 ====<br />
<br />
First create a configuration file for the [[systemd]] service, replace {{ic|<interface>}} with the proper network interface name:<br />
<br />
{{hc|/etc/conf.d/network@<interface>|<nowiki><br />
address=192.168.0.15<br />
netmask=24<br />
broadcast=192.168.0.255<br />
gateway=192.168.0.1<br />
</nowiki>}}<br />
<br />
建立 systemd unit 檔案:<br />
<br />
{{hc|/etc/systemd/system/network@.service|<nowiki><br />
[Unit]<br />
Description=Network connectivity (%i)<br />
Wants=network.target<br />
Before=network.target<br />
BindsTo=sys-subsystem-net-devices-%i.device<br />
After=sys-subsystem-net-devices-%i.device<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
EnvironmentFile=/etc/conf.d/network@%i<br />
<br />
ExecStart=/usr/bin/ip link set dev %i up<br />
ExecStart=/usr/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i<br />
ExecStart=/usr/bin/ip route add default via ${gateway}<br />
<br />
ExecStop=/usr/bin/ip addr flush dev %i<br />
ExecStop=/usr/bin/ip link set dev %i down<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
啟用該 unit 並將其啟動,傳入介面名稱:<br />
<br />
# systemctl enable network@''介面名稱''.service<br />
# systemctl start network@''介面名稱''.service<br />
<br />
==== 計算位址 ====<br />
<br />
您可以使用 {{Pkg|ipcalc}} 提供的 {{ic|ipcalc}} 來計算 IP 廣播、網域、子網路遮罩與主機範圍等進階設定舉例來說,我使用了位於防火牆後的乙太網路來連線 Windows 機器至 Arch。為了安全性與網路組織,我將他們放置於各自獨立的網路,接著組態設定子網路遮罩與廣播位址,如此一來網路中就只有兩台機器。為了找出子網路遮罩跟廣播位址,我使用了 ipcalc ,提供其 Arch firewire nic 的 IP 位址 10.66.66.1 ,並指定 ipcalc 要建立一個只有兩台主機的網路。<br />
<br />
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|<nowiki><br />
Address: 10.66.66.1<br />
<br />
Netmask: 255.255.255.252 = 30<br />
Network: 10.66.66.0/30<br />
HostMin: 10.66.66.1<br />
HostMax: 10.66.66.2<br />
Broadcast: 10.66.66.3<br />
Hosts/Net: 2 Class A, Private Internet<br />
</nowiki>}}<br />
<br />
== 載入組態設定 ==<br />
<br />
要測試您的設定,您可以重新啟動電腦或是重新載入相關的 systemd 服務。Then try pinging your gateway, DNS server, ISP provider and other Internet sites, in that order, to detect any connection problems along the way, as in this example:<br />
<br />
$ ping -c 3 www.google.com<br />
<br />
== 附加設定 ==<br />
<br />
=== 筆記型電腦之 ifplugd ===<br />
<br />
{{提示|[[dhcpcd]] 提供了開箱即用的相同功能。}}<br />
<br />
[[Official Repositories (正體中文)|官方軟體套件庫]]中的 {{Pkg|ifplugd}} 為一個當網路線插入後自動組態乙太設備;網路線拔除後自動取消組態的 Daemon 。<br />
這對於搭載內建網路介面卡的筆記型電腦特別有用,因為其只會在網路線真正連上後才會對介面進行組態。另一個會用到的情況為,當您需要重新啟動網路,但您並不想重開及或在 Shell 中進行設定。<br />
<br />
預設情況下,其會對 {{ic|eth0}} 裝置進行設定使其運作。這與其他設定類似延遲之類的設定能在 {{ic|/etc/ifplugd/ifplugd.conf}} 中進行設定。<br />
<br />
<br />
{{註記|[[Netctl]] 軟體包包含了 {{ic|netctl-ifplugd@.service}},否則您可以使用來自 {{Pkg|ifplugd}} 軟體包的 {{ic|ifplugd@.service}} 。例如這樣使用:{{ic|systemctl enable ifplugd@eth0.service}}。}}<br />
<br />
=== Bonding 或 LAG ===<br />
<br />
請參閱 [[netctl#Bonding]] 。<br />
<br />
=== IP 別名 ===<br />
<br />
{{Expansion|Manual method using [[Core Utilities#ip|ip]] should be added; then move current example using ''netctl'' into [[netctl]].}}<br />
<br />
IP 別名為讓同一個網路介面有多個 IP 位址。如此一來,單個節點的網路就能有多個網路連線,進而實現不同的作用。經典的使用方法為網頁與 FTP 伺服器的虛擬主機,或是重組伺服器而無需更新任何其他的機器(對於名稱伺服器來說特別有用)。<br />
<br />
==== 範例 ====<br />
<br />
您將需要來自[[Official Repositories (正體中文)|官方軟體套件庫]]的 {{Pkg|netctl}} 。<br />
<br />
準備組態設定檔:<br />
<br />
{{hc|/etc/netctl/mynetwork|<nowiki><br />
Connection='ethernet'<br />
Description='Five different addresses on the same NIC.'<br />
Interface='eth0'<br />
IP='static'<br />
Address=('192.168.1.10' '192.168.178.11' '192.168.1.12' '192.168.1.13' '192.168.1.14' '192.168.1.15')<br />
Gateway='192.168.1.1'<br />
DNS=('192.168.1.1')<br />
</nowiki>}}<br />
<br />
接著只需要將其執行即可:<br />
<br />
$ netctl start mynetwork<br />
<br />
=== 更改 MAC/硬體 位址 ===<br />
<br />
請參閱 [[MAC Address Spoofing]] 。<br />
<br />
=== 網路共享 ===<br />
<br />
請參閱 [[Internet Sharing]] 。<br />
<br />
=== 路由組態設定 ===<br />
<br />
請參閱 [[Router]] 。<br />
<br />
=== 區域網路主機名稱解析 ===<br />
<br />
先決條件為[[#.E8.A8.AD.E5.AE.9A.E4.B8.BB.E6.A9.9F.E5.90.8D.E7.A8.B1|設定主機名稱]]之後,主機名稱可在本機系統上解析:<br />
{{hc|$ ping hostname|<br />
PING hostname <nowiki>(192.168.1.2) 56(84) bytes of data.<br />
64 bytes from hostname (192.168.1.2): icmp_seq=1 ttl=64 time=0.043 ms</nowiki>}}<br />
要以其他機器的名稱來解析主機,需要手動設定各自的 {{ic|/etc/hosts}} 檔案或是廣播/解析名稱的服務。<br />
<br />
過度設定 DNS 伺服器,如 [[BIND]] 、 [[Unbound]] ,手動編輯 {{ic|/etc/hosts}} 過於繁瑣,或是您希望對於動態地將主機離開、加入網路有更大的靈活性,您可以在您的區域網路中使用 Zero-configuration networking 來進行主機名稱解析。這裡有兩個可用選擇:<br />
<br />
*[[Samba]] 提供了通過微軟 '''NetBIOS''' 的主機名稱解析。其只需要安裝 {{Pkg|samba}} 並啟用 {{ic|nmbd.service}} 服務。執行 Windows 、OS X 或執行了 {{ic|nmbd}} 的 Linux ,將能夠找到您的機器。<br />
<br />
*[[Avahi]] 提供通過 '''zeroconf''' 的主機名稱解析,也稱作 Avahi 或 Boujour 。它比 Samba 還需要稍微複雜一點的設定:詳情請參考 [[Avahi#Hostname resolution]]。執行 OS X 或執行了 Avahi daemon 的 Linux ,將能夠找到您的機器。Windows 並無內建 Avahi 用戶端或 Daemon 。<br />
<br />
== 診斷 ==<br />
<br />
=== Swapping computers on the cable modem ===<br />
<br />
Some cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.<br />
<br />
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].<br />
<br />
=== The TCP window scaling problem ===<br />
<br />
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.<br />
<br />
Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html RFC 1323] was written to improve the situation: Window Scaling. The "window" value, provided in all packets, will be modified by a Scale Factor defined once, at the very beginning of the connection.<br />
<br />
That 8-bit Scale Factor allows the Window to be up to 32 times higher than the initial 64Kb.<br />
<br />
It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts.<br />
<br />
The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.<br />
<br />
The resulting connection is at best very slow or broken.<br />
<br />
==== How to diagnose the problem ====<br />
<br />
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).<br />
<br />
When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|ip addr}} will report normal status... and actually everything appears normal.<br />
<br />
If you cannot browse any website, but you can ping some random hosts, chances are great that you're experiencing this problem: ping uses ICMP and is not affected by TCP problems.<br />
<br />
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).<br />
<br />
==== How to fix it (The bad way) ====<br />
<br />
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.<br />
<br />
# echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem<br />
<br />
==== How to fix it (The good way) ====<br />
<br />
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.d/99-disable_window_scaling.conf}} (see also [[sysctl]])<br />
<br />
net.ipv4.tcp_window_scaling = 0<br />
<br />
==== How to fix it (The best way) ====<br />
<br />
This problem is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.<br />
<br />
==== More about it ====<br />
<br />
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].<br />
<br />
There are also several relevant threads on the LKML.<br />
<br />
=== Realtek no link / WOL problem ===<br />
<br />
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice a problem where the NIC seems to be disabled on boot and has no Link light. This can usually be found on a dual boot system where Windows is also installed. It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause. These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots. You will be able to notice if this problem is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off. Normal operation should be that the link light is always on as long as the system is on, even during POST. This problem will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this problem:<br />
<br />
==== Method 1 - Rollback/change Windows driver ====<br />
<br />
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).<br />
<br />
==== Method 2 - Enable WOL in Windows driver ====<br />
<br />
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems). In Windows, under Device Manager, find your Realtek network adapter and double-click it. Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.<br />
<br />
In Windows XP (example)<br />
Right click my computer<br />
--> Hardware tab<br />
--> Device Manager<br />
--> Network Adapters<br />
--> "double click" Realtek ...<br />
--> Advanced tab<br />
--> Wake-On-Lan After Shutdown<br />
--> Enable<br />
<br />
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{ic|Disable}} has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.}}<br />
<br />
==== Method 3 - Newer Realtek Linux driver ====<br />
<br />
Any newer driver for these Realtek cards can be found for Linux on the realtek site. (untested but believed to also solve the problem).<br />
<br />
==== Method 4 - Enable ''LAN Boot ROM'' in BIOS/CMOS ====<br />
<br />
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.<br />
<br />
{{Note|This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.}}<br />
<br />
=== No eth0 with Atheros AR8161 ===<br />
<br />
{{Note|With the 3.10.2-1-ARCH kernel update, the alx ethernet driver module is included in the package.}}<br />
<br />
With the Atheros AR8161 Gigabit Ethernet card, the ethernet connection is not working out-of-the-box (with the installation media of March 2013). The module "alx" needs to be loaded but is not present.<br />
<br />
The driver from [http://linuxwireless.org/en/users/Download/stable/#compat-wireless_stable_releases compat-wireless] (that has become [https://backports.wiki.kernel.org/index.php/Releases compat-drives] since linux 3.7) need to be installed. The "-u" postfix annotates that Qualcomm have applied a driver under a unified driver.<br />
<br />
$ wget https://www.kernel.org/pub/linux/kernel/projects/backports/2013/03/28/compat-drivers-2013-03-28-5-u.tar.bz2<br />
$ tar xjf compat*<br />
$ cd compat*<br />
$ ./scripts/driver-select alx<br />
$ make<br />
$ sudo make install<br />
$ sudo modprobe alx<br />
<br />
The alx driver has not been added to Linux kernel due to various problems. Compatibility between the different kernel versions has been spotty. For better support follow the [http://lists.infradead.org/mailman/listinfo/unified-drivers mailing list]and [http://www.linuxfoundation.org/collaborate/workgroups/networking/alx alx page]for latest working solution for alx.<br />
<br />
The driver must be built and installed after every kernel change.<br />
<br />
Alternatively you can use the AUR package for [https://aur.archlinux.org/packages/compat-drivers-patched/ compat drivers], which installs many other drivers.<br />
<br />
=== No eth0 with Atheros AR9485 ===<br />
<br />
The ethernet (eth0) for Atheros AR9485 are not working out-of-the-box (with installation media of March 2013). The working solution for this is to install the package [https://aur.archlinux.org/packages/compat-drivers-patched/ compat-drivers-patched] from AUR.<br />
<br />
=== No carrier / no connection after suspend ===<br />
After suspend to RAM no connection is found although the network cable is plugged in. <br />
This may be caused by PCI power management. What is the output of<br />
<br />
# ip link show eth0<br />
<br />
If the line contains "NO-CARRIER" even though there's a cable connected to your eth0 port, it is possible that the device was auto-suspended and the media sense feature doesn't work. To solve this, first you need to find your ethernet controllers PCI address by<br />
<br />
# lspci<br />
<br />
This should look similar to this:<br />
<br />
...<br />
00:19.0 Ethernet controller: Intel Corporation 82577LM Gigabit Network Connection (rev 06)<br />
...<br />
<br />
So the address is 00:19.0.<br />
Now check the PM status of the device by issuing<br />
<br />
# cat "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
substituting 00:19.0 with the address obtained from lspci.<br />
If the output reads "auto", you can try to bring the device out of suspend by<br />
<br />
# echo on > "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
Don't forget to substitute the address again.<br />
<br />
{{Note|1=This appears to be a bug in kernel 3.8.4.1- (3.8.8.1 is still affected): [https://bbs.archlinux.org/viewtopic.php?id=159837&p=2 Forum discussion.] It also appears a fix is [https://lkml.org/lkml/2013/1/18/147 on the way. (It will be likely fixed in 3.9.)] In the meantime, the above is a suitable workaround.}}<br />
<br />
=== Broadcom BCM57780 ===<br />
<br />
This Broadcom chipset sometimes does not behave well unless you specify the order of the modules to be loaded. The modules are {{ic|broadcom}} and {{ic|tg3}}, the former needing to be loaded first.<br />
<br />
These steps should help if your computer has this chipset:<br />
$ lspci | grep Ethernet<br />
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)<br />
<br />
If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following (as root):<br />
# modprobe -r tg3<br />
# modprobe broadcom<br />
# modprobe tg3<br />
<br />
Now plug you network cable in. If this solves your problems you can make this permanent by adding {{ic|broadcom}} and {{ic|tg3}} (in this order) to the {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}}:<br />
<br />
MODULES=".. broadcom tg3 .."<br />
<br />
Then rebuild the initramfs:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|These methods may work for other chipsets, such as BCM57760.}}</div>Binotahttps://wiki.archlinux.org/index.php?title=Template:Translateme_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=293583Template:Translateme (正體中文)2014-01-19T14:22:21Z<p>Binota: Created page with "<noinclude>zh-cn:Template:Translateme {{Template}} '''A "translation requested" flag used to indicate incomplete translations or to request assistance translating an arti..."</p>
<hr />
<div><noinclude>[[zh-cn:Template:Translateme]]<br />
{{Template}}<br />
<br />
'''A "translation requested" flag used to indicate incomplete translations or to request assistance translating an article.'''<br />
<br />
====Usage====<br />
<br />
This template should be added at the beginning of incomplete article translations. Please enter more detailed indications that could be useful to translators; consider expanding the description in the discussion page.<br />
<br />
{{bc|<nowiki>{{Translateme (正體中文)|reason}}</nowiki>}}<br />
<br />
You can override the default discussion page with a second optional argument:<br />
<br />
{{bc|<nowiki>{{Translateme (正體中文)|reason|Talk:Alternative Page}}</nowiki>}}<br />
<br />
Alternatively you can point to a specific section in the default talk page with the named {{ic|section}} parameter:<br />
<br />
{{bc|<nowiki>{{Translateme (正體中文)|reason|section=Section name}}</nowiki>}}<br />
<br />
See [[Template:Bad translation]] for outdated or inaccurate article translations.<br />
<br />
Flagged pages can be found in [[Special:WhatLinksHere/Template:Translateme]]. If familiar with the language, users are encouraged to participate to complete the translation. The {{ic|<nowiki>{{Translateme (正體中文)}}</nowiki>}} flag should be removed after the translation is completed.<br />
<br />
{{Note|The talk page is linked throgh an external link: this is to avoid polluting [[Special:WantedPages]] when the talk page doesn't exist.}}<br />
<br />
====Example====<br />
<br />
<nowiki>{{Translateme (正體中文)|This is just a demonstration template.}}</nowiki><br />
<br />
{{Translateme (正體中文)|This is just a demonstration template.}}</noinclude><includeonly>{{META Message<br />
|id = translateme<br />
|signal = [[Image:Tango-preferences-desktop-locale.png]]<br />
|heading = 本條目或段落需要進行[[ArchWiki:Contributing#Translating|翻譯]]。<br />
|message = '''註記: ''' {{{reason|{{{1|{{META Unexplained Status Template|2=more detailed indications}}}}}}}} ([{{fullurl:{{{talk|{{{2|{{TALKPAGENAME}}#{{{section|}}}}}}}}}}} 討論])}}</includeonly></div>Binotahttps://wiki.archlinux.org/index.php?title=Official_repositories_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=293582Official repositories (正體中文)2014-01-19T14:13:32Z<p>Binota: Add language link zh-TW.</p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:軟體套件包管理 (正體中文)]]<br />
[[Category:關於Arch (正體中文)]]<br />
[[cs:Official Repositories]]<br />
[[en:Official Repositories]]<br />
[[es:Official Repositories]]<br />
[[fr:Depots]]<br />
[[it:Official Repositories]]<br />
[[ja:Official Repositories]]<br />
[[nl:Official Repositories]]<br />
[[pt:Official Repositories]]<br />
[[ru:Official Repositories]]<br />
[[tr:Resmi_Depolar]]<br />
[[zh-CN:Official Repositories]]<br />
[[zh-TW:Official Repositories]]<br />
{{Article summary start}}<br />
{{Article summary text|軟體套件庫包含了開發者與可信使用者(TU)提供的軟體套件,通常我們可以通過 pacman 來安裝並使用他們。本文將介紹 Arch Linux 的各種軟體套件庫。}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Mirrors}}<br />
{{Article summary wiki|AUR}}<br />
{{Article summary wiki|Unofficial User Repositories}}<br />
{{Article summary end}}<br />
{{TranslationStatus (正體中文)|Official_Repositories|2014-01-19|286771}}<br />
<br />
[[Wikipedia:software repository|軟體套件庫]](在 Debian 生態圈的發行版中,又叫做「檔案庫」)是軟體套件存儲的地方。通常我們所說的軟體套件庫是指'''線上軟體套件庫''',亦即使用者從網際網路取得軟體的地方。Arch Linux [[Package Maintainer|軟體套件維護員]](包括開發人員以及[[Trusted Users|可信使用者]])對基本、常用或流行的軟體套件進行維護,使用者則可通過 [[pacman (正體中文)|pacman]] 軟體套件管理員安裝使用這些軟體。本文將帶您了解我們的官方軟體套件庫。<br />
<br />
= 歷史背景 =<br />
<br />
大部分的套件庫是因為歷史原因而分開的。一開始的時候,當本發行版只有少數使用者時,是只有一個軟體套件庫的,它就是現在的 [core] ──那時候它叫做 [official] 。這個倉庫主要存放了 Judd Vinet 選定的應用程式,當然現在已經不是這樣了:它被設計為只包含「每種類型」程式中的一個 ── 一個桌面環境、一個主瀏覽器等等。<br />
<br />
後來有使用者不滿 Judd 的選擇,由於 [[Arch Build System (正體中文)|ABS 系統]]使用簡單,所以他們就用 ABS 來建立自己的軟體套件。這些軟體套件被放入一個名為[unofficial] 的軟體套件庫,而這個套件庫由除 Judd 以外的開發人員進行維護。最終,新的套件庫獲得開發人員同樣的支持,所以就不再使用 [official] 和 [unofficial] 這兩個名稱了。大約在 0.5 版本的時候,兩個倉庫更名為 [current] 和 [extra] 。<br />
<br />
在 2007.8.1 版本發布之後,[current] 更名為 [core] ,以免讓人誤解它包含的內容。如今,這兩個套件庫在開發人員和社群眼中都是相同分量的。不過 [core] 還是有些不同的,主要區別在於安裝光碟和發布的快照中的軟體套件都只在 [core] 當中。這個倉庫可以實現一個完整的 Linux 系統,但並不一定是你想要的 Linux 系統。<br />
<br />
在 0.5 或者 0.6 版本的時候,套件庫中有大量的軟體套件沒有開發者願意去維護。於是一位開發人員(Xentac)建立了「可信使用者套件庫」(Trusted User Repositories),作為存放被信任的使用者(TU)自行建立的軟體套件的套件庫。[staging] 倉庫裡的軟體套件可被 Arch Linux 的開發人員選拔入官方倉庫,不過除此之外,開發人員和可信使用者或多或少還是有所不同的。<br />
<br />
就這樣過了一段時間,逐漸的可信使用者對他們的軟體倉庫感到厭倦,而非可信使用者又期望可以將自己的軟體套件與大家分享。這導致了[[AUR|AUR]]的出現。慢慢的,TU 們形成更為嚴密的組織,如今他們共同維護 [community] 軟體倉庫。TU 是一個獨立於 Arch Linux 開發人員之外的組織,兩者並沒太多交流。不過,熱門的軟體套件仍然會偶爾從[community] 選拔入 [extra]。[https://aur.archlinux.org/ AUR] 也支持允許非可信使用者送出 PKGBUILD 給其他使用者自願地使用。這些軟體套件不提供技術支持,所以 [[AUR|AUR]] 有時候被稱為 [unsupported] 倉庫。因為沒有發布可執行套件,unsupported 並不算是真正的軟體套件庫。如果 [[AUR|AUR]] 的某些軟體套件被 TU 認為熱門或是有興趣維護它, TU 可以自行決定從 unsupported 裡接納某些軟體套件包進入 [community]。<br />
<br />
2006 年,[core] 倉庫裡未被正確編譯的核心 [https://www.archlinux.org/news/please-avoid-kernel-261614-1/ 導致許多使用者系統當機]。之後,「core 套件庫審核機制」引入:所有 [core] 倉庫軟體套件包更新前,必須先在一個叫做 [testing] 的倉庫進行測試,必須在其他開發者同意後,軟體套件包才能正式移入 [core]。後來,[core] 中出現一些低使用率的軟體,審核機制對它們有所寬鬆。<br />
<br />
2009 年末至 2010 年初,出現了一些新的檔案系統,人們希望在安裝系統時就使用它們(即納入 [core] )。鑒於 [core] 從來沒有給出明確的界定(只是說「重要的軟體套件包,由開發者挑選」),人們決定給它一個更為明確的定義(參見下文)。<br />
<br />
= 軟體套件庫列表 =<br />
<br />
== [core] ==<br />
<br />
[core] 套件庫位於 Arch 鏡像的 ''core/os/i686'' 或 ''core/os/x86_64'' 目錄中。<br />
<br />
該套件庫對套件的質量有嚴格的要求:<br />
* 軟體套件更新需要經過開發者和使用者的審察批准。<br />
* 對於低使用率的軟體,公布合理的更新緣由(例如:發布通知、請求審核、在 [testing] 倉庫審核幾天到幾週不等),後經開發者簡單的審核即可。<br />
<br />
該倉庫包含下列軟體套件包:<br />
<br />
* 啟動 Arch 系統所必需的。<br />
* 連線至網際網路時可能需要的。<br />
* 編譯軟體套件時需要的。<br />
* 檢查、修復檔案系統的工具。<br />
* 在安裝過程中可能用到的(例如 openssh)。<br />
* 同上述軟體套件包的執行有依存關係的。<br />
<br />
''核心系統安裝光碟中包含這些軟體套件包,通過安裝光碟,你可以離線安裝基本系統。''<br />
<br />
== [extra] ==<br />
<br />
[extra] 套件庫位於 Arch 鏡像的 ''extra/os/i686'' 或 ''extra/os/x86_64'' 目錄中。它包含不適合 [core] 套件庫標準的大量軟體套件,如:Xorg,視窗管理員,網頁瀏覽器,媒體播放器,Script 語言支援等等。<br />
<br />
== [community] ==<br />
<br />
[community] 套件庫位於 Arch 鏡像的 ''community/os/i686'' 或 ''community/os/x86_64'' 目錄中。它由 ''可信使用者(TU)'' 維護,包含由 TU 認證、獲得足夠多評分的 [[AUR|AUR]] 軟體套件包。嚴格來講,它是 [[AUR|AUR]] 的一部分。<br />
<br />
== [multilib] ==<br />
<br />
[community] 套件庫位於 Arch 鏡像的 ''multilib/os/x86_64'' 目錄中。包含 64 位元系統中需要的 32 位元軟體和套件庫,如:Flash 外掛程式、Skype 。<br />
<br />
== [testing] ==<br />
<br />
[testing] 套件庫位於 Arch 鏡像的 ''testing/os/i686'' 或 ''testing/os/x86_64'' 目錄中。[testing] 套件庫很特別,它包含即將進入 [core]、[extra] 軟體套件庫的候選軟體套件。<br />
<br />
下列軟體套件會進入 [testing] 套件庫:<br />
* 更新該軟體套件可能損壞系統,需要進行測試。<br />
* 更新該軟體套件,可能需要其他相關軟體套件的重建,軟體套件在 [testing] 套件庫中等候全部相關軟體套件準備到位。 <br />
<br />
[testing] 套件庫是唯一可能和其它官方軟體套件庫有軟體套件名稱沖突的套件庫。如果要啟用,應該在''pacman.conf''檔案中將其設為第一個套件庫。<br />
<br />
{{警告|謹慎啟用 [testing] 套件庫,其中的軟體套件可能損壞系統。僅當你有足夠的經驗應對問題時,再考慮啟用。}}<br />
<br />
[testing] 套件庫並不是「最新」軟體套件包的倉庫,而是為軟體套件提供「測試」的地方。我們建議使用 [testing] 套件庫的使用者訂閱 arch-dev-public 郵件列表,並在 Bug Tracker 中彙報 Bug。<br />
<br />
== [community-testing] ==<br />
<br />
[community-testing] 套件庫的功能類似 [testing],不過是為 [community] 套件庫設計的測試套件庫。<br />
<br />
== [unsupported],即 AUR ==<br />
<br />
[unsupported],即我們所熟知的 [[AUR|AUR]]。在這個套件庫中,使用者可以自行送出軟體套件(通常以[[PKGBUILD (正體中文)|PKGBUILD]]的形式,而非可執行套件)。無法以 pacman 使用這個套件庫,下載 [[PKGBUILD (正體中文)|PKGBUILD]] 以及相關文件後,需要自行通過 [[makepkg]] 編譯軟體套件。諸如 [[yaourt_(正體中文)|yaourt]] 之類的 [[AUR Helpers]] 是使用者使用 [[AUR|AUR]] 的好工具。<br />
<br />
{{註記|嚴格來說,[[AUR|AUR]] 是由 [community] 和 [unsupported] 一同組成的。}}<br />
<br />
== 非官方使用者套件庫 ==<br />
<br />
一些使用者組建了自己的軟體倉庫,參見[[Unofficial User Repositories|非官方使用者套件庫]]。</div>Binotahttps://wiki.archlinux.org/index.php?title=Official_repositories_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=293581Official repositories (正體中文)2014-01-19T14:12:50Z<p>Binota: Change some link to language zh_TW.</p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:軟體套件包管理 (正體中文)]]<br />
[[Category:關於Arch (正體中文)]]<br />
[[cs:Official Repositories]]<br />
[[en:Official Repositories]]<br />
[[es:Official Repositories]]<br />
[[fr:Depots]]<br />
[[it:Official Repositories]]<br />
[[ja:Official Repositories]]<br />
[[nl:Official Repositories]]<br />
[[pt:Official Repositories]]<br />
[[ru:Official Repositories]]<br />
[[tr:Resmi_Depolar]]<br />
[[zh-CN:Official Repositories]]<br />
{{Article summary start}}<br />
{{Article summary text|軟體套件庫包含了開發者與可信使用者(TU)提供的軟體套件,通常我們可以通過 pacman 來安裝並使用他們。本文將介紹 Arch Linux 的各種軟體套件庫。}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Mirrors}}<br />
{{Article summary wiki|AUR}}<br />
{{Article summary wiki|Unofficial User Repositories}}<br />
{{Article summary end}}<br />
{{TranslationStatus (正體中文)|Official_Repositories|2014-01-19|286771}}<br />
<br />
[[Wikipedia:software repository|軟體套件庫]](在 Debian 生態圈的發行版中,又叫做「檔案庫」)是軟體套件存儲的地方。通常我們所說的軟體套件庫是指'''線上軟體套件庫''',亦即使用者從網際網路取得軟體的地方。Arch Linux [[Package Maintainer|軟體套件維護員]](包括開發人員以及[[Trusted Users|可信使用者]])對基本、常用或流行的軟體套件進行維護,使用者則可通過 [[pacman (正體中文)|pacman]] 軟體套件管理員安裝使用這些軟體。本文將帶您了解我們的官方軟體套件庫。<br />
<br />
= 歷史背景 =<br />
<br />
大部分的套件庫是因為歷史原因而分開的。一開始的時候,當本發行版只有少數使用者時,是只有一個軟體套件庫的,它就是現在的 [core] ──那時候它叫做 [official] 。這個倉庫主要存放了 Judd Vinet 選定的應用程式,當然現在已經不是這樣了:它被設計為只包含「每種類型」程式中的一個 ── 一個桌面環境、一個主瀏覽器等等。<br />
<br />
後來有使用者不滿 Judd 的選擇,由於 [[Arch Build System (正體中文)|ABS 系統]]使用簡單,所以他們就用 ABS 來建立自己的軟體套件。這些軟體套件被放入一個名為[unofficial] 的軟體套件庫,而這個套件庫由除 Judd 以外的開發人員進行維護。最終,新的套件庫獲得開發人員同樣的支持,所以就不再使用 [official] 和 [unofficial] 這兩個名稱了。大約在 0.5 版本的時候,兩個倉庫更名為 [current] 和 [extra] 。<br />
<br />
在 2007.8.1 版本發布之後,[current] 更名為 [core] ,以免讓人誤解它包含的內容。如今,這兩個套件庫在開發人員和社群眼中都是相同分量的。不過 [core] 還是有些不同的,主要區別在於安裝光碟和發布的快照中的軟體套件都只在 [core] 當中。這個倉庫可以實現一個完整的 Linux 系統,但並不一定是你想要的 Linux 系統。<br />
<br />
在 0.5 或者 0.6 版本的時候,套件庫中有大量的軟體套件沒有開發者願意去維護。於是一位開發人員(Xentac)建立了「可信使用者套件庫」(Trusted User Repositories),作為存放被信任的使用者(TU)自行建立的軟體套件的套件庫。[staging] 倉庫裡的軟體套件可被 Arch Linux 的開發人員選拔入官方倉庫,不過除此之外,開發人員和可信使用者或多或少還是有所不同的。<br />
<br />
就這樣過了一段時間,逐漸的可信使用者對他們的軟體倉庫感到厭倦,而非可信使用者又期望可以將自己的軟體套件與大家分享。這導致了[[AUR|AUR]]的出現。慢慢的,TU 們形成更為嚴密的組織,如今他們共同維護 [community] 軟體倉庫。TU 是一個獨立於 Arch Linux 開發人員之外的組織,兩者並沒太多交流。不過,熱門的軟體套件仍然會偶爾從[community] 選拔入 [extra]。[https://aur.archlinux.org/ AUR] 也支持允許非可信使用者送出 PKGBUILD 給其他使用者自願地使用。這些軟體套件不提供技術支持,所以 [[AUR|AUR]] 有時候被稱為 [unsupported] 倉庫。因為沒有發布可執行套件,unsupported 並不算是真正的軟體套件庫。如果 [[AUR|AUR]] 的某些軟體套件被 TU 認為熱門或是有興趣維護它, TU 可以自行決定從 unsupported 裡接納某些軟體套件包進入 [community]。<br />
<br />
2006 年,[core] 倉庫裡未被正確編譯的核心 [https://www.archlinux.org/news/please-avoid-kernel-261614-1/ 導致許多使用者系統當機]。之後,「core 套件庫審核機制」引入:所有 [core] 倉庫軟體套件包更新前,必須先在一個叫做 [testing] 的倉庫進行測試,必須在其他開發者同意後,軟體套件包才能正式移入 [core]。後來,[core] 中出現一些低使用率的軟體,審核機制對它們有所寬鬆。<br />
<br />
2009 年末至 2010 年初,出現了一些新的檔案系統,人們希望在安裝系統時就使用它們(即納入 [core] )。鑒於 [core] 從來沒有給出明確的界定(只是說「重要的軟體套件包,由開發者挑選」),人們決定給它一個更為明確的定義(參見下文)。<br />
<br />
= 軟體套件庫列表 =<br />
<br />
== [core] ==<br />
<br />
[core] 套件庫位於 Arch 鏡像的 ''core/os/i686'' 或 ''core/os/x86_64'' 目錄中。<br />
<br />
該套件庫對套件的質量有嚴格的要求:<br />
* 軟體套件更新需要經過開發者和使用者的審察批准。<br />
* 對於低使用率的軟體,公布合理的更新緣由(例如:發布通知、請求審核、在 [testing] 倉庫審核幾天到幾週不等),後經開發者簡單的審核即可。<br />
<br />
該倉庫包含下列軟體套件包:<br />
<br />
* 啟動 Arch 系統所必需的。<br />
* 連線至網際網路時可能需要的。<br />
* 編譯軟體套件時需要的。<br />
* 檢查、修復檔案系統的工具。<br />
* 在安裝過程中可能用到的(例如 openssh)。<br />
* 同上述軟體套件包的執行有依存關係的。<br />
<br />
''核心系統安裝光碟中包含這些軟體套件包,通過安裝光碟,你可以離線安裝基本系統。''<br />
<br />
== [extra] ==<br />
<br />
[extra] 套件庫位於 Arch 鏡像的 ''extra/os/i686'' 或 ''extra/os/x86_64'' 目錄中。它包含不適合 [core] 套件庫標準的大量軟體套件,如:Xorg,視窗管理員,網頁瀏覽器,媒體播放器,Script 語言支援等等。<br />
<br />
== [community] ==<br />
<br />
[community] 套件庫位於 Arch 鏡像的 ''community/os/i686'' 或 ''community/os/x86_64'' 目錄中。它由 ''可信使用者(TU)'' 維護,包含由 TU 認證、獲得足夠多評分的 [[AUR|AUR]] 軟體套件包。嚴格來講,它是 [[AUR|AUR]] 的一部分。<br />
<br />
== [multilib] ==<br />
<br />
[community] 套件庫位於 Arch 鏡像的 ''multilib/os/x86_64'' 目錄中。包含 64 位元系統中需要的 32 位元軟體和套件庫,如:Flash 外掛程式、Skype 。<br />
<br />
== [testing] ==<br />
<br />
[testing] 套件庫位於 Arch 鏡像的 ''testing/os/i686'' 或 ''testing/os/x86_64'' 目錄中。[testing] 套件庫很特別,它包含即將進入 [core]、[extra] 軟體套件庫的候選軟體套件。<br />
<br />
下列軟體套件會進入 [testing] 套件庫:<br />
* 更新該軟體套件可能損壞系統,需要進行測試。<br />
* 更新該軟體套件,可能需要其他相關軟體套件的重建,軟體套件在 [testing] 套件庫中等候全部相關軟體套件準備到位。 <br />
<br />
[testing] 套件庫是唯一可能和其它官方軟體套件庫有軟體套件名稱沖突的套件庫。如果要啟用,應該在''pacman.conf''檔案中將其設為第一個套件庫。<br />
<br />
{{警告|謹慎啟用 [testing] 套件庫,其中的軟體套件可能損壞系統。僅當你有足夠的經驗應對問題時,再考慮啟用。}}<br />
<br />
[testing] 套件庫並不是「最新」軟體套件包的倉庫,而是為軟體套件提供「測試」的地方。我們建議使用 [testing] 套件庫的使用者訂閱 arch-dev-public 郵件列表,並在 Bug Tracker 中彙報 Bug。<br />
<br />
== [community-testing] ==<br />
<br />
[community-testing] 套件庫的功能類似 [testing],不過是為 [community] 套件庫設計的測試套件庫。<br />
<br />
== [unsupported],即 AUR ==<br />
<br />
[unsupported],即我們所熟知的 [[AUR|AUR]]。在這個套件庫中,使用者可以自行送出軟體套件(通常以[[PKGBUILD (正體中文)|PKGBUILD]]的形式,而非可執行套件)。無法以 pacman 使用這個套件庫,下載 [[PKGBUILD (正體中文)|PKGBUILD]] 以及相關文件後,需要自行通過 [[makepkg]] 編譯軟體套件。諸如 [[yaourt_(正體中文)|yaourt]] 之類的 [[AUR Helpers]] 是使用者使用 [[AUR|AUR]] 的好工具。<br />
<br />
{{註記|嚴格來說,[[AUR|AUR]] 是由 [community] 和 [unsupported] 一同組成的。}}<br />
<br />
== 非官方使用者套件庫 ==<br />
<br />
一些使用者組建了自己的軟體倉庫,參見[[Unofficial User Repositories|非官方使用者套件庫]]。</div>Binotahttps://wiki.archlinux.org/index.php?title=Official_repositories_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=293580Official repositories (正體中文)2014-01-19T14:06:15Z<p>Binota: Add Translation Status</p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:軟體套件包管理 (正體中文)]]<br />
[[Category:關於Arch (正體中文)]]<br />
[[cs:Official Repositories]]<br />
[[en:Official Repositories]]<br />
[[es:Official Repositories]]<br />
[[fr:Depots]]<br />
[[it:Official Repositories]]<br />
[[ja:Official Repositories]]<br />
[[nl:Official Repositories]]<br />
[[pt:Official Repositories]]<br />
[[ru:Official Repositories]]<br />
[[tr:Resmi_Depolar]]<br />
[[zh-CN:Official Repositories]]<br />
{{Article summary start}}<br />
{{Article summary text|軟體套件庫包含了開發者與可信使用者(TU)提供的軟體套件,通常我們可以通過 pacman 來安裝並使用他們。本文將介紹 Arch Linux 的各種軟體套件庫。}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Mirrors}}<br />
{{Article summary wiki|AUR}}<br />
{{Article summary wiki|Unofficial User Repositories}}<br />
{{Article summary end}}<br />
{{TranslationStatus (正體中文)|Official_Repositories|2014-01-19|286771}}<br />
<br />
[[Wikipedia:software repository|軟體套件庫]](在 Debian 生態圈的發行版中,又叫做「檔案庫」)是軟體套件存儲的地方。通常我們所說的軟體套件庫是指'''線上軟體套件庫''',亦即使用者從網際網路取得軟體的地方。Arch Linux [[Package Maintainer|軟體套件維護員]](包括開發人員以及[[Trusted Users|可信使用者]])對基本、常用或流行的軟體套件進行維護,使用者則可通過 [[pacman]] 軟體套件管理員安裝使用這些軟體。本文將帶您了解我們的官方軟體套件庫。<br />
<br />
= 歷史背景 =<br />
<br />
大部分的套件庫是因為歷史原因而分開的。一開始的時候,當本發行版只有少數使用者時,是只有一個軟體套件庫的,它就是現在的 [core] ──那時候它叫做 [official] 。這個倉庫主要存放了 Judd Vinet 選定的應用程式,當然現在已經不是這樣了:它被設計為只包含「每種類型」程式中的一個 ── 一個桌面環境、一個主瀏覽器等等。<br />
<br />
後來有使用者不滿 Judd 的選擇,由於 [[Arch Build System|ABS 系統]]使用簡單,所以他們就用 ABS 來建立自己的軟體套件。這些軟體套件被放入一個名為[unofficial] 的軟體套件庫,而這個套件庫由除 Judd 以外的開發人員進行維護。最終,新的套件庫獲得開發人員同樣的支持,所以就不再使用 [official] 和 [unofficial] 這兩個名稱了。大約在 0.5 版本的時候,兩個倉庫更名為 [current] 和 [extra] 。<br />
<br />
在 2007.8.1 版本發布之後,[current] 更名為 [core] ,以免讓人誤解它包含的內容。如今,這兩個套件庫在開發人員和社群眼中都是相同分量的。不過 [core] 還是有些不同的,主要區別在於安裝光碟和發布的快照中的軟體套件都只在 [core] 當中。這個倉庫可以實現一個完整的 Linux 系統,但並不一定是你想要的 Linux 系統。<br />
<br />
在 0.5 或者 0.6 版本的時候,套件庫中有大量的軟體套件沒有開發者願意去維護。於是一位開發人員(Xentac)建立了「可信使用者套件庫」(Trusted User Repositories),作為存放被信任的使用者(TU)自行建立的軟體套件的套件庫。[staging] 倉庫裡的軟體套件可被 Arch Linux 的開發人員選拔入官方倉庫,不過除此之外,開發人員和可信使用者或多或少還是有所不同的。<br />
<br />
就這樣過了一段時間,逐漸的可信使用者對他們的軟體倉庫感到厭倦,而非可信使用者又期望可以將自己的軟體套件與大家分享。這導致了[[AUR|AUR]]的出現。慢慢的,TU 們形成更為嚴密的組織,如今他們共同維護 [community] 軟體倉庫。TU 是一個獨立於 Arch Linux 開發人員之外的組織,兩者並沒太多交流。不過,熱門的軟體套件仍然會偶爾從[community] 選拔入 [extra]。[https://aur.archlinux.org/ AUR] 也支持允許非可信使用者送出 PKGBUILD 給其他使用者自願地使用。這些軟體套件不提供技術支持,所以 [[AUR|AUR]] 有時候被稱為 [unsupported] 倉庫。因為沒有發布可執行套件,unsupported 並不算是真正的軟體套件庫。如果 [[AUR|AUR]] 的某些軟體套件被 TU 認為熱門或是有興趣維護它, TU 可以自行決定從 unsupported 裡接納某些軟體套件包進入 [community]。<br />
<br />
2006 年,[core] 倉庫裡未被正確編譯的核心 [https://www.archlinux.org/news/please-avoid-kernel-261614-1/ 導致許多使用者系統當機]。之後,「core 套件庫審核機制」引入:所有 [core] 倉庫軟體套件包更新前,必須先在一個叫做 [testing] 的倉庫進行測試,必須在其他開發者同意後,軟體套件包才能正式移入 [core]。後來,[core] 中出現一些低使用率的軟體,審核機制對它們有所寬鬆。<br />
<br />
2009 年末至 2010 年初,出現了一些新的檔案系統,人們希望在安裝系統時就使用它們(即納入 [core] )。鑒於 [core] 從來沒有給出明確的界定(只是說「重要的軟體套件包,由開發者挑選」),人們決定給它一個更為明確的定義(參見下文)。<br />
<br />
= 軟體套件庫列表 =<br />
<br />
== [core] ==<br />
<br />
[core] 套件庫位於 Arch 鏡像的 ''core/os/i686'' 或 ''core/os/x86_64'' 目錄中。<br />
<br />
該套件庫對套件的質量有嚴格的要求:<br />
* 軟體套件更新需要經過開發者和使用者的審察批准。<br />
* 對於低使用率的軟體,公布合理的更新緣由(例如:發布通知、請求審核、在 [testing] 倉庫審核幾天到幾週不等),後經開發者簡單的審核即可。<br />
<br />
該倉庫包含下列軟體套件包:<br />
<br />
* 啟動 Arch 系統所必需的。<br />
* 連線至網際網路時可能需要的。<br />
* 編譯軟體套件時需要的。<br />
* 檢查、修復檔案系統的工具。<br />
* 在安裝過程中可能用到的(例如 openssh)。<br />
* 同上述軟體套件包的執行有依存關係的。<br />
<br />
''核心系統安裝光碟中包含這些軟體套件包,通過安裝光碟,你可以離線安裝基本系統。''<br />
<br />
== [extra] ==<br />
<br />
[extra] 套件庫位於 Arch 鏡像的 ''extra/os/i686'' 或 ''extra/os/x86_64'' 目錄中。它包含不適合 [core] 套件庫標準的大量軟體套件,如:Xorg,視窗管理員,網頁瀏覽器,媒體播放器,Script 語言支援等等。<br />
<br />
== [community] ==<br />
<br />
[community] 套件庫位於 Arch 鏡像的 ''community/os/i686'' 或 ''community/os/x86_64'' 目錄中。它由 ''可信使用者(TU)'' 維護,包含由 TU 認證、獲得足夠多評分的 [[AUR|AUR]] 軟體套件包。嚴格來講,它是 [[AUR|AUR]] 的一部分。<br />
<br />
== [multilib] ==<br />
<br />
[community] 套件庫位於 Arch 鏡像的 ''multilib/os/x86_64'' 目錄中。包含 64 位元系統中需要的 32 位元軟體和套件庫,如:Flash 外掛程式、Skype 。<br />
<br />
== [testing] ==<br />
<br />
[testing] 套件庫位於 Arch 鏡像的 ''testing/os/i686'' 或 ''testing/os/x86_64'' 目錄中。[testing] 套件庫很特別,它包含即將進入 [core]、[extra] 軟體套件庫的候選軟體套件。<br />
<br />
下列軟體套件會進入 [testing] 套件庫:<br />
* 更新該軟體套件可能損壞系統,需要進行測試。<br />
* 更新該軟體套件,可能需要其他相關軟體套件的重建,軟體套件在 [testing] 套件庫中等候全部相關軟體套件準備到位。 <br />
<br />
[testing] 套件庫是唯一可能和其它官方軟體套件庫有軟體套件名稱沖突的套件庫。如果要啟用,應該在''pacman.conf''檔案中將其設為第一個套件庫。<br />
<br />
{{警告|謹慎啟用 [testing] 套件庫,其中的軟體套件可能損壞系統。僅當你有足夠的經驗應對問題時,再考慮啟用。}}<br />
<br />
[testing] 套件庫並不是「最新」軟體套件包的倉庫,而是為軟體套件提供「測試」的地方。我們建議使用 [testing] 套件庫的使用者訂閱 arch-dev-public 郵件列表,並在 Bug Tracker 中彙報 Bug。<br />
<br />
== [community-testing] ==<br />
<br />
[community-testing] 套件庫的功能類似 [testing],不過是為 [community] 套件庫設計的測試套件庫。<br />
<br />
== [unsupported],即 AUR ==<br />
<br />
[unsupported],即我們所熟知的 [[AUR|AUR]]。在這個套件庫中,使用者可以自行送出軟體套件(通常以[[PKGBUILD]]的形式,而非二進制包)。無法以 pacman 使用這個套件庫,下載 [[PKGBUILD]] 以及相關文件後,需要自行通過 [[makepkg]] 編譯軟體套件。諸如[[yaourt_(正體中文)|yaourt]]之類的 [[AUR Helpers]] 是使用者使用 [[AUR|AUR]] 的好工具。<br />
<br />
{{註記|嚴格來說,[[AUR|AUR]] 是由 [community] 和 [unsupported] 一同組成的。}}<br />
<br />
== 非官方使用者套件庫 ==<br />
<br />
一些使用者組建了自己的軟體倉庫,參見[[Unofficial User Repositories|非官方使用者套件庫]]。</div>Binotahttps://wiki.archlinux.org/index.php?title=Official_repositories_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=293579Official repositories (正體中文)2014-01-19T13:58:38Z<p>Binota: 修正 zh_TW 用語,麻煩請不要以 zh_CN 經過粗略轉換就拿來充當 zh_TW 。</p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:軟體套件包管理 (正體中文)]]<br />
[[Category:關於Arch (正體中文)]]<br />
[[cs:Official Repositories]]<br />
[[en:Official Repositories]]<br />
[[es:Official Repositories]]<br />
[[fr:Depots]]<br />
[[it:Official Repositories]]<br />
[[ja:Official Repositories]]<br />
[[nl:Official Repositories]]<br />
[[pt:Official Repositories]]<br />
[[ru:Official Repositories]]<br />
[[tr:Resmi_Depolar]]<br />
[[zh-CN:Official Repositories]]<br />
{{Article summary start}}<br />
{{Article summary text|軟體套件庫包含了開發者與可信使用者(TU)提供的軟體套件,通常我們可以通過 pacman 來安裝並使用他們。本文將介紹 Arch Linux 的各種軟體套件庫。}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Mirrors}}<br />
{{Article summary wiki|AUR}}<br />
{{Article summary wiki|Unofficial User Repositories}}<br />
{{Article summary end}}<br />
<br />
[[Wikipedia:software repository|軟體套件庫]](在 Debian 生態圈的發行版中,又叫做「檔案庫」)是軟體套件存儲的地方。通常我們所說的軟體套件庫是指'''線上軟體套件庫''',亦即使用者從網際網路取得軟體的地方。Arch Linux [[Package Maintainer|軟體套件維護員]](包括開發人員以及[[Trusted Users|可信使用者]])對基本、常用或流行的軟體套件進行維護,使用者則可通過 [[pacman]] 軟體套件管理員安裝使用這些軟體。本文將帶您了解我們的官方軟體套件庫。<br />
<br />
= 歷史背景 =<br />
<br />
大部分的套件庫是因為歷史原因而分開的。一開始的時候,當本發行版只有少數使用者時,是只有一個軟體套件庫的,它就是現在的 [core] ──那時候它叫做 [official] 。這個倉庫主要存放了 Judd Vinet 選定的應用程式,當然現在已經不是這樣了:它被設計為只包含「每種類型」程式中的一個 ── 一個桌面環境、一個主瀏覽器等等。<br />
<br />
後來有使用者不滿 Judd 的選擇,由於 [[Arch Build System|ABS 系統]]使用簡單,所以他們就用 ABS 來建立自己的軟體套件。這些軟體套件被放入一個名為[unofficial] 的軟體套件庫,而這個套件庫由除 Judd 以外的開發人員進行維護。最終,新的套件庫獲得開發人員同樣的支持,所以就不再使用 [official] 和 [unofficial] 這兩個名稱了。大約在 0.5 版本的時候,兩個倉庫更名為 [current] 和 [extra] 。<br />
<br />
在 2007.8.1 版本發布之後,[current] 更名為 [core] ,以免讓人誤解它包含的內容。如今,這兩個套件庫在開發人員和社群眼中都是相同分量的。不過 [core] 還是有些不同的,主要區別在於安裝光碟和發布的快照中的軟體套件都只在 [core] 當中。這個倉庫可以實現一個完整的 Linux 系統,但並不一定是你想要的 Linux 系統。<br />
<br />
在 0.5 或者 0.6 版本的時候,套件庫中有大量的軟體套件沒有開發者願意去維護。於是一位開發人員(Xentac)建立了「可信使用者套件庫」(Trusted User Repositories),作為存放被信任的使用者(TU)自行建立的軟體套件的套件庫。[staging] 倉庫裡的軟體套件可被 Arch Linux 的開發人員選拔入官方倉庫,不過除此之外,開發人員和可信使用者或多或少還是有所不同的。<br />
<br />
就這樣過了一段時間,逐漸的可信使用者對他們的軟體倉庫感到厭倦,而非可信使用者又期望可以將自己的軟體套件與大家分享。這導致了[[AUR|AUR]]的出現。慢慢的,TU 們形成更為嚴密的組織,如今他們共同維護 [community] 軟體倉庫。TU 是一個獨立於 Arch Linux 開發人員之外的組織,兩者並沒太多交流。不過,熱門的軟體套件仍然會偶爾從[community] 選拔入 [extra]。[https://aur.archlinux.org/ AUR] 也支持允許非可信使用者送出 PKGBUILD 給其他使用者自願地使用。這些軟體套件不提供技術支持,所以 [[AUR|AUR]] 有時候被稱為 [unsupported] 倉庫。因為沒有發布可執行套件,unsupported 並不算是真正的軟體套件庫。如果 [[AUR|AUR]] 的某些軟體套件被 TU 認為熱門或是有興趣維護它, TU 可以自行決定從 unsupported 裡接納某些軟體套件包進入 [community]。<br />
<br />
2006 年,[core] 倉庫裡未被正確編譯的核心 [https://www.archlinux.org/news/please-avoid-kernel-261614-1/ 導致許多使用者系統當機]。之後,「core 套件庫審核機制」引入:所有 [core] 倉庫軟體套件包更新前,必須先在一個叫做 [testing] 的倉庫進行測試,必須在其他開發者同意後,軟體套件包才能正式移入 [core]。後來,[core] 中出現一些低使用率的軟體,審核機制對它們有所寬鬆。<br />
<br />
2009 年末至 2010 年初,出現了一些新的檔案系統,人們希望在安裝系統時就使用它們(即納入 [core] )。鑒於 [core] 從來沒有給出明確的界定(只是說「重要的軟體套件包,由開發者挑選」),人們決定給它一個更為明確的定義(參見下文)。<br />
<br />
= 軟體套件庫列表 =<br />
<br />
== [core] ==<br />
<br />
[core] 套件庫位於 Arch 鏡像的 ''core/os/i686'' 或 ''core/os/x86_64'' 目錄中。<br />
<br />
該套件庫對套件的質量有嚴格的要求:<br />
* 軟體套件更新需要經過開發者和使用者的審察批准。<br />
* 對於低使用率的軟體,公布合理的更新緣由(例如:發布通知、請求審核、在 [testing] 倉庫審核幾天到幾週不等),後經開發者簡單的審核即可。<br />
<br />
該倉庫包含下列軟體套件包:<br />
<br />
* 啟動 Arch 系統所必需的。<br />
* 連線至網際網路時可能需要的。<br />
* 編譯軟體套件時需要的。<br />
* 檢查、修復檔案系統的工具。<br />
* 在安裝過程中可能用到的(例如 openssh)。<br />
* 同上述軟體套件包的執行有依存關係的。<br />
<br />
''核心系統安裝光碟中包含這些軟體套件包,通過安裝光碟,你可以離線安裝基本系統。''<br />
<br />
== [extra] ==<br />
<br />
[extra] 套件庫位於 Arch 鏡像的 ''extra/os/i686'' 或 ''extra/os/x86_64'' 目錄中。它包含不適合 [core] 套件庫標準的大量軟體套件,如:Xorg,視窗管理員,網頁瀏覽器,媒體播放器,Script 語言支援等等。<br />
<br />
== [community] ==<br />
<br />
[community] 套件庫位於 Arch 鏡像的 ''community/os/i686'' 或 ''community/os/x86_64'' 目錄中。它由 ''可信使用者(TU)'' 維護,包含由 TU 認證、獲得足夠多評分的 [[AUR|AUR]] 軟體套件包。嚴格來講,它是 [[AUR|AUR]] 的一部分。<br />
<br />
== [multilib] ==<br />
<br />
[community] 套件庫位於 Arch 鏡像的 ''multilib/os/x86_64'' 目錄中。包含 64 位元系統中需要的 32 位元軟體和套件庫,如:Flash 外掛程式、Skype 。<br />
<br />
== [testing] ==<br />
<br />
[testing] 套件庫位於 Arch 鏡像的 ''testing/os/i686'' 或 ''testing/os/x86_64'' 目錄中。[testing] 套件庫很特別,它包含即將進入 [core]、[extra] 軟體套件庫的候選軟體套件。<br />
<br />
下列軟體套件會進入 [testing] 套件庫:<br />
* 更新該軟體套件可能損壞系統,需要進行測試。<br />
* 更新該軟體套件,可能需要其他相關軟體套件的重建,軟體套件在 [testing] 套件庫中等候全部相關軟體套件準備到位。 <br />
<br />
[testing] 套件庫是唯一可能和其它官方軟體套件庫有軟體套件名稱沖突的套件庫。如果要啟用,應該在''pacman.conf''檔案中將其設為第一個套件庫。<br />
<br />
{{警告|謹慎啟用 [testing] 套件庫,其中的軟體套件可能損壞系統。僅當你有足夠的經驗應對問題時,再考慮啟用。}}<br />
<br />
[testing] 套件庫並不是「最新」軟體套件包的倉庫,而是為軟體套件提供「測試」的地方。我們建議使用 [testing] 套件庫的使用者訂閱 arch-dev-public 郵件列表,並在 Bug Tracker 中彙報 Bug。<br />
<br />
== [community-testing] ==<br />
<br />
[community-testing] 套件庫的功能類似 [testing],不過是為 [community] 套件庫設計的測試套件庫。<br />
<br />
== [unsupported],即 AUR ==<br />
<br />
[unsupported],即我們所熟知的 [[AUR|AUR]]。在這個套件庫中,使用者可以自行送出軟體套件(通常以[[PKGBUILD]]的形式,而非二進制包)。無法以 pacman 使用這個套件庫,下載 [[PKGBUILD]] 以及相關文件後,需要自行通過 [[makepkg]] 編譯軟體套件。諸如[[yaourt_(正體中文)|yaourt]]之類的 [[AUR Helpers]] 是使用者使用 [[AUR|AUR]] 的好工具。<br />
<br />
{{註記|嚴格來說,[[AUR|AUR]] 是由 [community] 和 [unsupported] 一同組成的。}}<br />
<br />
== 非官方使用者套件庫 ==<br />
<br />
一些使用者組建了自己的軟體倉庫,參見[[Unofficial User Repositories|非官方使用者套件庫]]。</div>Binotahttps://wiki.archlinux.org/index.php?title=Network_configuration_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=293578Network configuration (正體中文)2014-01-19T13:37:27Z<p>Binota: /* 範例 */ Change the wiki link which named Official Repositories to the link of the page which is Chinese Traditional.</p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:Networking (正體中文)]]<br />
[[Category:Getting and installing Arch (正體中文)]]<br />
<br />
[[cs:Configuring Network]]<br />
[[el:Configuring Network]]<br />
[[es:Configuring Network]]<br />
[[fr:Connexions reseau]]<br />
[[it:Configuring Network]]<br />
[[ja:Network Configuration]]<br />
[[nl:Configuring Network]]<br />
[[pt:Configuring Network]]<br />
[[ro:Configurare retea]]<br />
[[ru:Configuring Network]]<br />
[[sk:Configuring Network]]<br />
[[tr:Ağ_Yapılandırması]]<br />
[[zh-CN:Network Configuration]]<br />
[[zh-TW:Network Configuration]]<br />
{{Related articles start}}<br />
{{Related|Jumbo Frames}}<br />
{{Related|Firewalls}}<br />
{{Related|Wireless Setup}}<br />
{{Related|List of Applications#Network Managers}}<br />
{{Related articles end}}<br />
{{TranslationStatus (正體中文)|Network_Configuration|2014-01-19|293523}}<br />
<br />
本頁將介紹如何設定 '''有線''' 網路連線。若您需要設定 '''無線''' 網路,請參考[[Wireless Setup|無線網路設定]]。<br />
<br />
== 檢查連線 ==<br />
<br />
{{註記|若您在執行 ping 時收到了類似 {{ic|ping: icmp open socket: Operation not permitted}} 這樣的錯誤訊息,請嘗試重新安裝 {{ic|iputils}} 軟體包。}} <br />
<br />
一般來說,基本的安裝過程都已經建立了可運作的網路設定。請執行下列指令以進行檢查:<br />
<br />
{{註記|{{ic|-c 3}} 選項表示將會呼叫三次。詳細請參閱 {{ic|man ping}} 。}}<br />
{{提示|您也可以嘗試使用其他的 Domain ,如 www.hinet.net 。}}<br />
<br />
{{hc|$ ping -c 3 www.google.com|<nowiki><br />
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.<br />
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms<br />
64 bytes from 74.125.224.146: icmp_req=2 ttl=50 time=385 ms<br />
64 bytes from 74.125.224.146: icmp_req=3 ttl=50 time=298 ms<br />
<br />
--- www.l.google.com ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 1999ms<br />
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms<br />
</nowiki>}}<br />
<br />
如果沒問題的話,您可能只是想以本文的下列部分來自定您的設定。<br />
<br />
若剛才的指令出現了 unknown hosts 之類的訊息,代表您的機器無法解析網域。這可能是因為您的網路服務提供商/閘道造成的。您可以嘗試 ping 一個靜態 IP 以實驗您的機器能否存取網際網路。<br />
{{提示|您也可以嘗試使用其他的 IP ,如 168.95.1.1 。}}<br />
<br />
{{hc|$ ping -c 3 8.8.8.8|<nowiki><br />
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.<br />
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms<br />
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms<br />
64 bytes from 8.8.8.8: icmp_req=3 ttl=53 time=70.6 ms<br />
<br />
--- 8.8.8.8 ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 2002ms<br />
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms<br />
</nowiki>}}<br />
<br />
{{註記|{{ic|8.8.8.8}} 為一個好記的靜態 IP 位置。這是 Google 的主要 DNS 伺服器,這表示其有一定的可信度,並且通常不會被系統或代理伺服器擋下。}}<br />
<br />
若您可以 ping 通該位置,您可能需要試著在 {{ic|/etc/resolv.conf}} 檔案中加上網域名稱伺服器。<br />
<br />
== 設定主機名稱 ==<br />
<br />
[[Wikipedia:Hostname|主機名稱]]為網路中用於識別機器的唯一識別名稱:主機名稱可以通過 {{ic|/etc/hostname}} 檔案來進行設定。一般來說該檔案包含了系統的網域名稱。下面為設定主機名稱的方法:<br />
<br />
# hostnamectl set-hostname '''myhostname'''<br />
<br />
這樣會將 '''myhostname''' 寫入 {{ic|/etc/hostname}} 檔案中。<br />
<br />
詳細請參閱 {{ic|man 5 hostname}} 與 {{ic|man 1 hostnamectl}} 。<br />
<br />
{{註記|<br />
* {{ic|hostnamectl}} 支援 FQDN<br />
* 您不需要編輯 {{ic|/etc/hosts}} 檔案,{{pkg|systemd}} 會提供主機名稱解析且預設安裝於所有系統。<br />
}}<br />
<br />
使用來自 {{Pkg|inetutils}} 的 {{ic|hostname}} 指令以設定臨時主機名稱(直到重新啟動):<br />
<br />
# hostname ''myhostname''<br />
<br />
== 裝置驅動程式 ==<br />
<br />
=== 檢查驅動程式狀態 ===<br />
<br />
[[udev]] 應該會檢測您的網路介面卡([[Wikipedia:Network_interface_controller|NIC]])並自動於啟動時載入必要的模組。檢查 {{ic|lspci -v}} 輸出內容中的「Ethernet controller」 項目(或類似的)。這應該會告訴您哪些核心模組包含了網路設備的驅動程式。舉例來說:<br />
<br />
{{hc|$ lspci -v|<br />
02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)<br />
...<br />
Kernel driver in use: atl1<br />
Kernel modules: atl1<br />
}}<br />
<br />
接下來,確認該驅動程式已經通過 {{ic|dmesg <nowiki>|</nowiki> grep ''module_name''}} 載入了。舉例來說:<br />
<br />
$ dmesg | grep atl1<br />
...<br />
atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex<br />
<br />
若驅動程式已成功加載可以跳過接下來這段。否則,您會需要知道哪些模組時您的特定型號的裝置需要哪個模組。<br />
<br />
=== 載入裝置模組 ===<br />
<br />
以 Google 搜尋正確的晶片組模組/驅動程式。常見的驅動模組有 Realtek 晶片組網卡的 {{ic|8139too}} ,或是 SiS 晶片組網卡的 {{ic|sis900}}。當您知道要使用何種模組了之後,試著[[Kernel modules#Manual module handling|手動將其載入]]。若您得到了錯誤訊息告訴您找不到該模組,則該驅動可能未包含於 Arch 核心中。您可以在 [[AUR]] 中搜尋該模組名稱。<br />
<br />
若 udev 未在開機期間檢測與載入正確的模組,請參閱 [[Kernel modules#Loading]]。<br />
<br />
== 網路介面 ==<br />
<br />
=== 裝置名稱 ===<br />
<br />
對於多網路卡的電腦,固定裝置名稱非常重要。許多設定問題都是因為介面卡名稱的改動造成的。<br />
<br />
[[udev]] 負責命名裝置。Systemd v197 則有[http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames 可預測之網路介面名稱]並可自動支配靜態名稱給網路裝置。介面名稱以 {{ic|en}} (乙太網路)、 {{ic|wl}} (無線網路) 或是 {{ic|ww}} (WWAN)作為前置字串並附上一個自動產生的識別名稱,進而產生了類似 {{ic|enp0s25}} 這樣的名稱。 <br />
<br />
要禁用這種行為,可以加上一個連接:<br />
<br />
# ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules<br />
<br />
自早期版本升級 systemd 的使用者會有一自動建立的空規則檔案。因此,若您想使用一貫的裝置名稱,只需要刪除該檔案。<br />
<br />
{{提示|您可以執行 {{ic|ip link}} 或是 {{ic|ls /sys/class/net}} 以列出所有可用的介面。}}<br />
<br />
{{註記|當您更改了介面名稱規則後,別忘了更新所有跟網路有關的組態檔案與自定的 systemd unit 檔案以因應該更改。特別是當您啟用了 [[netctl#Basic method|netctl 靜態設定檔]] ,請執行 {{ic|netctl reenable ''profile''}} 以更新所有產生的服務檔案。}}<br />
<br />
==== 更改裝置名稱 ====<br />
<br />
您可以使用 udev-rule 來手動定義裝置名稱。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"<br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"<br />
</nowiki>}}<br />
<br />
請注意這兩點:<br />
<br />
* 使用這個指令以取得 MAC 位置:{{ic|cat /sys/class/net/''device_name''/address}}。<br />
* 請確定 udev 規則中使用的是小寫的十六進位數值而不是大寫。<br />
<br />
若您的網路卡為動態 MAC ,您可以使用 DEVPATH ,例如:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"<br />
</nowiki>}}<br />
<br />
{{註記|當使用了靜態的名稱時,'''應該要避免使用類似 "eth''X''" 與 "wlan''X''"''' 這樣的名稱,因為這可能會導致核心與 udev 在開機時發生衝突。而剛好相反地,最好使用核心預設不會使用的介面名稱,如 {{ic|net0}} 、 {{ic|net1}} 、 {{ic|wifi0}} 、 {{ic|wifi1}} 。詳細說明請參閱 [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames systemd] 文件。}}<br />
<br />
=== 設定裝置的 MTU 與佇列長度 ===<br />
<br />
您可以手動定義 udev 規則來更改裝置的 MTU 與佇列長度。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1480", ATTR{tx_queue_len}="2000"<br />
</nowiki>}}<br />
<br />
=== 取得目前的裝置名稱 ===<br />
<br />
目前的 NIC 名稱可以通過 sysfs 找到<br />
<br />
{{hc|$ ls /sys/class/net|<br />
lo eth0 eth1 firewire0<br />
}}<br />
<br />
=== 啟用與禁用網路介面 ===<br />
<br />
您可以使用下列指令來啟用或禁用網路介面:<br />
<br />
# ip link set eth0 up<br />
# ip link set eth0 down<br />
<br />
要確認結果,請執行:<br />
<br />
{{hc|$ ip link show dev eth0|<br />
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000<br />
...<br />
}}<br />
<br />
== 組態設定 IP 位址 ==<br />
<br />
您有兩個選擇:使用 [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]] 指派動態位址,或是使用「靜態」的位址。<br />
<br />
=== 動態 IP 位址 ===<br />
<br />
==== 手動執行 DHCP 用戶端 Daemon ====<br />
<br />
{{註記|請特別注意 {{ic|dhcpcd}} (DHCP ''Client'' Daemon,DHCP 用戶端 Daemon) 與 {{ic|dhcpd}} (DHCP ''(server)'' daemon,DHCP 伺服端 Daemon) 間的差異。}}<br />
<br />
{{hc|# dhcpcd eth0|<br />
dhcpcd: version 5.1.1 starting<br />
dhcpcd: eth0: broadcasting for a lease<br />
...<br />
dhcpcd: eth0: leased 192.168.1.70 for 86400 seconds<br />
}}<br />
<br />
緊接著, {{ic|ip addr show dev eth0}} 應該要顯示出您的 inet 位址。<br />
<br />
對部分的人而言,{{ic|dhcpcd}} 失敗時,可以使用 {{ic|dhclient}} (位於 {{Pkg|dhclient}} 軟體包中)<br />
<br />
==== 於啟動時執行 DHCP ====<br />
<br />
若您只是想使用 DHCP 來連線至您的乙太網路連線,您可以使用 {{ic|dhcpcd@.service}} (由 {{Pkg|dhcpcd}} 軟體包提供)。<br />
<br />
要啟動 {{ic|eth0}} 上的 DHCP ,只需要使用:<br />
<br />
# systemctl start dhcpcd@eth0.service<br />
<br />
您可以下列方法啟用該服務讓其於開機時自動啟動:<br />
<br />
# systemctl enable dhcpcd@eth0.service<br />
<br />
若您用了 DHCP 且您並 '''不想''' 讓您的 DNS 伺服器在每次啟動網路時自動指派,請將下列內容加到 {{ic|dhcpcd.conf}} 的最後一段中:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nohook resolv.conf<br />
}}<br />
<br />
另外,若您位於基於 MAC 位址的用戶端 IP 位址進行過濾的 DHCPv4 網路,您可能需要修改下列內容:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 Client ID as per RFC4361. <br />
duid<br />
}}<br />
<br />
為:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the hardware address of the interface for the Client ID (DHCPv4).<br />
clientid<br />
}}<br />
<br />
否則,您可能會因為 DHCP 伺服器無法正確讀取您的 [http://en.wikipedia.org/wiki/DHCPv6 DHCPv6-style] 用戶端 ID 而無法使用。詳細請參閱 [http://tools.ietf.org/html/rfc4361 RFC 4361] 。<br />
<br />
為防止 {{ic|dhcpcd}} 加入網域名稱伺服器至 {{ic|/etc/resolv.conf}} 中,請於其中使用 {{ic|nooption}} 選項:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nooption domain_name_servers<br />
}}<br />
<br />
接著加入您自己的 DNS 名稱伺服器至 {{ic|/etc/resolv.conf}} 中。<br />
<br />
若有多個不同的執行緒要控制 {{ic|/etc/resolv.conf}} (如 {{Pkg|dhcpcd}} 與 VPN 用戶端),您可能會想要使用 {{Pkg|openresolv}} 軟體包。使用 {{Pkg|openresolv}} 並不需要額外地設定 {{Pkg|dhcpcd}} 。<br />
<br />
==== DHCP 靜態路由 ====<br />
若您需要加入靜態路由用戶端,請於 {{ic|/usr/lib/dhcpcd/dhcpcd-hooks}} 中建立一個新的 dhcpcd hook-script 。下列範例展示了加入靜態路由至一個通過閘道為 192.168.192.5 ,位於 10.11.12.0/24 的 VPN 子網路:<br />
{{hc|/usr/lib/dhcpcd/dhcpcd-hooks/40-vpnroute|<br />
ip route add 10.11.12.0/24 via 192.168.192.5<br />
}}<br />
前置字串''40''表示其於 dhcpcd 啟動時的最後執行 hook-script 。<br />
<br />
=== 靜態 IP 位址 ===<br />
<br />
您可能因為各種原因而希望在您的網路中指派靜態 IP 位址,例如靜態的位址可以獲得一定程度的可預測性,或是您沒有可用的 DHCP 伺服器。<br />
<br />
{{註記|若您通過 Windows 機器來共享您的網路而不是使用路由器,請確保兩台電腦皆使用了靜態 IP 位址以避免區域網路問題。}}<br />
<br />
您需要:<br />
<br />
* 靜態 IP 位址<br />
* [[Wikipedia:Subnetwork|子網路遮罩]]<br />
* [[Wikipedia:Broadcast_address|廣播位址]]<br />
* [[Wikipedia:Default_gateway|預設閘道器]]的 IP 位址<br />
<br />
若您處在內部網路中,使用 192.168.*.* 這樣的 IP 位址較為安全,搭配其的子網路遮罩 255.255.255.0 ,廣播位址為 192.168.*.255 。而閘道通常是 192.168.*.1 或是 192.168.*.254 。<br />
<br />
==== 手動指派 ====<br />
<br />
您可於控制台中指派一靜態 IP 位址:<br />
<br />
# ip addr add <IP 位址>/<子網路遮罩> broadcast <廣播> dev <介面><br />
<br />
舉例來說:<br />
<br />
# ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev eth0<br />
<br />
{{註記|子網路遮罩使用了 [[Wikipedia:CIDR_notation|CIDR 表示法]](CIDR,Classless Inter-Domain Routing,無類別網路間路由)。}}<br />
<br />
詳情請參閱 {{ic|man ip}} 。<br />
<br />
以類似下列方法加上您的閘道:<br />
<br />
# ip route add default via <預設閘道 IP 位址><br />
<br />
舉例來說:<br />
<br />
# ip route add default via 192.168.1.1<br />
<br />
若您得到了 "No such process" 這樣的錯誤訊息,這代表您必須以 root 執行 {{ic|ip link set dev eth0 up}} 。<br />
<br />
==== 於啟動時通過 systemd 手動連線 ====<br />
<br />
先確保 dhcpcd 已停止並禁用:<br />
<br />
# systemctl status dhcpcd.service<br />
<br />
接著為 [[systemd]] 服務建立一個檔案。以正確的網路介面名稱取代其中的 {{ic|<interface>}} :<br />
<br />
{{hc|/etc/conf.d/network@<interface>|<nowiki><br />
address=192.168.0.15<br />
netmask=24<br />
broadcast=192.168.0.255<br />
gateway=192.168.0.1<br />
</nowiki>}}<br />
<br />
建立 systemd unit 檔案:<br />
<br />
{{hc|/etc/systemd/system/network@.service|<nowiki><br />
[Unit]<br />
Description=Network connectivity (%i)<br />
Wants=network.target<br />
Before=network.target<br />
BindsTo=sys-subsystem-net-devices-%i.device<br />
After=sys-subsystem-net-devices-%i.device<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
EnvironmentFile=/etc/conf.d/network@%i<br />
<br />
ExecStart=/usr/bin/ip link set dev %i up<br />
ExecStart=/usr/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i<br />
ExecStart=/usr/bin/ip route add default via ${gateway}<br />
<br />
ExecStop=/usr/bin/ip addr flush dev %i<br />
ExecStop=/usr/bin/ip link set dev %i down<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
啟用該 unit 並將其啟動,傳入介面名稱,例如 eno1 :<br />
<br />
# systemctl enable network@eno1.service<br />
# systemctl start network@eno1.service<br />
<br />
若您需要手動設定名稱伺服器,請編輯 {{ic|/etc/resolv.conf}} 檔案:<br />
<br />
{{hc|/etc/resolv.conf|<br />
nameserver 208.67.222.222<br />
nameserver 208.67.220.220}}<br />
<br />
若 {{ic|/etc/resolv.conf}} 被持續遭到複寫,請參考 [[Resolv.conf]] 以瞭解如何解決此問題。<br />
<br />
有幾個類似的方法來讓 systemd 啟動網路,其中的差異為檔案內容,並且其可以寫死 EnvironmentFile 定義的參考檔案中抓到的參數。因此可以作為一種替代的,將介面名稱放置於 /etc/conf.d/ 中的 EnvironmentFile ,接著直接使用介面名稱而不是 %i 。如此一來,檔案名稱便不需要「@」。這也是一種有用的方法,詳情請參閱[http://www.freedesktop.org/software/systemd/man/systemd.unit.html Systemd 服務文件]。<br />
<br />
==== 計算位址 ====<br />
<br />
您可以使用 {{Pkg|ipcalc}} 提供的 {{ic|ipcalc}} 來計算 IP 廣播、網域、子網路遮罩與主機範圍等進階設定舉例來說,我使用了位於防火牆後的乙太網路來連線 Windows 機器至 Arch。為了安全性與網路組織,我將他們放置於各自獨立的網路,接著組態設定子網路遮罩與廣播位址,如此一來網路中就只有兩台機器。為了找出子網路遮罩跟廣播位址,我使用了 ipcalc ,提供其 Arch firewire nic 的 IP 位址 10.66.66.1 ,並指定 ipcalc 要建立一個只有兩台主機的網路。<br />
<br />
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|<nowiki><br />
Address: 10.66.66.1<br />
<br />
Netmask: 255.255.255.252 = 30<br />
Network: 10.66.66.0/30<br />
HostMin: 10.66.66.1<br />
HostMax: 10.66.66.2<br />
Broadcast: 10.66.66.3<br />
Hosts/Net: 2 Class A, Private Internet<br />
</nowiki>}}<br />
<br />
== 載入組態設定 ==<br />
<br />
要測試您的設定,您可以重新啟動電腦或是重新載入相關的 systemd 服務:<br />
<br />
# systemctl restart dhcpcd@eth0<br />
<br />
您可以試著 ping 您的閘道、 DNS 伺服器、 ISP 提供商或是其他網路上的站台。如此一來便可以確認您的網路連線問題為何,例如:<br />
<br />
$ ping -c 3 www.google.com<br />
<br />
== 附加設定 ==<br />
<br />
=== 筆記型電腦之 ifplugd ===<br />
<br />
{{提示|{{Pkg|dhcpcd}} 提供了開箱即用的相同功能。}}<br />
<br />
[[Official Repositories (正體中文)|官方軟體套件庫]]中的 {{Pkg|ifplugd}} 為一個當網路線插入後自動組態乙太設備;網路線拔除後自動取消組態的 Daemon 。<br />
這對於搭載內建網路介面卡的筆記型電腦特別有用,因為其只會在網路線真正連上後才會對介面進行組態。另一個會用到的情況為,當您需要重新啟動網路,但您並不想重開及或在 Shell 中進行設定。<br />
<br />
預設情況下,其會對 {{ic|eth0}} 裝置進行設定使其運作。這與其他設定類似延遲之類的設定能在 {{ic|/etc/ifplugd/ifplugd.conf}} 中進行設定。<br />
<br />
<br />
{{註記|[[Netctl]] 軟體包包含了 {{ic|netctl-ifplugd@.service}},否則您可以使用來自 {{Pkg|ifplugd}} 軟體包的 {{ic|ifplugd@.service}} 。例如這樣使用:{{ic|systemctl enable ifplugd@eth0.service}}。}}<br />
<br />
=== Bonding 或 LAG ===<br />
<br />
請參閱 [[netctl#Bonding]] 。<br />
<br />
=== IP 別名 ===<br />
<br />
{{Expansion|Manual method using [[Core Utilities#ip|ip]] should be added; then move current example using ''netctl'' into [[netctl]].}}<br />
<br />
IP 別名為讓同一個網路介面有多個 IP 位址。如此一來,單個節點的網路就能有多個網路連線,進而實現不同的作用。經典的使用方法為網頁與 FTP 伺服器的虛擬主機,或是重組伺服器而無需更新任何其他的機器(對於名稱伺服器來說特別有用)。<br />
<br />
==== 範例 ====<br />
<br />
您將需要來自[[Official Repositories (正體中文)|官方軟體套件庫]]的 {{Pkg|netctl}} 。<br />
<br />
準備組態設定檔:<br />
<br />
{{hc|/etc/netctl/mynetwork|<nowiki><br />
Connection='ethernet'<br />
Description='Five different addresses on the same NIC.'<br />
Interface='eth0'<br />
IP='static'<br />
Address=('192.168.1.10' '192.168.178.11' '192.168.1.12' '192.168.1.13' '192.168.1.14' '192.168.1.15')<br />
Gateway='192.168.1.1'<br />
DNS=('192.168.1.1')<br />
</nowiki>}}<br />
<br />
接著只需要將其執行即可:<br />
<br />
$ netctl start mynetwork<br />
<br />
=== 更改 MAC/硬體 位址 ===<br />
<br />
請參閱 [[MAC Address Spoofing]] 。<br />
<br />
=== 網路共享 ===<br />
<br />
請參閱 [[Internet Sharing]] 。<br />
<br />
=== 路由組態設定 ===<br />
<br />
請參閱 [[Router]] 。<br />
<br />
=== 區域網路主機名稱解析 ===<br />
<br />
先決條件為[[#.E8.A8.AD.E5.AE.9A.E4.B8.BB.E6.A9.9F.E5.90.8D.E7.A8.B1|設定主機名稱]]之後,主機名稱可在本機系統上解析:<br />
{{hc|$ ping hostname|<br />
PING hostname <nowiki>(192.168.1.2) 56(84) bytes of data.<br />
64 bytes from hostname (192.168.1.2): icmp_seq=1 ttl=64 time=0.043 ms</nowiki>}}<br />
要以其他機器的名稱來解析主機,需要手動設定各自的 {{ic|/etc/hosts}} 檔案或是廣播/解析名稱的服務。<br />
<br />
過度設定 DNS 伺服器,如 [[BIND]] 、 [[Unbound]] ,手動編輯 {{ic|/etc/hosts}} 過於繁瑣,或是您希望對於動態地將主機離開、加入網路有更大的靈活性,您可以在您的區域網路中使用 Zero-configuration networking 來進行主機名稱解析。這裡有兩個可用選擇:<br />
<br />
*[[Samba]] 提供了通過微軟 '''NetBIOS''' 的主機名稱解析。其只需要安裝 {{Pkg|samba}} 並啟用 {{ic|nmbd.service}} 服務。執行 Windows 、OS X 或執行了 {{ic|nmbd}} 的 Linux ,將能夠找到您的機器。<br />
<br />
*[[Avahi]] 提供通過 '''zeroconf''' 的主機名稱解析,也稱作 Avahi 或 Boujour 。它比 Samba 還需要稍微複雜一點的設定:詳情請參考 [[Avahi#Hostname resolution]]。執行 OS X 或執行了 Avahi daemon 的 Linux ,將能夠找到您的機器。Windows 並無內建 Avahi 用戶端或 Daemon 。<br />
<br />
== 診斷 ==<br />
<br />
=== Swapping computers on the cable modem ===<br />
<br />
Some cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.<br />
<br />
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].<br />
<br />
=== The TCP window scaling problem ===<br />
<br />
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.<br />
<br />
Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html RFC 1323] was written to improve the situation: Window Scaling. The "window" value, provided in all packets, will be modified by a Scale Factor defined once, at the very beginning of the connection.<br />
<br />
That 8-bit Scale Factor allows the Window to be up to 32 times higher than the initial 64Kb.<br />
<br />
It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts.<br />
<br />
The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.<br />
<br />
The resulting connection is at best very slow or broken.<br />
<br />
==== How to diagnose the problem ====<br />
<br />
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).<br />
<br />
When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|ip addr}} will report normal status... and actually everything appears normal.<br />
<br />
If you cannot browse any website, but you can ping some random hosts, chances are great that you're experiencing this problem: ping uses ICMP and is not affected by TCP problems.<br />
<br />
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).<br />
<br />
==== How to fix it (The bad way) ====<br />
<br />
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.<br />
<br />
# echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem<br />
<br />
==== How to fix it (The good way) ====<br />
<br />
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.d/99-disable_window_scaling.conf}} (see also [[sysctl]])<br />
<br />
net.ipv4.tcp_window_scaling = 0<br />
<br />
==== How to fix it (The best way) ====<br />
<br />
This problem is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.<br />
<br />
==== More about it ====<br />
<br />
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].<br />
<br />
There are also several relevant threads on the LKML.<br />
<br />
=== Realtek no link / WOL problem ===<br />
<br />
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice a problem where the NIC seems to be disabled on boot and has no Link light. This can usually be found on a dual boot system where Windows is also installed. It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause. These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots. You will be able to notice if this problem is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off. Normal operation should be that the link light is always on as long as the system is on, even during POST. This problem will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this problem:<br />
<br />
==== Method 1 - Rollback/change Windows driver ====<br />
<br />
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).<br />
<br />
==== Method 2 - Enable WOL in Windows driver ====<br />
<br />
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems). In Windows, under Device Manager, find your Realtek network adapter and double-click it. Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.<br />
<br />
In Windows XP (example)<br />
Right click my computer<br />
--> Hardware tab<br />
--> Device Manager<br />
--> Network Adapters<br />
--> "double click" Realtek ...<br />
--> Advanced tab<br />
--> Wake-On-Lan After Shutdown<br />
--> Enable<br />
<br />
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{ic|Disable}} has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.}}<br />
<br />
==== Method 3 - Newer Realtek Linux driver ====<br />
<br />
Any newer driver for these Realtek cards can be found for Linux on the realtek site. (untested but believed to also solve the problem).<br />
<br />
==== Method 4 - Enable ''LAN Boot ROM'' in BIOS/CMOS ====<br />
<br />
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.<br />
<br />
{{Note|This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.}}<br />
<br />
=== DLink G604T/DLink G502T DNS problem ===<br />
<br />
Users with a DLink G604T/DLink G502T router, using DHCP and have firmware v2.00+ (typically users with AUS firmware) may have problems with certain programs not resolving the DNS. One of these programs are unfortunatley pacman. The problem is basically the router in certain situations is not sending the DNS properly to DHCP, which causes programs to try and connect to servers with an IP address of 1.0.0.0 and fail with a connection timed out error<br />
<br />
==== How to diagnose the problem ====<br />
<br />
The best way to diagnose the problem is to use Firefox/Konqueror/links/seamonkey and to enable wget for pacman. If this is a fresh install of Arch Linux, then you may want to consider installing {{ic|links}} through the live CD.<br />
<br />
Firstly, enable wget for pacman (since it gives us info about pacman when it is downloading packages)<br />
Open {{ic|/etc/pacman.conf}} with your favourite editor and uncomment the following line (remove the # if it is there)<br />
<br />
XferCommand=/usr/bin/wget --passive-ftp -c -O %o %u<br />
<br />
While you are editing {{ic|/etc/pacman.conf}}, check the default mirror that pacman uses to download packages.<br />
<br />
Now open up the default mirror in an Internet browser to see if the mirror actually works. If it does work, then do {{ic|pacman -Syy}} (otherwise pick another working mirror and set it to the pacman default). If you get something similar to the following (notice the 1.0.0.0),<br />
<br />
<nowiki>ftp://mirror.pacific.net.au/linux/archlinux/extra/os/i686/extra.db.tar.gz</nowiki><br />
=> '/var/lib/pacman/community.db.tar.gz.part'<br />
Resolving mirror.pacific.net.au... 1.0.0.0<br />
<br />
then you most likely have this problem. The 1.0.0.0 means it is unable to resolve DNS, so we must add it to {{ic|/etc/resolv.conf}}.<br />
<br />
==== How to fix it ====<br />
<br />
{{Out of date|{{Pkg|dhcpcd}} does not use {{ic|/etc/conf.d/dhcpcd}} any more.}}<br />
<br />
Basically what we need to do is to manually add the DNS servers to our {{ic|/etc/resolv.conf}} file. The problem is that DHCP automatically deletes and replaces this file on boot, so we need to edit {{ic|/etc/conf.d/dhcpcd}} and change the flags to stop DHCP from doing this.<br />
<br />
When you open {{ic|/etc/conf.d/dhcpcd}}, you should see something close to the following:<br />
<br />
DHCPCD_ARGS="-t 30 -h $HOSTNAME"<br />
<br />
Add the {{ic|-R}} flag to the arguments, e.g.,<br />
<br />
DHCPCD_ARGS="-R -t 30 -h $HOSTNAME"<br />
<br />
{{Note|1=If you are using {{Pkg|dhcpcd}} >= 4.0.2, the {{ic|-R}} flag has been deprecated. Please see the [[#Run DHCP at boot]] section for information on how to use a custom {{ic|/etc/resolv.conf}} file.}}<br />
<br />
Save and close the file; now open {{ic|/etc/resolv.conf}}. You should see a single nameserver (most likely 10.1.1.1). This is the gateway to your router, which we need to connect to in order to get the DNS servers of your ISP. Paste the IP address into your browser and log in to your router. Go to the DNS section, and you should see an IP address in the Primary DNS Server field; copy it and paste it as a nameserver '''ABOVE''' the current gateway one.<br />
<br />
For example, {{ic|/etc/resolv.conf}} should look something along the lines of:<br />
<br />
nameserver 10.1.1.1<br />
<br />
If my primary DNS server is 211.29.132.12, then change {{ic|/etc/resolv.conf}} to:<br />
<br />
nameserver 211.29.132.12<br />
nameserver 10.1.1.1<br />
<br />
Now restart the network daemon by running {{ic|systemctl restart dhcpcd@<interface>}} and do {{ic|pacman -Syy}}. If it syncs correctly with the server, then the problem is solved.<br />
<br />
==== More about it ====<br />
<br />
This is the whirlpool forum (Australian ISP community) which talks about and gives the same solution to the problem:<br />
<br />
http://forums.whirlpool.net.au/forum-replies-archive.cfm/461625.html<br />
<br />
=== Check DHCP problem by releasing IP first ===<br />
<br />
Problem may occur when DHCP get wrong IP assignment. For example when two routers are tied together through VPN. The router that is connected to me by VPN may assigning IP address. To fix it. On a console, as root, release IP address:<br />
<br />
# dhcpcd -k<br />
<br />
Then request a new one:<br />
<br />
# dhcpcd<br />
<br />
Maybe you had to run those two commands many times.<br />
<br />
=== No eth0 with Atheros AR8161 ===<br />
<br />
{{Note|With the 3.10.2-1-ARCH kernel update, the alx ethernet driver module is included in the package.}}<br />
<br />
With the Atheros AR8161 Gigabit Ethernet card, the ethernet connection is not working out-of-the-box (with the installation media of March 2013). The module "alx" needs to be loaded but is not present.<br />
<br />
The driver from [http://linuxwireless.org/en/users/Download/stable/#compat-wireless_stable_releases compat-wireless] (that has become [https://backports.wiki.kernel.org/index.php/Releases compat-drives] since linux 3.7) need to be installed. The "-u" postfix annotates that Qualcomm have applied a driver under a unified driver.<br />
<br />
$ wget https://www.kernel.org/pub/linux/kernel/projects/backports/2013/03/28/compat-drivers-2013-03-28-5-u.tar.bz2<br />
$ tar xjf compat*<br />
$ cd compat*<br />
$ ./scripts/driver-select alx<br />
$ make<br />
$ sudo make install<br />
$ sudo modprobe alx<br />
<br />
The alx driver has not been added to Linux kernel due to various problems. Compatibility between the different kernel versions has been spotty. For better support follow the [http://lists.infradead.org/mailman/listinfo/unified-drivers mailing list]and [http://www.linuxfoundation.org/collaborate/workgroups/networking/alx alx page]for latest working solution for alx.<br />
<br />
The driver must be built and installed after every kernel change.<br />
<br />
Alternatively you can use the AUR package for [https://aur.archlinux.org/packages/compat-drivers-patched/ compat drivers], which installs many other drivers.<br />
<br />
=== No eth0 with Atheros AR9485 ===<br />
<br />
The ethernet (eth0) for Atheros AR9485 are not working out-of-the-box (with installation media of March 2013). The working solution for this is to install the package [https://aur.archlinux.org/packages/compat-drivers-patched/ compat-drivers-patched] from AUR.<br />
<br />
=== No carrier / no connection after suspend ===<br />
After suspend to RAM no connection is found although the network cable is plugged in. <br />
This may be caused by PCI power management. What is the output of<br />
<br />
# ip link show eth0<br />
<br />
If the line contains "NO-CARRIER" even though there's a cable connected to your eth0 port, it is possible that the device was auto-suspended and the media sense feature doesn't work. To solve this, first you need to find your ethernet controllers PCI address by<br />
<br />
# lspci<br />
<br />
This should look similar to this:<br />
<br />
...<br />
00:19.0 Ethernet controller: Intel Corporation 82577LM Gigabit Network Connection (rev 06)<br />
...<br />
<br />
So the address is 00:19.0.<br />
Now check the PM status of the device by issuing<br />
<br />
# cat "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
substituting 00:19.0 with the address obtained from lspci.<br />
If the output reads "auto", you can try to bring the device out of suspend by<br />
<br />
# echo on > "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
Don't forget to substitute the address again.<br />
<br />
{{Note|1=This appears to be a bug in kernel 3.8.4.1- (3.8.8.1 is still affected): [https://bbs.archlinux.org/viewtopic.php?id=159837&p=2 Forum discussion.] It also appears a fix is [https://lkml.org/lkml/2013/1/18/147 on the way. (It will be likely fixed in 3.9.)] In the meantime, the above is a suitable workaround.}}<br />
<br />
=== Broadcom BCM57780 ===<br />
<br />
This Broadcom chipset sometimes does not behave well unless you specify the order of the modules to be loaded. The modules are {{ic|broadcom}} and {{ic|tg3}}, the former needing to be loaded first.<br />
<br />
These steps should help if your computer has this chipset:<br />
$ lspci | grep Ethernet<br />
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)<br />
<br />
If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following (as root):<br />
# modprobe -r tg3<br />
# modprobe broadcom<br />
# modprobe tg3<br />
<br />
Now plug you network cable in. If this solves your problems you can make this permanent by adding {{ic|broadcom}} and {{ic|tg3}} (in this order) to the {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}}:<br />
<br />
MODULES=".. broadcom tg3 .."<br />
<br />
Then rebuild the initramfs:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|These methods may work for other chipsets, such as BCM57760.}}</div>Binotahttps://wiki.archlinux.org/index.php?title=Network_configuration_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=293577Network configuration (正體中文)2014-01-19T13:34:45Z<p>Binota: /* 筆記型電腦之 ifplugd */ Translated</p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:Networking (正體中文)]]<br />
[[Category:Getting and installing Arch (正體中文)]]<br />
<br />
[[cs:Configuring Network]]<br />
[[el:Configuring Network]]<br />
[[es:Configuring Network]]<br />
[[fr:Connexions reseau]]<br />
[[it:Configuring Network]]<br />
[[ja:Network Configuration]]<br />
[[nl:Configuring Network]]<br />
[[pt:Configuring Network]]<br />
[[ro:Configurare retea]]<br />
[[ru:Configuring Network]]<br />
[[sk:Configuring Network]]<br />
[[tr:Ağ_Yapılandırması]]<br />
[[zh-CN:Network Configuration]]<br />
[[zh-TW:Network Configuration]]<br />
{{Related articles start}}<br />
{{Related|Jumbo Frames}}<br />
{{Related|Firewalls}}<br />
{{Related|Wireless Setup}}<br />
{{Related|List of Applications#Network Managers}}<br />
{{Related articles end}}<br />
{{TranslationStatus (正體中文)|Network_Configuration|2014-01-19|293523}}<br />
<br />
本頁將介紹如何設定 '''有線''' 網路連線。若您需要設定 '''無線''' 網路,請參考[[Wireless Setup|無線網路設定]]。<br />
<br />
== 檢查連線 ==<br />
<br />
{{註記|若您在執行 ping 時收到了類似 {{ic|ping: icmp open socket: Operation not permitted}} 這樣的錯誤訊息,請嘗試重新安裝 {{ic|iputils}} 軟體包。}} <br />
<br />
一般來說,基本的安裝過程都已經建立了可運作的網路設定。請執行下列指令以進行檢查:<br />
<br />
{{註記|{{ic|-c 3}} 選項表示將會呼叫三次。詳細請參閱 {{ic|man ping}} 。}}<br />
{{提示|您也可以嘗試使用其他的 Domain ,如 www.hinet.net 。}}<br />
<br />
{{hc|$ ping -c 3 www.google.com|<nowiki><br />
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.<br />
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms<br />
64 bytes from 74.125.224.146: icmp_req=2 ttl=50 time=385 ms<br />
64 bytes from 74.125.224.146: icmp_req=3 ttl=50 time=298 ms<br />
<br />
--- www.l.google.com ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 1999ms<br />
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms<br />
</nowiki>}}<br />
<br />
如果沒問題的話,您可能只是想以本文的下列部分來自定您的設定。<br />
<br />
若剛才的指令出現了 unknown hosts 之類的訊息,代表您的機器無法解析網域。這可能是因為您的網路服務提供商/閘道造成的。您可以嘗試 ping 一個靜態 IP 以實驗您的機器能否存取網際網路。<br />
{{提示|您也可以嘗試使用其他的 IP ,如 168.95.1.1 。}}<br />
<br />
{{hc|$ ping -c 3 8.8.8.8|<nowiki><br />
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.<br />
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms<br />
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms<br />
64 bytes from 8.8.8.8: icmp_req=3 ttl=53 time=70.6 ms<br />
<br />
--- 8.8.8.8 ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 2002ms<br />
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms<br />
</nowiki>}}<br />
<br />
{{註記|{{ic|8.8.8.8}} 為一個好記的靜態 IP 位置。這是 Google 的主要 DNS 伺服器,這表示其有一定的可信度,並且通常不會被系統或代理伺服器擋下。}}<br />
<br />
若您可以 ping 通該位置,您可能需要試著在 {{ic|/etc/resolv.conf}} 檔案中加上網域名稱伺服器。<br />
<br />
== 設定主機名稱 ==<br />
<br />
[[Wikipedia:Hostname|主機名稱]]為網路中用於識別機器的唯一識別名稱:主機名稱可以通過 {{ic|/etc/hostname}} 檔案來進行設定。一般來說該檔案包含了系統的網域名稱。下面為設定主機名稱的方法:<br />
<br />
# hostnamectl set-hostname '''myhostname'''<br />
<br />
這樣會將 '''myhostname''' 寫入 {{ic|/etc/hostname}} 檔案中。<br />
<br />
詳細請參閱 {{ic|man 5 hostname}} 與 {{ic|man 1 hostnamectl}} 。<br />
<br />
{{註記|<br />
* {{ic|hostnamectl}} 支援 FQDN<br />
* 您不需要編輯 {{ic|/etc/hosts}} 檔案,{{pkg|systemd}} 會提供主機名稱解析且預設安裝於所有系統。<br />
}}<br />
<br />
使用來自 {{Pkg|inetutils}} 的 {{ic|hostname}} 指令以設定臨時主機名稱(直到重新啟動):<br />
<br />
# hostname ''myhostname''<br />
<br />
== 裝置驅動程式 ==<br />
<br />
=== 檢查驅動程式狀態 ===<br />
<br />
[[udev]] 應該會檢測您的網路介面卡([[Wikipedia:Network_interface_controller|NIC]])並自動於啟動時載入必要的模組。檢查 {{ic|lspci -v}} 輸出內容中的「Ethernet controller」 項目(或類似的)。這應該會告訴您哪些核心模組包含了網路設備的驅動程式。舉例來說:<br />
<br />
{{hc|$ lspci -v|<br />
02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)<br />
...<br />
Kernel driver in use: atl1<br />
Kernel modules: atl1<br />
}}<br />
<br />
接下來,確認該驅動程式已經通過 {{ic|dmesg <nowiki>|</nowiki> grep ''module_name''}} 載入了。舉例來說:<br />
<br />
$ dmesg | grep atl1<br />
...<br />
atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex<br />
<br />
若驅動程式已成功加載可以跳過接下來這段。否則,您會需要知道哪些模組時您的特定型號的裝置需要哪個模組。<br />
<br />
=== 載入裝置模組 ===<br />
<br />
以 Google 搜尋正確的晶片組模組/驅動程式。常見的驅動模組有 Realtek 晶片組網卡的 {{ic|8139too}} ,或是 SiS 晶片組網卡的 {{ic|sis900}}。當您知道要使用何種模組了之後,試著[[Kernel modules#Manual module handling|手動將其載入]]。若您得到了錯誤訊息告訴您找不到該模組,則該驅動可能未包含於 Arch 核心中。您可以在 [[AUR]] 中搜尋該模組名稱。<br />
<br />
若 udev 未在開機期間檢測與載入正確的模組,請參閱 [[Kernel modules#Loading]]。<br />
<br />
== 網路介面 ==<br />
<br />
=== 裝置名稱 ===<br />
<br />
對於多網路卡的電腦,固定裝置名稱非常重要。許多設定問題都是因為介面卡名稱的改動造成的。<br />
<br />
[[udev]] 負責命名裝置。Systemd v197 則有[http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames 可預測之網路介面名稱]並可自動支配靜態名稱給網路裝置。介面名稱以 {{ic|en}} (乙太網路)、 {{ic|wl}} (無線網路) 或是 {{ic|ww}} (WWAN)作為前置字串並附上一個自動產生的識別名稱,進而產生了類似 {{ic|enp0s25}} 這樣的名稱。 <br />
<br />
要禁用這種行為,可以加上一個連接:<br />
<br />
# ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules<br />
<br />
自早期版本升級 systemd 的使用者會有一自動建立的空規則檔案。因此,若您想使用一貫的裝置名稱,只需要刪除該檔案。<br />
<br />
{{提示|您可以執行 {{ic|ip link}} 或是 {{ic|ls /sys/class/net}} 以列出所有可用的介面。}}<br />
<br />
{{註記|當您更改了介面名稱規則後,別忘了更新所有跟網路有關的組態檔案與自定的 systemd unit 檔案以因應該更改。特別是當您啟用了 [[netctl#Basic method|netctl 靜態設定檔]] ,請執行 {{ic|netctl reenable ''profile''}} 以更新所有產生的服務檔案。}}<br />
<br />
==== 更改裝置名稱 ====<br />
<br />
您可以使用 udev-rule 來手動定義裝置名稱。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"<br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"<br />
</nowiki>}}<br />
<br />
請注意這兩點:<br />
<br />
* 使用這個指令以取得 MAC 位置:{{ic|cat /sys/class/net/''device_name''/address}}。<br />
* 請確定 udev 規則中使用的是小寫的十六進位數值而不是大寫。<br />
<br />
若您的網路卡為動態 MAC ,您可以使用 DEVPATH ,例如:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"<br />
</nowiki>}}<br />
<br />
{{註記|當使用了靜態的名稱時,'''應該要避免使用類似 "eth''X''" 與 "wlan''X''"''' 這樣的名稱,因為這可能會導致核心與 udev 在開機時發生衝突。而剛好相反地,最好使用核心預設不會使用的介面名稱,如 {{ic|net0}} 、 {{ic|net1}} 、 {{ic|wifi0}} 、 {{ic|wifi1}} 。詳細說明請參閱 [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames systemd] 文件。}}<br />
<br />
=== 設定裝置的 MTU 與佇列長度 ===<br />
<br />
您可以手動定義 udev 規則來更改裝置的 MTU 與佇列長度。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1480", ATTR{tx_queue_len}="2000"<br />
</nowiki>}}<br />
<br />
=== 取得目前的裝置名稱 ===<br />
<br />
目前的 NIC 名稱可以通過 sysfs 找到<br />
<br />
{{hc|$ ls /sys/class/net|<br />
lo eth0 eth1 firewire0<br />
}}<br />
<br />
=== 啟用與禁用網路介面 ===<br />
<br />
您可以使用下列指令來啟用或禁用網路介面:<br />
<br />
# ip link set eth0 up<br />
# ip link set eth0 down<br />
<br />
要確認結果,請執行:<br />
<br />
{{hc|$ ip link show dev eth0|<br />
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000<br />
...<br />
}}<br />
<br />
== 組態設定 IP 位址 ==<br />
<br />
您有兩個選擇:使用 [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]] 指派動態位址,或是使用「靜態」的位址。<br />
<br />
=== 動態 IP 位址 ===<br />
<br />
==== 手動執行 DHCP 用戶端 Daemon ====<br />
<br />
{{註記|請特別注意 {{ic|dhcpcd}} (DHCP ''Client'' Daemon,DHCP 用戶端 Daemon) 與 {{ic|dhcpd}} (DHCP ''(server)'' daemon,DHCP 伺服端 Daemon) 間的差異。}}<br />
<br />
{{hc|# dhcpcd eth0|<br />
dhcpcd: version 5.1.1 starting<br />
dhcpcd: eth0: broadcasting for a lease<br />
...<br />
dhcpcd: eth0: leased 192.168.1.70 for 86400 seconds<br />
}}<br />
<br />
緊接著, {{ic|ip addr show dev eth0}} 應該要顯示出您的 inet 位址。<br />
<br />
對部分的人而言,{{ic|dhcpcd}} 失敗時,可以使用 {{ic|dhclient}} (位於 {{Pkg|dhclient}} 軟體包中)<br />
<br />
==== 於啟動時執行 DHCP ====<br />
<br />
若您只是想使用 DHCP 來連線至您的乙太網路連線,您可以使用 {{ic|dhcpcd@.service}} (由 {{Pkg|dhcpcd}} 軟體包提供)。<br />
<br />
要啟動 {{ic|eth0}} 上的 DHCP ,只需要使用:<br />
<br />
# systemctl start dhcpcd@eth0.service<br />
<br />
您可以下列方法啟用該服務讓其於開機時自動啟動:<br />
<br />
# systemctl enable dhcpcd@eth0.service<br />
<br />
若您用了 DHCP 且您並 '''不想''' 讓您的 DNS 伺服器在每次啟動網路時自動指派,請將下列內容加到 {{ic|dhcpcd.conf}} 的最後一段中:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nohook resolv.conf<br />
}}<br />
<br />
另外,若您位於基於 MAC 位址的用戶端 IP 位址進行過濾的 DHCPv4 網路,您可能需要修改下列內容:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 Client ID as per RFC4361. <br />
duid<br />
}}<br />
<br />
為:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the hardware address of the interface for the Client ID (DHCPv4).<br />
clientid<br />
}}<br />
<br />
否則,您可能會因為 DHCP 伺服器無法正確讀取您的 [http://en.wikipedia.org/wiki/DHCPv6 DHCPv6-style] 用戶端 ID 而無法使用。詳細請參閱 [http://tools.ietf.org/html/rfc4361 RFC 4361] 。<br />
<br />
為防止 {{ic|dhcpcd}} 加入網域名稱伺服器至 {{ic|/etc/resolv.conf}} 中,請於其中使用 {{ic|nooption}} 選項:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nooption domain_name_servers<br />
}}<br />
<br />
接著加入您自己的 DNS 名稱伺服器至 {{ic|/etc/resolv.conf}} 中。<br />
<br />
若有多個不同的執行緒要控制 {{ic|/etc/resolv.conf}} (如 {{Pkg|dhcpcd}} 與 VPN 用戶端),您可能會想要使用 {{Pkg|openresolv}} 軟體包。使用 {{Pkg|openresolv}} 並不需要額外地設定 {{Pkg|dhcpcd}} 。<br />
<br />
==== DHCP 靜態路由 ====<br />
若您需要加入靜態路由用戶端,請於 {{ic|/usr/lib/dhcpcd/dhcpcd-hooks}} 中建立一個新的 dhcpcd hook-script 。下列範例展示了加入靜態路由至一個通過閘道為 192.168.192.5 ,位於 10.11.12.0/24 的 VPN 子網路:<br />
{{hc|/usr/lib/dhcpcd/dhcpcd-hooks/40-vpnroute|<br />
ip route add 10.11.12.0/24 via 192.168.192.5<br />
}}<br />
前置字串''40''表示其於 dhcpcd 啟動時的最後執行 hook-script 。<br />
<br />
=== 靜態 IP 位址 ===<br />
<br />
您可能因為各種原因而希望在您的網路中指派靜態 IP 位址,例如靜態的位址可以獲得一定程度的可預測性,或是您沒有可用的 DHCP 伺服器。<br />
<br />
{{註記|若您通過 Windows 機器來共享您的網路而不是使用路由器,請確保兩台電腦皆使用了靜態 IP 位址以避免區域網路問題。}}<br />
<br />
您需要:<br />
<br />
* 靜態 IP 位址<br />
* [[Wikipedia:Subnetwork|子網路遮罩]]<br />
* [[Wikipedia:Broadcast_address|廣播位址]]<br />
* [[Wikipedia:Default_gateway|預設閘道器]]的 IP 位址<br />
<br />
若您處在內部網路中,使用 192.168.*.* 這樣的 IP 位址較為安全,搭配其的子網路遮罩 255.255.255.0 ,廣播位址為 192.168.*.255 。而閘道通常是 192.168.*.1 或是 192.168.*.254 。<br />
<br />
==== 手動指派 ====<br />
<br />
您可於控制台中指派一靜態 IP 位址:<br />
<br />
# ip addr add <IP 位址>/<子網路遮罩> broadcast <廣播> dev <介面><br />
<br />
舉例來說:<br />
<br />
# ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev eth0<br />
<br />
{{註記|子網路遮罩使用了 [[Wikipedia:CIDR_notation|CIDR 表示法]](CIDR,Classless Inter-Domain Routing,無類別網路間路由)。}}<br />
<br />
詳情請參閱 {{ic|man ip}} 。<br />
<br />
以類似下列方法加上您的閘道:<br />
<br />
# ip route add default via <預設閘道 IP 位址><br />
<br />
舉例來說:<br />
<br />
# ip route add default via 192.168.1.1<br />
<br />
若您得到了 "No such process" 這樣的錯誤訊息,這代表您必須以 root 執行 {{ic|ip link set dev eth0 up}} 。<br />
<br />
==== 於啟動時通過 systemd 手動連線 ====<br />
<br />
先確保 dhcpcd 已停止並禁用:<br />
<br />
# systemctl status dhcpcd.service<br />
<br />
接著為 [[systemd]] 服務建立一個檔案。以正確的網路介面名稱取代其中的 {{ic|<interface>}} :<br />
<br />
{{hc|/etc/conf.d/network@<interface>|<nowiki><br />
address=192.168.0.15<br />
netmask=24<br />
broadcast=192.168.0.255<br />
gateway=192.168.0.1<br />
</nowiki>}}<br />
<br />
建立 systemd unit 檔案:<br />
<br />
{{hc|/etc/systemd/system/network@.service|<nowiki><br />
[Unit]<br />
Description=Network connectivity (%i)<br />
Wants=network.target<br />
Before=network.target<br />
BindsTo=sys-subsystem-net-devices-%i.device<br />
After=sys-subsystem-net-devices-%i.device<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
EnvironmentFile=/etc/conf.d/network@%i<br />
<br />
ExecStart=/usr/bin/ip link set dev %i up<br />
ExecStart=/usr/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i<br />
ExecStart=/usr/bin/ip route add default via ${gateway}<br />
<br />
ExecStop=/usr/bin/ip addr flush dev %i<br />
ExecStop=/usr/bin/ip link set dev %i down<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
啟用該 unit 並將其啟動,傳入介面名稱,例如 eno1 :<br />
<br />
# systemctl enable network@eno1.service<br />
# systemctl start network@eno1.service<br />
<br />
若您需要手動設定名稱伺服器,請編輯 {{ic|/etc/resolv.conf}} 檔案:<br />
<br />
{{hc|/etc/resolv.conf|<br />
nameserver 208.67.222.222<br />
nameserver 208.67.220.220}}<br />
<br />
若 {{ic|/etc/resolv.conf}} 被持續遭到複寫,請參考 [[Resolv.conf]] 以瞭解如何解決此問題。<br />
<br />
有幾個類似的方法來讓 systemd 啟動網路,其中的差異為檔案內容,並且其可以寫死 EnvironmentFile 定義的參考檔案中抓到的參數。因此可以作為一種替代的,將介面名稱放置於 /etc/conf.d/ 中的 EnvironmentFile ,接著直接使用介面名稱而不是 %i 。如此一來,檔案名稱便不需要「@」。這也是一種有用的方法,詳情請參閱[http://www.freedesktop.org/software/systemd/man/systemd.unit.html Systemd 服務文件]。<br />
<br />
==== 計算位址 ====<br />
<br />
您可以使用 {{Pkg|ipcalc}} 提供的 {{ic|ipcalc}} 來計算 IP 廣播、網域、子網路遮罩與主機範圍等進階設定舉例來說,我使用了位於防火牆後的乙太網路來連線 Windows 機器至 Arch。為了安全性與網路組織,我將他們放置於各自獨立的網路,接著組態設定子網路遮罩與廣播位址,如此一來網路中就只有兩台機器。為了找出子網路遮罩跟廣播位址,我使用了 ipcalc ,提供其 Arch firewire nic 的 IP 位址 10.66.66.1 ,並指定 ipcalc 要建立一個只有兩台主機的網路。<br />
<br />
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|<nowiki><br />
Address: 10.66.66.1<br />
<br />
Netmask: 255.255.255.252 = 30<br />
Network: 10.66.66.0/30<br />
HostMin: 10.66.66.1<br />
HostMax: 10.66.66.2<br />
Broadcast: 10.66.66.3<br />
Hosts/Net: 2 Class A, Private Internet<br />
</nowiki>}}<br />
<br />
== 載入組態設定 ==<br />
<br />
要測試您的設定,您可以重新啟動電腦或是重新載入相關的 systemd 服務:<br />
<br />
# systemctl restart dhcpcd@eth0<br />
<br />
您可以試著 ping 您的閘道、 DNS 伺服器、 ISP 提供商或是其他網路上的站台。如此一來便可以確認您的網路連線問題為何,例如:<br />
<br />
$ ping -c 3 www.google.com<br />
<br />
== 附加設定 ==<br />
<br />
=== 筆記型電腦之 ifplugd ===<br />
<br />
{{提示|{{Pkg|dhcpcd}} 提供了開箱即用的相同功能。}}<br />
<br />
[[Official Repositories (正體中文)|官方軟體套件庫]]中的 {{Pkg|ifplugd}} 為一個當網路線插入後自動組態乙太設備;網路線拔除後自動取消組態的 Daemon 。<br />
這對於搭載內建網路介面卡的筆記型電腦特別有用,因為其只會在網路線真正連上後才會對介面進行組態。另一個會用到的情況為,當您需要重新啟動網路,但您並不想重開及或在 Shell 中進行設定。<br />
<br />
預設情況下,其會對 {{ic|eth0}} 裝置進行設定使其運作。這與其他設定類似延遲之類的設定能在 {{ic|/etc/ifplugd/ifplugd.conf}} 中進行設定。<br />
<br />
<br />
{{註記|[[Netctl]] 軟體包包含了 {{ic|netctl-ifplugd@.service}},否則您可以使用來自 {{Pkg|ifplugd}} 軟體包的 {{ic|ifplugd@.service}} 。例如這樣使用:{{ic|systemctl enable ifplugd@eth0.service}}。}}<br />
<br />
=== Bonding 或 LAG ===<br />
<br />
請參閱 [[netctl#Bonding]] 。<br />
<br />
=== IP 別名 ===<br />
<br />
{{Expansion|Manual method using [[Core Utilities#ip|ip]] should be added; then move current example using ''netctl'' into [[netctl]].}}<br />
<br />
IP 別名為讓同一個網路介面有多個 IP 位址。如此一來,單個節點的網路就能有多個網路連線,進而實現不同的作用。經典的使用方法為網頁與 FTP 伺服器的虛擬主機,或是重組伺服器而無需更新任何其他的機器(對於名稱伺服器來說特別有用)。<br />
<br />
==== 範例 ====<br />
<br />
您將需要來自[[Official Repositories|官方軟體套件庫]]的 {{Pkg|netctl}} 。<br />
<br />
準備組態設定檔:<br />
<br />
{{hc|/etc/netctl/mynetwork|<nowiki><br />
Connection='ethernet'<br />
Description='Five different addresses on the same NIC.'<br />
Interface='eth0'<br />
IP='static'<br />
Address=('192.168.1.10' '192.168.178.11' '192.168.1.12' '192.168.1.13' '192.168.1.14' '192.168.1.15')<br />
Gateway='192.168.1.1'<br />
DNS=('192.168.1.1')<br />
</nowiki>}}<br />
<br />
接著只需要將其執行:<br />
<br />
$ netctl start mynetwork<br />
<br />
=== 更改 MAC/硬體 位址 ===<br />
<br />
請參閱 [[MAC Address Spoofing]] 。<br />
<br />
=== 網路共享 ===<br />
<br />
請參閱 [[Internet Sharing]] 。<br />
<br />
=== 路由組態設定 ===<br />
<br />
請參閱 [[Router]] 。<br />
<br />
=== 區域網路主機名稱解析 ===<br />
<br />
先決條件為[[#.E8.A8.AD.E5.AE.9A.E4.B8.BB.E6.A9.9F.E5.90.8D.E7.A8.B1|設定主機名稱]]之後,主機名稱可在本機系統上解析:<br />
{{hc|$ ping hostname|<br />
PING hostname <nowiki>(192.168.1.2) 56(84) bytes of data.<br />
64 bytes from hostname (192.168.1.2): icmp_seq=1 ttl=64 time=0.043 ms</nowiki>}}<br />
要以其他機器的名稱來解析主機,需要手動設定各自的 {{ic|/etc/hosts}} 檔案或是廣播/解析名稱的服務。<br />
<br />
過度設定 DNS 伺服器,如 [[BIND]] 、 [[Unbound]] ,手動編輯 {{ic|/etc/hosts}} 過於繁瑣,或是您希望對於動態地將主機離開、加入網路有更大的靈活性,您可以在您的區域網路中使用 Zero-configuration networking 來進行主機名稱解析。這裡有兩個可用選擇:<br />
<br />
*[[Samba]] 提供了通過微軟 '''NetBIOS''' 的主機名稱解析。其只需要安裝 {{Pkg|samba}} 並啟用 {{ic|nmbd.service}} 服務。執行 Windows 、OS X 或執行了 {{ic|nmbd}} 的 Linux ,將能夠找到您的機器。<br />
<br />
*[[Avahi]] 提供通過 '''zeroconf''' 的主機名稱解析,也稱作 Avahi 或 Boujour 。它比 Samba 還需要稍微複雜一點的設定:詳情請參考 [[Avahi#Hostname resolution]]。執行 OS X 或執行了 Avahi daemon 的 Linux ,將能夠找到您的機器。Windows 並無內建 Avahi 用戶端或 Daemon 。<br />
<br />
== 診斷 ==<br />
<br />
=== Swapping computers on the cable modem ===<br />
<br />
Some cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.<br />
<br />
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].<br />
<br />
=== The TCP window scaling problem ===<br />
<br />
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.<br />
<br />
Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html RFC 1323] was written to improve the situation: Window Scaling. The "window" value, provided in all packets, will be modified by a Scale Factor defined once, at the very beginning of the connection.<br />
<br />
That 8-bit Scale Factor allows the Window to be up to 32 times higher than the initial 64Kb.<br />
<br />
It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts.<br />
<br />
The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.<br />
<br />
The resulting connection is at best very slow or broken.<br />
<br />
==== How to diagnose the problem ====<br />
<br />
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).<br />
<br />
When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|ip addr}} will report normal status... and actually everything appears normal.<br />
<br />
If you cannot browse any website, but you can ping some random hosts, chances are great that you're experiencing this problem: ping uses ICMP and is not affected by TCP problems.<br />
<br />
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).<br />
<br />
==== How to fix it (The bad way) ====<br />
<br />
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.<br />
<br />
# echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem<br />
<br />
==== How to fix it (The good way) ====<br />
<br />
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.d/99-disable_window_scaling.conf}} (see also [[sysctl]])<br />
<br />
net.ipv4.tcp_window_scaling = 0<br />
<br />
==== How to fix it (The best way) ====<br />
<br />
This problem is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.<br />
<br />
==== More about it ====<br />
<br />
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].<br />
<br />
There are also several relevant threads on the LKML.<br />
<br />
=== Realtek no link / WOL problem ===<br />
<br />
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice a problem where the NIC seems to be disabled on boot and has no Link light. This can usually be found on a dual boot system where Windows is also installed. It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause. These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots. You will be able to notice if this problem is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off. Normal operation should be that the link light is always on as long as the system is on, even during POST. This problem will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this problem:<br />
<br />
==== Method 1 - Rollback/change Windows driver ====<br />
<br />
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).<br />
<br />
==== Method 2 - Enable WOL in Windows driver ====<br />
<br />
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems). In Windows, under Device Manager, find your Realtek network adapter and double-click it. Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.<br />
<br />
In Windows XP (example)<br />
Right click my computer<br />
--> Hardware tab<br />
--> Device Manager<br />
--> Network Adapters<br />
--> "double click" Realtek ...<br />
--> Advanced tab<br />
--> Wake-On-Lan After Shutdown<br />
--> Enable<br />
<br />
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{ic|Disable}} has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.}}<br />
<br />
==== Method 3 - Newer Realtek Linux driver ====<br />
<br />
Any newer driver for these Realtek cards can be found for Linux on the realtek site. (untested but believed to also solve the problem).<br />
<br />
==== Method 4 - Enable ''LAN Boot ROM'' in BIOS/CMOS ====<br />
<br />
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.<br />
<br />
{{Note|This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.}}<br />
<br />
=== DLink G604T/DLink G502T DNS problem ===<br />
<br />
Users with a DLink G604T/DLink G502T router, using DHCP and have firmware v2.00+ (typically users with AUS firmware) may have problems with certain programs not resolving the DNS. One of these programs are unfortunatley pacman. The problem is basically the router in certain situations is not sending the DNS properly to DHCP, which causes programs to try and connect to servers with an IP address of 1.0.0.0 and fail with a connection timed out error<br />
<br />
==== How to diagnose the problem ====<br />
<br />
The best way to diagnose the problem is to use Firefox/Konqueror/links/seamonkey and to enable wget for pacman. If this is a fresh install of Arch Linux, then you may want to consider installing {{ic|links}} through the live CD.<br />
<br />
Firstly, enable wget for pacman (since it gives us info about pacman when it is downloading packages)<br />
Open {{ic|/etc/pacman.conf}} with your favourite editor and uncomment the following line (remove the # if it is there)<br />
<br />
XferCommand=/usr/bin/wget --passive-ftp -c -O %o %u<br />
<br />
While you are editing {{ic|/etc/pacman.conf}}, check the default mirror that pacman uses to download packages.<br />
<br />
Now open up the default mirror in an Internet browser to see if the mirror actually works. If it does work, then do {{ic|pacman -Syy}} (otherwise pick another working mirror and set it to the pacman default). If you get something similar to the following (notice the 1.0.0.0),<br />
<br />
<nowiki>ftp://mirror.pacific.net.au/linux/archlinux/extra/os/i686/extra.db.tar.gz</nowiki><br />
=> '/var/lib/pacman/community.db.tar.gz.part'<br />
Resolving mirror.pacific.net.au... 1.0.0.0<br />
<br />
then you most likely have this problem. The 1.0.0.0 means it is unable to resolve DNS, so we must add it to {{ic|/etc/resolv.conf}}.<br />
<br />
==== How to fix it ====<br />
<br />
{{Out of date|{{Pkg|dhcpcd}} does not use {{ic|/etc/conf.d/dhcpcd}} any more.}}<br />
<br />
Basically what we need to do is to manually add the DNS servers to our {{ic|/etc/resolv.conf}} file. The problem is that DHCP automatically deletes and replaces this file on boot, so we need to edit {{ic|/etc/conf.d/dhcpcd}} and change the flags to stop DHCP from doing this.<br />
<br />
When you open {{ic|/etc/conf.d/dhcpcd}}, you should see something close to the following:<br />
<br />
DHCPCD_ARGS="-t 30 -h $HOSTNAME"<br />
<br />
Add the {{ic|-R}} flag to the arguments, e.g.,<br />
<br />
DHCPCD_ARGS="-R -t 30 -h $HOSTNAME"<br />
<br />
{{Note|1=If you are using {{Pkg|dhcpcd}} >= 4.0.2, the {{ic|-R}} flag has been deprecated. Please see the [[#Run DHCP at boot]] section for information on how to use a custom {{ic|/etc/resolv.conf}} file.}}<br />
<br />
Save and close the file; now open {{ic|/etc/resolv.conf}}. You should see a single nameserver (most likely 10.1.1.1). This is the gateway to your router, which we need to connect to in order to get the DNS servers of your ISP. Paste the IP address into your browser and log in to your router. Go to the DNS section, and you should see an IP address in the Primary DNS Server field; copy it and paste it as a nameserver '''ABOVE''' the current gateway one.<br />
<br />
For example, {{ic|/etc/resolv.conf}} should look something along the lines of:<br />
<br />
nameserver 10.1.1.1<br />
<br />
If my primary DNS server is 211.29.132.12, then change {{ic|/etc/resolv.conf}} to:<br />
<br />
nameserver 211.29.132.12<br />
nameserver 10.1.1.1<br />
<br />
Now restart the network daemon by running {{ic|systemctl restart dhcpcd@<interface>}} and do {{ic|pacman -Syy}}. If it syncs correctly with the server, then the problem is solved.<br />
<br />
==== More about it ====<br />
<br />
This is the whirlpool forum (Australian ISP community) which talks about and gives the same solution to the problem:<br />
<br />
http://forums.whirlpool.net.au/forum-replies-archive.cfm/461625.html<br />
<br />
=== Check DHCP problem by releasing IP first ===<br />
<br />
Problem may occur when DHCP get wrong IP assignment. For example when two routers are tied together through VPN. The router that is connected to me by VPN may assigning IP address. To fix it. On a console, as root, release IP address:<br />
<br />
# dhcpcd -k<br />
<br />
Then request a new one:<br />
<br />
# dhcpcd<br />
<br />
Maybe you had to run those two commands many times.<br />
<br />
=== No eth0 with Atheros AR8161 ===<br />
<br />
{{Note|With the 3.10.2-1-ARCH kernel update, the alx ethernet driver module is included in the package.}}<br />
<br />
With the Atheros AR8161 Gigabit Ethernet card, the ethernet connection is not working out-of-the-box (with the installation media of March 2013). The module "alx" needs to be loaded but is not present.<br />
<br />
The driver from [http://linuxwireless.org/en/users/Download/stable/#compat-wireless_stable_releases compat-wireless] (that has become [https://backports.wiki.kernel.org/index.php/Releases compat-drives] since linux 3.7) need to be installed. The "-u" postfix annotates that Qualcomm have applied a driver under a unified driver.<br />
<br />
$ wget https://www.kernel.org/pub/linux/kernel/projects/backports/2013/03/28/compat-drivers-2013-03-28-5-u.tar.bz2<br />
$ tar xjf compat*<br />
$ cd compat*<br />
$ ./scripts/driver-select alx<br />
$ make<br />
$ sudo make install<br />
$ sudo modprobe alx<br />
<br />
The alx driver has not been added to Linux kernel due to various problems. Compatibility between the different kernel versions has been spotty. For better support follow the [http://lists.infradead.org/mailman/listinfo/unified-drivers mailing list]and [http://www.linuxfoundation.org/collaborate/workgroups/networking/alx alx page]for latest working solution for alx.<br />
<br />
The driver must be built and installed after every kernel change.<br />
<br />
Alternatively you can use the AUR package for [https://aur.archlinux.org/packages/compat-drivers-patched/ compat drivers], which installs many other drivers.<br />
<br />
=== No eth0 with Atheros AR9485 ===<br />
<br />
The ethernet (eth0) for Atheros AR9485 are not working out-of-the-box (with installation media of March 2013). The working solution for this is to install the package [https://aur.archlinux.org/packages/compat-drivers-patched/ compat-drivers-patched] from AUR.<br />
<br />
=== No carrier / no connection after suspend ===<br />
After suspend to RAM no connection is found although the network cable is plugged in. <br />
This may be caused by PCI power management. What is the output of<br />
<br />
# ip link show eth0<br />
<br />
If the line contains "NO-CARRIER" even though there's a cable connected to your eth0 port, it is possible that the device was auto-suspended and the media sense feature doesn't work. To solve this, first you need to find your ethernet controllers PCI address by<br />
<br />
# lspci<br />
<br />
This should look similar to this:<br />
<br />
...<br />
00:19.0 Ethernet controller: Intel Corporation 82577LM Gigabit Network Connection (rev 06)<br />
...<br />
<br />
So the address is 00:19.0.<br />
Now check the PM status of the device by issuing<br />
<br />
# cat "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
substituting 00:19.0 with the address obtained from lspci.<br />
If the output reads "auto", you can try to bring the device out of suspend by<br />
<br />
# echo on > "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
Don't forget to substitute the address again.<br />
<br />
{{Note|1=This appears to be a bug in kernel 3.8.4.1- (3.8.8.1 is still affected): [https://bbs.archlinux.org/viewtopic.php?id=159837&p=2 Forum discussion.] It also appears a fix is [https://lkml.org/lkml/2013/1/18/147 on the way. (It will be likely fixed in 3.9.)] In the meantime, the above is a suitable workaround.}}<br />
<br />
=== Broadcom BCM57780 ===<br />
<br />
This Broadcom chipset sometimes does not behave well unless you specify the order of the modules to be loaded. The modules are {{ic|broadcom}} and {{ic|tg3}}, the former needing to be loaded first.<br />
<br />
These steps should help if your computer has this chipset:<br />
$ lspci | grep Ethernet<br />
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)<br />
<br />
If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following (as root):<br />
# modprobe -r tg3<br />
# modprobe broadcom<br />
# modprobe tg3<br />
<br />
Now plug you network cable in. If this solves your problems you can make this permanent by adding {{ic|broadcom}} and {{ic|tg3}} (in this order) to the {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}}:<br />
<br />
MODULES=".. broadcom tg3 .."<br />
<br />
Then rebuild the initramfs:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|These methods may work for other chipsets, such as BCM57760.}}</div>Binotahttps://wiki.archlinux.org/index.php?title=Network_configuration_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=293576Network configuration (正體中文)2014-01-19T13:24:45Z<p>Binota: /* 於啟動時通過 systemd 手動連線 */</p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:Networking (正體中文)]]<br />
[[Category:Getting and installing Arch (正體中文)]]<br />
<br />
[[cs:Configuring Network]]<br />
[[el:Configuring Network]]<br />
[[es:Configuring Network]]<br />
[[fr:Connexions reseau]]<br />
[[it:Configuring Network]]<br />
[[ja:Network Configuration]]<br />
[[nl:Configuring Network]]<br />
[[pt:Configuring Network]]<br />
[[ro:Configurare retea]]<br />
[[ru:Configuring Network]]<br />
[[sk:Configuring Network]]<br />
[[tr:Ağ_Yapılandırması]]<br />
[[zh-CN:Network Configuration]]<br />
[[zh-TW:Network Configuration]]<br />
{{Related articles start}}<br />
{{Related|Jumbo Frames}}<br />
{{Related|Firewalls}}<br />
{{Related|Wireless Setup}}<br />
{{Related|List of Applications#Network Managers}}<br />
{{Related articles end}}<br />
{{TranslationStatus (正體中文)|Network_Configuration|2014-01-19|293523}}<br />
<br />
本頁將介紹如何設定 '''有線''' 網路連線。若您需要設定 '''無線''' 網路,請參考[[Wireless Setup|無線網路設定]]。<br />
<br />
== 檢查連線 ==<br />
<br />
{{註記|若您在執行 ping 時收到了類似 {{ic|ping: icmp open socket: Operation not permitted}} 這樣的錯誤訊息,請嘗試重新安裝 {{ic|iputils}} 軟體包。}} <br />
<br />
一般來說,基本的安裝過程都已經建立了可運作的網路設定。請執行下列指令以進行檢查:<br />
<br />
{{註記|{{ic|-c 3}} 選項表示將會呼叫三次。詳細請參閱 {{ic|man ping}} 。}}<br />
{{提示|您也可以嘗試使用其他的 Domain ,如 www.hinet.net 。}}<br />
<br />
{{hc|$ ping -c 3 www.google.com|<nowiki><br />
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.<br />
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms<br />
64 bytes from 74.125.224.146: icmp_req=2 ttl=50 time=385 ms<br />
64 bytes from 74.125.224.146: icmp_req=3 ttl=50 time=298 ms<br />
<br />
--- www.l.google.com ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 1999ms<br />
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms<br />
</nowiki>}}<br />
<br />
如果沒問題的話,您可能只是想以本文的下列部分來自定您的設定。<br />
<br />
若剛才的指令出現了 unknown hosts 之類的訊息,代表您的機器無法解析網域。這可能是因為您的網路服務提供商/閘道造成的。您可以嘗試 ping 一個靜態 IP 以實驗您的機器能否存取網際網路。<br />
{{提示|您也可以嘗試使用其他的 IP ,如 168.95.1.1 。}}<br />
<br />
{{hc|$ ping -c 3 8.8.8.8|<nowiki><br />
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.<br />
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms<br />
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms<br />
64 bytes from 8.8.8.8: icmp_req=3 ttl=53 time=70.6 ms<br />
<br />
--- 8.8.8.8 ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 2002ms<br />
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms<br />
</nowiki>}}<br />
<br />
{{註記|{{ic|8.8.8.8}} 為一個好記的靜態 IP 位置。這是 Google 的主要 DNS 伺服器,這表示其有一定的可信度,並且通常不會被系統或代理伺服器擋下。}}<br />
<br />
若您可以 ping 通該位置,您可能需要試著在 {{ic|/etc/resolv.conf}} 檔案中加上網域名稱伺服器。<br />
<br />
== 設定主機名稱 ==<br />
<br />
[[Wikipedia:Hostname|主機名稱]]為網路中用於識別機器的唯一識別名稱:主機名稱可以通過 {{ic|/etc/hostname}} 檔案來進行設定。一般來說該檔案包含了系統的網域名稱。下面為設定主機名稱的方法:<br />
<br />
# hostnamectl set-hostname '''myhostname'''<br />
<br />
這樣會將 '''myhostname''' 寫入 {{ic|/etc/hostname}} 檔案中。<br />
<br />
詳細請參閱 {{ic|man 5 hostname}} 與 {{ic|man 1 hostnamectl}} 。<br />
<br />
{{註記|<br />
* {{ic|hostnamectl}} 支援 FQDN<br />
* 您不需要編輯 {{ic|/etc/hosts}} 檔案,{{pkg|systemd}} 會提供主機名稱解析且預設安裝於所有系統。<br />
}}<br />
<br />
使用來自 {{Pkg|inetutils}} 的 {{ic|hostname}} 指令以設定臨時主機名稱(直到重新啟動):<br />
<br />
# hostname ''myhostname''<br />
<br />
== 裝置驅動程式 ==<br />
<br />
=== 檢查驅動程式狀態 ===<br />
<br />
[[udev]] 應該會檢測您的網路介面卡([[Wikipedia:Network_interface_controller|NIC]])並自動於啟動時載入必要的模組。檢查 {{ic|lspci -v}} 輸出內容中的「Ethernet controller」 項目(或類似的)。這應該會告訴您哪些核心模組包含了網路設備的驅動程式。舉例來說:<br />
<br />
{{hc|$ lspci -v|<br />
02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)<br />
...<br />
Kernel driver in use: atl1<br />
Kernel modules: atl1<br />
}}<br />
<br />
接下來,確認該驅動程式已經通過 {{ic|dmesg <nowiki>|</nowiki> grep ''module_name''}} 載入了。舉例來說:<br />
<br />
$ dmesg | grep atl1<br />
...<br />
atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex<br />
<br />
若驅動程式已成功加載可以跳過接下來這段。否則,您會需要知道哪些模組時您的特定型號的裝置需要哪個模組。<br />
<br />
=== 載入裝置模組 ===<br />
<br />
以 Google 搜尋正確的晶片組模組/驅動程式。常見的驅動模組有 Realtek 晶片組網卡的 {{ic|8139too}} ,或是 SiS 晶片組網卡的 {{ic|sis900}}。當您知道要使用何種模組了之後,試著[[Kernel modules#Manual module handling|手動將其載入]]。若您得到了錯誤訊息告訴您找不到該模組,則該驅動可能未包含於 Arch 核心中。您可以在 [[AUR]] 中搜尋該模組名稱。<br />
<br />
若 udev 未在開機期間檢測與載入正確的模組,請參閱 [[Kernel modules#Loading]]。<br />
<br />
== 網路介面 ==<br />
<br />
=== 裝置名稱 ===<br />
<br />
對於多網路卡的電腦,固定裝置名稱非常重要。許多設定問題都是因為介面卡名稱的改動造成的。<br />
<br />
[[udev]] 負責命名裝置。Systemd v197 則有[http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames 可預測之網路介面名稱]並可自動支配靜態名稱給網路裝置。介面名稱以 {{ic|en}} (乙太網路)、 {{ic|wl}} (無線網路) 或是 {{ic|ww}} (WWAN)作為前置字串並附上一個自動產生的識別名稱,進而產生了類似 {{ic|enp0s25}} 這樣的名稱。 <br />
<br />
要禁用這種行為,可以加上一個連接:<br />
<br />
# ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules<br />
<br />
自早期版本升級 systemd 的使用者會有一自動建立的空規則檔案。因此,若您想使用一貫的裝置名稱,只需要刪除該檔案。<br />
<br />
{{提示|您可以執行 {{ic|ip link}} 或是 {{ic|ls /sys/class/net}} 以列出所有可用的介面。}}<br />
<br />
{{註記|當您更改了介面名稱規則後,別忘了更新所有跟網路有關的組態檔案與自定的 systemd unit 檔案以因應該更改。特別是當您啟用了 [[netctl#Basic method|netctl 靜態設定檔]] ,請執行 {{ic|netctl reenable ''profile''}} 以更新所有產生的服務檔案。}}<br />
<br />
==== 更改裝置名稱 ====<br />
<br />
您可以使用 udev-rule 來手動定義裝置名稱。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"<br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"<br />
</nowiki>}}<br />
<br />
請注意這兩點:<br />
<br />
* 使用這個指令以取得 MAC 位置:{{ic|cat /sys/class/net/''device_name''/address}}。<br />
* 請確定 udev 規則中使用的是小寫的十六進位數值而不是大寫。<br />
<br />
若您的網路卡為動態 MAC ,您可以使用 DEVPATH ,例如:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"<br />
</nowiki>}}<br />
<br />
{{註記|當使用了靜態的名稱時,'''應該要避免使用類似 "eth''X''" 與 "wlan''X''"''' 這樣的名稱,因為這可能會導致核心與 udev 在開機時發生衝突。而剛好相反地,最好使用核心預設不會使用的介面名稱,如 {{ic|net0}} 、 {{ic|net1}} 、 {{ic|wifi0}} 、 {{ic|wifi1}} 。詳細說明請參閱 [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames systemd] 文件。}}<br />
<br />
=== 設定裝置的 MTU 與佇列長度 ===<br />
<br />
您可以手動定義 udev 規則來更改裝置的 MTU 與佇列長度。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1480", ATTR{tx_queue_len}="2000"<br />
</nowiki>}}<br />
<br />
=== 取得目前的裝置名稱 ===<br />
<br />
目前的 NIC 名稱可以通過 sysfs 找到<br />
<br />
{{hc|$ ls /sys/class/net|<br />
lo eth0 eth1 firewire0<br />
}}<br />
<br />
=== 啟用與禁用網路介面 ===<br />
<br />
您可以使用下列指令來啟用或禁用網路介面:<br />
<br />
# ip link set eth0 up<br />
# ip link set eth0 down<br />
<br />
要確認結果,請執行:<br />
<br />
{{hc|$ ip link show dev eth0|<br />
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000<br />
...<br />
}}<br />
<br />
== 組態設定 IP 位址 ==<br />
<br />
您有兩個選擇:使用 [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]] 指派動態位址,或是使用「靜態」的位址。<br />
<br />
=== 動態 IP 位址 ===<br />
<br />
==== 手動執行 DHCP 用戶端 Daemon ====<br />
<br />
{{註記|請特別注意 {{ic|dhcpcd}} (DHCP ''Client'' Daemon,DHCP 用戶端 Daemon) 與 {{ic|dhcpd}} (DHCP ''(server)'' daemon,DHCP 伺服端 Daemon) 間的差異。}}<br />
<br />
{{hc|# dhcpcd eth0|<br />
dhcpcd: version 5.1.1 starting<br />
dhcpcd: eth0: broadcasting for a lease<br />
...<br />
dhcpcd: eth0: leased 192.168.1.70 for 86400 seconds<br />
}}<br />
<br />
緊接著, {{ic|ip addr show dev eth0}} 應該要顯示出您的 inet 位址。<br />
<br />
對部分的人而言,{{ic|dhcpcd}} 失敗時,可以使用 {{ic|dhclient}} (位於 {{Pkg|dhclient}} 軟體包中)<br />
<br />
==== 於啟動時執行 DHCP ====<br />
<br />
若您只是想使用 DHCP 來連線至您的乙太網路連線,您可以使用 {{ic|dhcpcd@.service}} (由 {{Pkg|dhcpcd}} 軟體包提供)。<br />
<br />
要啟動 {{ic|eth0}} 上的 DHCP ,只需要使用:<br />
<br />
# systemctl start dhcpcd@eth0.service<br />
<br />
您可以下列方法啟用該服務讓其於開機時自動啟動:<br />
<br />
# systemctl enable dhcpcd@eth0.service<br />
<br />
若您用了 DHCP 且您並 '''不想''' 讓您的 DNS 伺服器在每次啟動網路時自動指派,請將下列內容加到 {{ic|dhcpcd.conf}} 的最後一段中:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nohook resolv.conf<br />
}}<br />
<br />
另外,若您位於基於 MAC 位址的用戶端 IP 位址進行過濾的 DHCPv4 網路,您可能需要修改下列內容:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 Client ID as per RFC4361. <br />
duid<br />
}}<br />
<br />
為:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the hardware address of the interface for the Client ID (DHCPv4).<br />
clientid<br />
}}<br />
<br />
否則,您可能會因為 DHCP 伺服器無法正確讀取您的 [http://en.wikipedia.org/wiki/DHCPv6 DHCPv6-style] 用戶端 ID 而無法使用。詳細請參閱 [http://tools.ietf.org/html/rfc4361 RFC 4361] 。<br />
<br />
為防止 {{ic|dhcpcd}} 加入網域名稱伺服器至 {{ic|/etc/resolv.conf}} 中,請於其中使用 {{ic|nooption}} 選項:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nooption domain_name_servers<br />
}}<br />
<br />
接著加入您自己的 DNS 名稱伺服器至 {{ic|/etc/resolv.conf}} 中。<br />
<br />
若有多個不同的執行緒要控制 {{ic|/etc/resolv.conf}} (如 {{Pkg|dhcpcd}} 與 VPN 用戶端),您可能會想要使用 {{Pkg|openresolv}} 軟體包。使用 {{Pkg|openresolv}} 並不需要額外地設定 {{Pkg|dhcpcd}} 。<br />
<br />
==== DHCP 靜態路由 ====<br />
若您需要加入靜態路由用戶端,請於 {{ic|/usr/lib/dhcpcd/dhcpcd-hooks}} 中建立一個新的 dhcpcd hook-script 。下列範例展示了加入靜態路由至一個通過閘道為 192.168.192.5 ,位於 10.11.12.0/24 的 VPN 子網路:<br />
{{hc|/usr/lib/dhcpcd/dhcpcd-hooks/40-vpnroute|<br />
ip route add 10.11.12.0/24 via 192.168.192.5<br />
}}<br />
前置字串''40''表示其於 dhcpcd 啟動時的最後執行 hook-script 。<br />
<br />
=== 靜態 IP 位址 ===<br />
<br />
您可能因為各種原因而希望在您的網路中指派靜態 IP 位址,例如靜態的位址可以獲得一定程度的可預測性,或是您沒有可用的 DHCP 伺服器。<br />
<br />
{{註記|若您通過 Windows 機器來共享您的網路而不是使用路由器,請確保兩台電腦皆使用了靜態 IP 位址以避免區域網路問題。}}<br />
<br />
您需要:<br />
<br />
* 靜態 IP 位址<br />
* [[Wikipedia:Subnetwork|子網路遮罩]]<br />
* [[Wikipedia:Broadcast_address|廣播位址]]<br />
* [[Wikipedia:Default_gateway|預設閘道器]]的 IP 位址<br />
<br />
若您處在內部網路中,使用 192.168.*.* 這樣的 IP 位址較為安全,搭配其的子網路遮罩 255.255.255.0 ,廣播位址為 192.168.*.255 。而閘道通常是 192.168.*.1 或是 192.168.*.254 。<br />
<br />
==== 手動指派 ====<br />
<br />
您可於控制台中指派一靜態 IP 位址:<br />
<br />
# ip addr add <IP 位址>/<子網路遮罩> broadcast <廣播> dev <介面><br />
<br />
舉例來說:<br />
<br />
# ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev eth0<br />
<br />
{{註記|子網路遮罩使用了 [[Wikipedia:CIDR_notation|CIDR 表示法]](CIDR,Classless Inter-Domain Routing,無類別網路間路由)。}}<br />
<br />
詳情請參閱 {{ic|man ip}} 。<br />
<br />
以類似下列方法加上您的閘道:<br />
<br />
# ip route add default via <預設閘道 IP 位址><br />
<br />
舉例來說:<br />
<br />
# ip route add default via 192.168.1.1<br />
<br />
若您得到了 "No such process" 這樣的錯誤訊息,這代表您必須以 root 執行 {{ic|ip link set dev eth0 up}} 。<br />
<br />
==== 於啟動時通過 systemd 手動連線 ====<br />
<br />
先確保 dhcpcd 已停止並禁用:<br />
<br />
# systemctl status dhcpcd.service<br />
<br />
接著為 [[systemd]] 服務建立一個檔案。以正確的網路介面名稱取代其中的 {{ic|<interface>}} :<br />
<br />
{{hc|/etc/conf.d/network@<interface>|<nowiki><br />
address=192.168.0.15<br />
netmask=24<br />
broadcast=192.168.0.255<br />
gateway=192.168.0.1<br />
</nowiki>}}<br />
<br />
建立 systemd unit 檔案:<br />
<br />
{{hc|/etc/systemd/system/network@.service|<nowiki><br />
[Unit]<br />
Description=Network connectivity (%i)<br />
Wants=network.target<br />
Before=network.target<br />
BindsTo=sys-subsystem-net-devices-%i.device<br />
After=sys-subsystem-net-devices-%i.device<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
EnvironmentFile=/etc/conf.d/network@%i<br />
<br />
ExecStart=/usr/bin/ip link set dev %i up<br />
ExecStart=/usr/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i<br />
ExecStart=/usr/bin/ip route add default via ${gateway}<br />
<br />
ExecStop=/usr/bin/ip addr flush dev %i<br />
ExecStop=/usr/bin/ip link set dev %i down<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
啟用該 unit 並將其啟動,傳入介面名稱,例如 eno1 :<br />
<br />
# systemctl enable network@eno1.service<br />
# systemctl start network@eno1.service<br />
<br />
若您需要手動設定名稱伺服器,請編輯 {{ic|/etc/resolv.conf}} 檔案:<br />
<br />
{{hc|/etc/resolv.conf|<br />
nameserver 208.67.222.222<br />
nameserver 208.67.220.220}}<br />
<br />
若 {{ic|/etc/resolv.conf}} 被持續遭到複寫,請參考 [[Resolv.conf]] 以瞭解如何解決此問題。<br />
<br />
有幾個類似的方法來讓 systemd 啟動網路,其中的差異為檔案內容,並且其可以寫死 EnvironmentFile 定義的參考檔案中抓到的參數。因此可以作為一種替代的,將介面名稱放置於 /etc/conf.d/ 中的 EnvironmentFile ,接著直接使用介面名稱而不是 %i 。如此一來,檔案名稱便不需要「@」。這也是一種有用的方法,詳情請參閱[http://www.freedesktop.org/software/systemd/man/systemd.unit.html Systemd 服務文件]。<br />
<br />
==== 計算位址 ====<br />
<br />
您可以使用 {{Pkg|ipcalc}} 提供的 {{ic|ipcalc}} 來計算 IP 廣播、網域、子網路遮罩與主機範圍等進階設定舉例來說,我使用了位於防火牆後的乙太網路來連線 Windows 機器至 Arch。為了安全性與網路組織,我將他們放置於各自獨立的網路,接著組態設定子網路遮罩與廣播位址,如此一來網路中就只有兩台機器。為了找出子網路遮罩跟廣播位址,我使用了 ipcalc ,提供其 Arch firewire nic 的 IP 位址 10.66.66.1 ,並指定 ipcalc 要建立一個只有兩台主機的網路。<br />
<br />
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|<nowiki><br />
Address: 10.66.66.1<br />
<br />
Netmask: 255.255.255.252 = 30<br />
Network: 10.66.66.0/30<br />
HostMin: 10.66.66.1<br />
HostMax: 10.66.66.2<br />
Broadcast: 10.66.66.3<br />
Hosts/Net: 2 Class A, Private Internet<br />
</nowiki>}}<br />
<br />
== 載入組態設定 ==<br />
<br />
要測試您的設定,您可以重新啟動電腦或是重新載入相關的 systemd 服務:<br />
<br />
# systemctl restart dhcpcd@eth0<br />
<br />
您可以試著 ping 您的閘道、 DNS 伺服器、 ISP 提供商或是其他網路上的站台。如此一來便可以確認您的網路連線問題為何,例如:<br />
<br />
$ ping -c 3 www.google.com<br />
<br />
== 附加設定 ==<br />
<br />
=== 筆記型電腦之 ifplugd ===<br />
<br />
{{Tip|{{Pkg|dhcpcd}} provides the same feature out of the box.}}<br />
<br />
{{Pkg|ifplugd}} in [[Official Repositories]] is a daemon which will automatically configure your Ethernet device when a cable is plugged in and automatically unconfigure it if the cable is pulled. This is useful on laptops with onboard network adapters, since it will only configure the interface when a cable is really connected. Another use is when you just need to restart the network but do not want to restart the computer or do it from the shell.<br />
<br />
By default it is configured to work for the {{ic|eth0}} device. This and other settings like delays can be configured in {{ic|/etc/ifplugd/ifplugd.conf}}.<br />
<br />
{{Note|[[Netctl]] package includes {{ic|netctl-ifplugd@.service}}, otherwise you can use {{ic|ifplugd@.service}} from {{Pkg|ifplugd}} package. Use for example {{ic|systemctl enable ifplugd@eth0.service}}.}}<br />
<br />
=== Bonding 或 LAG ===<br />
<br />
請參閱 [[netctl#Bonding]] 。<br />
<br />
=== IP 別名 ===<br />
<br />
{{Expansion|Manual method using [[Core Utilities#ip|ip]] should be added; then move current example using ''netctl'' into [[netctl]].}}<br />
<br />
IP 別名為讓同一個網路介面有多個 IP 位址。如此一來,單個節點的網路就能有多個網路連線,進而實現不同的作用。經典的使用方法為網頁與 FTP 伺服器的虛擬主機,或是重組伺服器而無需更新任何其他的機器(對於名稱伺服器來說特別有用)。<br />
<br />
==== 範例 ====<br />
<br />
您將需要來自[[Official Repositories|官方軟體套件庫]]的 {{Pkg|netctl}} 。<br />
<br />
準備組態設定檔:<br />
<br />
{{hc|/etc/netctl/mynetwork|<nowiki><br />
Connection='ethernet'<br />
Description='Five different addresses on the same NIC.'<br />
Interface='eth0'<br />
IP='static'<br />
Address=('192.168.1.10' '192.168.178.11' '192.168.1.12' '192.168.1.13' '192.168.1.14' '192.168.1.15')<br />
Gateway='192.168.1.1'<br />
DNS=('192.168.1.1')<br />
</nowiki>}}<br />
<br />
接著只需要將其執行:<br />
<br />
$ netctl start mynetwork<br />
<br />
=== 更改 MAC/硬體 位址 ===<br />
<br />
請參閱 [[MAC Address Spoofing]] 。<br />
<br />
=== 網路共享 ===<br />
<br />
請參閱 [[Internet Sharing]] 。<br />
<br />
=== 路由組態設定 ===<br />
<br />
請參閱 [[Router]] 。<br />
<br />
=== 區域網路主機名稱解析 ===<br />
<br />
先決條件為[[#.E8.A8.AD.E5.AE.9A.E4.B8.BB.E6.A9.9F.E5.90.8D.E7.A8.B1|設定主機名稱]]之後,主機名稱可在本機系統上解析:<br />
{{hc|$ ping hostname|<br />
PING hostname <nowiki>(192.168.1.2) 56(84) bytes of data.<br />
64 bytes from hostname (192.168.1.2): icmp_seq=1 ttl=64 time=0.043 ms</nowiki>}}<br />
要以其他機器的名稱來解析主機,需要手動設定各自的 {{ic|/etc/hosts}} 檔案或是廣播/解析名稱的服務。<br />
<br />
過度設定 DNS 伺服器,如 [[BIND]] 、 [[Unbound]] ,手動編輯 {{ic|/etc/hosts}} 過於繁瑣,或是您希望對於動態地將主機離開、加入網路有更大的靈活性,您可以在您的區域網路中使用 Zero-configuration networking 來進行主機名稱解析。這裡有兩個可用選擇:<br />
<br />
*[[Samba]] 提供了通過微軟 '''NetBIOS''' 的主機名稱解析。其只需要安裝 {{Pkg|samba}} 並啟用 {{ic|nmbd.service}} 服務。執行 Windows 、OS X 或執行了 {{ic|nmbd}} 的 Linux ,將能夠找到您的機器。<br />
<br />
*[[Avahi]] 提供通過 '''zeroconf''' 的主機名稱解析,也稱作 Avahi 或 Boujour 。它比 Samba 還需要稍微複雜一點的設定:詳情請參考 [[Avahi#Hostname resolution]]。執行 OS X 或執行了 Avahi daemon 的 Linux ,將能夠找到您的機器。Windows 並無內建 Avahi 用戶端或 Daemon 。<br />
<br />
== 診斷 ==<br />
<br />
=== Swapping computers on the cable modem ===<br />
<br />
Some cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.<br />
<br />
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].<br />
<br />
=== The TCP window scaling problem ===<br />
<br />
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.<br />
<br />
Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html RFC 1323] was written to improve the situation: Window Scaling. The "window" value, provided in all packets, will be modified by a Scale Factor defined once, at the very beginning of the connection.<br />
<br />
That 8-bit Scale Factor allows the Window to be up to 32 times higher than the initial 64Kb.<br />
<br />
It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts.<br />
<br />
The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.<br />
<br />
The resulting connection is at best very slow or broken.<br />
<br />
==== How to diagnose the problem ====<br />
<br />
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).<br />
<br />
When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|ip addr}} will report normal status... and actually everything appears normal.<br />
<br />
If you cannot browse any website, but you can ping some random hosts, chances are great that you're experiencing this problem: ping uses ICMP and is not affected by TCP problems.<br />
<br />
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).<br />
<br />
==== How to fix it (The bad way) ====<br />
<br />
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.<br />
<br />
# echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem<br />
<br />
==== How to fix it (The good way) ====<br />
<br />
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.d/99-disable_window_scaling.conf}} (see also [[sysctl]])<br />
<br />
net.ipv4.tcp_window_scaling = 0<br />
<br />
==== How to fix it (The best way) ====<br />
<br />
This problem is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.<br />
<br />
==== More about it ====<br />
<br />
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].<br />
<br />
There are also several relevant threads on the LKML.<br />
<br />
=== Realtek no link / WOL problem ===<br />
<br />
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice a problem where the NIC seems to be disabled on boot and has no Link light. This can usually be found on a dual boot system where Windows is also installed. It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause. These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots. You will be able to notice if this problem is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off. Normal operation should be that the link light is always on as long as the system is on, even during POST. This problem will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this problem:<br />
<br />
==== Method 1 - Rollback/change Windows driver ====<br />
<br />
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).<br />
<br />
==== Method 2 - Enable WOL in Windows driver ====<br />
<br />
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems). In Windows, under Device Manager, find your Realtek network adapter and double-click it. Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.<br />
<br />
In Windows XP (example)<br />
Right click my computer<br />
--> Hardware tab<br />
--> Device Manager<br />
--> Network Adapters<br />
--> "double click" Realtek ...<br />
--> Advanced tab<br />
--> Wake-On-Lan After Shutdown<br />
--> Enable<br />
<br />
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{ic|Disable}} has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.}}<br />
<br />
==== Method 3 - Newer Realtek Linux driver ====<br />
<br />
Any newer driver for these Realtek cards can be found for Linux on the realtek site. (untested but believed to also solve the problem).<br />
<br />
==== Method 4 - Enable ''LAN Boot ROM'' in BIOS/CMOS ====<br />
<br />
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.<br />
<br />
{{Note|This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.}}<br />
<br />
=== DLink G604T/DLink G502T DNS problem ===<br />
<br />
Users with a DLink G604T/DLink G502T router, using DHCP and have firmware v2.00+ (typically users with AUS firmware) may have problems with certain programs not resolving the DNS. One of these programs are unfortunatley pacman. The problem is basically the router in certain situations is not sending the DNS properly to DHCP, which causes programs to try and connect to servers with an IP address of 1.0.0.0 and fail with a connection timed out error<br />
<br />
==== How to diagnose the problem ====<br />
<br />
The best way to diagnose the problem is to use Firefox/Konqueror/links/seamonkey and to enable wget for pacman. If this is a fresh install of Arch Linux, then you may want to consider installing {{ic|links}} through the live CD.<br />
<br />
Firstly, enable wget for pacman (since it gives us info about pacman when it is downloading packages)<br />
Open {{ic|/etc/pacman.conf}} with your favourite editor and uncomment the following line (remove the # if it is there)<br />
<br />
XferCommand=/usr/bin/wget --passive-ftp -c -O %o %u<br />
<br />
While you are editing {{ic|/etc/pacman.conf}}, check the default mirror that pacman uses to download packages.<br />
<br />
Now open up the default mirror in an Internet browser to see if the mirror actually works. If it does work, then do {{ic|pacman -Syy}} (otherwise pick another working mirror and set it to the pacman default). If you get something similar to the following (notice the 1.0.0.0),<br />
<br />
<nowiki>ftp://mirror.pacific.net.au/linux/archlinux/extra/os/i686/extra.db.tar.gz</nowiki><br />
=> '/var/lib/pacman/community.db.tar.gz.part'<br />
Resolving mirror.pacific.net.au... 1.0.0.0<br />
<br />
then you most likely have this problem. The 1.0.0.0 means it is unable to resolve DNS, so we must add it to {{ic|/etc/resolv.conf}}.<br />
<br />
==== How to fix it ====<br />
<br />
{{Out of date|{{Pkg|dhcpcd}} does not use {{ic|/etc/conf.d/dhcpcd}} any more.}}<br />
<br />
Basically what we need to do is to manually add the DNS servers to our {{ic|/etc/resolv.conf}} file. The problem is that DHCP automatically deletes and replaces this file on boot, so we need to edit {{ic|/etc/conf.d/dhcpcd}} and change the flags to stop DHCP from doing this.<br />
<br />
When you open {{ic|/etc/conf.d/dhcpcd}}, you should see something close to the following:<br />
<br />
DHCPCD_ARGS="-t 30 -h $HOSTNAME"<br />
<br />
Add the {{ic|-R}} flag to the arguments, e.g.,<br />
<br />
DHCPCD_ARGS="-R -t 30 -h $HOSTNAME"<br />
<br />
{{Note|1=If you are using {{Pkg|dhcpcd}} >= 4.0.2, the {{ic|-R}} flag has been deprecated. Please see the [[#Run DHCP at boot]] section for information on how to use a custom {{ic|/etc/resolv.conf}} file.}}<br />
<br />
Save and close the file; now open {{ic|/etc/resolv.conf}}. You should see a single nameserver (most likely 10.1.1.1). This is the gateway to your router, which we need to connect to in order to get the DNS servers of your ISP. Paste the IP address into your browser and log in to your router. Go to the DNS section, and you should see an IP address in the Primary DNS Server field; copy it and paste it as a nameserver '''ABOVE''' the current gateway one.<br />
<br />
For example, {{ic|/etc/resolv.conf}} should look something along the lines of:<br />
<br />
nameserver 10.1.1.1<br />
<br />
If my primary DNS server is 211.29.132.12, then change {{ic|/etc/resolv.conf}} to:<br />
<br />
nameserver 211.29.132.12<br />
nameserver 10.1.1.1<br />
<br />
Now restart the network daemon by running {{ic|systemctl restart dhcpcd@<interface>}} and do {{ic|pacman -Syy}}. If it syncs correctly with the server, then the problem is solved.<br />
<br />
==== More about it ====<br />
<br />
This is the whirlpool forum (Australian ISP community) which talks about and gives the same solution to the problem:<br />
<br />
http://forums.whirlpool.net.au/forum-replies-archive.cfm/461625.html<br />
<br />
=== Check DHCP problem by releasing IP first ===<br />
<br />
Problem may occur when DHCP get wrong IP assignment. For example when two routers are tied together through VPN. The router that is connected to me by VPN may assigning IP address. To fix it. On a console, as root, release IP address:<br />
<br />
# dhcpcd -k<br />
<br />
Then request a new one:<br />
<br />
# dhcpcd<br />
<br />
Maybe you had to run those two commands many times.<br />
<br />
=== No eth0 with Atheros AR8161 ===<br />
<br />
{{Note|With the 3.10.2-1-ARCH kernel update, the alx ethernet driver module is included in the package.}}<br />
<br />
With the Atheros AR8161 Gigabit Ethernet card, the ethernet connection is not working out-of-the-box (with the installation media of March 2013). The module "alx" needs to be loaded but is not present.<br />
<br />
The driver from [http://linuxwireless.org/en/users/Download/stable/#compat-wireless_stable_releases compat-wireless] (that has become [https://backports.wiki.kernel.org/index.php/Releases compat-drives] since linux 3.7) need to be installed. The "-u" postfix annotates that Qualcomm have applied a driver under a unified driver.<br />
<br />
$ wget https://www.kernel.org/pub/linux/kernel/projects/backports/2013/03/28/compat-drivers-2013-03-28-5-u.tar.bz2<br />
$ tar xjf compat*<br />
$ cd compat*<br />
$ ./scripts/driver-select alx<br />
$ make<br />
$ sudo make install<br />
$ sudo modprobe alx<br />
<br />
The alx driver has not been added to Linux kernel due to various problems. Compatibility between the different kernel versions has been spotty. For better support follow the [http://lists.infradead.org/mailman/listinfo/unified-drivers mailing list]and [http://www.linuxfoundation.org/collaborate/workgroups/networking/alx alx page]for latest working solution for alx.<br />
<br />
The driver must be built and installed after every kernel change.<br />
<br />
Alternatively you can use the AUR package for [https://aur.archlinux.org/packages/compat-drivers-patched/ compat drivers], which installs many other drivers.<br />
<br />
=== No eth0 with Atheros AR9485 ===<br />
<br />
The ethernet (eth0) for Atheros AR9485 are not working out-of-the-box (with installation media of March 2013). The working solution for this is to install the package [https://aur.archlinux.org/packages/compat-drivers-patched/ compat-drivers-patched] from AUR.<br />
<br />
=== No carrier / no connection after suspend ===<br />
After suspend to RAM no connection is found although the network cable is plugged in. <br />
This may be caused by PCI power management. What is the output of<br />
<br />
# ip link show eth0<br />
<br />
If the line contains "NO-CARRIER" even though there's a cable connected to your eth0 port, it is possible that the device was auto-suspended and the media sense feature doesn't work. To solve this, first you need to find your ethernet controllers PCI address by<br />
<br />
# lspci<br />
<br />
This should look similar to this:<br />
<br />
...<br />
00:19.0 Ethernet controller: Intel Corporation 82577LM Gigabit Network Connection (rev 06)<br />
...<br />
<br />
So the address is 00:19.0.<br />
Now check the PM status of the device by issuing<br />
<br />
# cat "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
substituting 00:19.0 with the address obtained from lspci.<br />
If the output reads "auto", you can try to bring the device out of suspend by<br />
<br />
# echo on > "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
Don't forget to substitute the address again.<br />
<br />
{{Note|1=This appears to be a bug in kernel 3.8.4.1- (3.8.8.1 is still affected): [https://bbs.archlinux.org/viewtopic.php?id=159837&p=2 Forum discussion.] It also appears a fix is [https://lkml.org/lkml/2013/1/18/147 on the way. (It will be likely fixed in 3.9.)] In the meantime, the above is a suitable workaround.}}<br />
<br />
=== Broadcom BCM57780 ===<br />
<br />
This Broadcom chipset sometimes does not behave well unless you specify the order of the modules to be loaded. The modules are {{ic|broadcom}} and {{ic|tg3}}, the former needing to be loaded first.<br />
<br />
These steps should help if your computer has this chipset:<br />
$ lspci | grep Ethernet<br />
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)<br />
<br />
If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following (as root):<br />
# modprobe -r tg3<br />
# modprobe broadcom<br />
# modprobe tg3<br />
<br />
Now plug you network cable in. If this solves your problems you can make this permanent by adding {{ic|broadcom}} and {{ic|tg3}} (in this order) to the {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}}:<br />
<br />
MODULES=".. broadcom tg3 .."<br />
<br />
Then rebuild the initramfs:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|These methods may work for other chipsets, such as BCM57760.}}</div>Binotahttps://wiki.archlinux.org/index.php?title=Network_configuration_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=293574Network configuration (正體中文)2014-01-19T12:40:27Z<p>Binota: Corrected some typo 修正錯字、筆誤以及排版。</p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:Networking (正體中文)]]<br />
[[Category:Getting and installing Arch (正體中文)]]<br />
<br />
[[cs:Configuring Network]]<br />
[[el:Configuring Network]]<br />
[[es:Configuring Network]]<br />
[[fr:Connexions reseau]]<br />
[[it:Configuring Network]]<br />
[[ja:Network Configuration]]<br />
[[nl:Configuring Network]]<br />
[[pt:Configuring Network]]<br />
[[ro:Configurare retea]]<br />
[[ru:Configuring Network]]<br />
[[sk:Configuring Network]]<br />
[[tr:Ağ_Yapılandırması]]<br />
[[zh-CN:Network Configuration]]<br />
[[zh-TW:Network Configuration]]<br />
{{Related articles start}}<br />
{{Related|Jumbo Frames}}<br />
{{Related|Firewalls}}<br />
{{Related|Wireless Setup}}<br />
{{Related|List of Applications#Network Managers}}<br />
{{Related articles end}}<br />
{{TranslationStatus (正體中文)|Network_Configuration|2014-01-19|293523}}<br />
<br />
本頁將介紹如何設定 '''有線''' 網路連線。若您需要設定 '''無線''' 網路,請參考[[Wireless Setup|無線網路設定]]。<br />
<br />
== 檢查連線 ==<br />
<br />
{{註記|若您在執行 ping 時收到了類似 {{ic|ping: icmp open socket: Operation not permitted}} 這樣的錯誤訊息,請嘗試重新安裝 {{ic|iputils}} 軟體包。}} <br />
<br />
一般來說,基本的安裝過程都已經建立了可運作的網路設定。請執行下列指令以進行檢查:<br />
<br />
{{註記|{{ic|-c 3}} 選項表示將會呼叫三次。詳細請參閱 {{ic|man ping}} 。}}<br />
{{提示|您也可以嘗試使用其他的 Domain ,如 www.hinet.net 。}}<br />
<br />
{{hc|$ ping -c 3 www.google.com|<nowiki><br />
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.<br />
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms<br />
64 bytes from 74.125.224.146: icmp_req=2 ttl=50 time=385 ms<br />
64 bytes from 74.125.224.146: icmp_req=3 ttl=50 time=298 ms<br />
<br />
--- www.l.google.com ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 1999ms<br />
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms<br />
</nowiki>}}<br />
<br />
如果沒問題的話,您可能只是想以本文的下列部分來自定您的設定。<br />
<br />
若剛才的指令出現了 unknown hosts 之類的訊息,代表您的機器無法解析網域。這可能是因為您的網路服務提供商/閘道造成的。您可以嘗試 ping 一個靜態 IP 以實驗您的機器能否存取網際網路。<br />
{{提示|您也可以嘗試使用其他的 IP ,如 168.95.1.1 。}}<br />
<br />
{{hc|$ ping -c 3 8.8.8.8|<nowiki><br />
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.<br />
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms<br />
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms<br />
64 bytes from 8.8.8.8: icmp_req=3 ttl=53 time=70.6 ms<br />
<br />
--- 8.8.8.8 ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 2002ms<br />
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms<br />
</nowiki>}}<br />
<br />
{{註記|{{ic|8.8.8.8}} 為一個好記的靜態 IP 位置。這是 Google 的主要 DNS 伺服器,這表示其有一定的可信度,並且通常不會被系統或代理伺服器擋下。}}<br />
<br />
若您可以 ping 通該位置,您可能需要試著在 {{ic|/etc/resolv.conf}} 檔案中加上網域名稱伺服器。<br />
<br />
== 設定主機名稱 ==<br />
<br />
[[Wikipedia:Hostname|主機名稱]]為網路中用於識別機器的唯一識別名稱:主機名稱可以通過 {{ic|/etc/hostname}} 檔案來進行設定。一般來說該檔案包含了系統的網域名稱。下面為設定主機名稱的方法:<br />
<br />
# hostnamectl set-hostname '''myhostname'''<br />
<br />
這樣會將 '''myhostname''' 寫入 {{ic|/etc/hostname}} 檔案中。<br />
<br />
詳細請參閱 {{ic|man 5 hostname}} 與 {{ic|man 1 hostnamectl}} 。<br />
<br />
{{註記|<br />
* {{ic|hostnamectl}} 支援 FQDN<br />
* 您不需要編輯 {{ic|/etc/hosts}} 檔案,{{pkg|systemd}} 會提供主機名稱解析且預設安裝於所有系統。<br />
}}<br />
<br />
使用來自 {{Pkg|inetutils}} 的 {{ic|hostname}} 指令以設定臨時主機名稱(直到重新啟動):<br />
<br />
# hostname ''myhostname''<br />
<br />
== 裝置驅動程式 ==<br />
<br />
=== 檢查驅動程式狀態 ===<br />
<br />
[[udev]] 應該會檢測您的網路介面卡([[Wikipedia:Network_interface_controller|NIC]])並自動於啟動時載入必要的模組。檢查 {{ic|lspci -v}} 輸出內容中的「Ethernet controller」 項目(或類似的)。這應該會告訴您哪些核心模組包含了網路設備的驅動程式。舉例來說:<br />
<br />
{{hc|$ lspci -v|<br />
02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)<br />
...<br />
Kernel driver in use: atl1<br />
Kernel modules: atl1<br />
}}<br />
<br />
接下來,確認該驅動程式已經通過 {{ic|dmesg <nowiki>|</nowiki> grep ''module_name''}} 載入了。舉例來說:<br />
<br />
$ dmesg | grep atl1<br />
...<br />
atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex<br />
<br />
若驅動程式已成功加載可以跳過接下來這段。否則,您會需要知道哪些模組時您的特定型號的裝置需要哪個模組。<br />
<br />
=== 載入裝置模組 ===<br />
<br />
以 Google 搜尋正確的晶片組模組/驅動程式。常見的驅動模組有 Realtek 晶片組網卡的 {{ic|8139too}} ,或是 SiS 晶片組網卡的 {{ic|sis900}}。當您知道要使用何種模組了之後,試著[[Kernel modules#Manual module handling|手動將其載入]]。若您得到了錯誤訊息告訴您找不到該模組,則該驅動可能未包含於 Arch 核心中。您可以在 [[AUR]] 中搜尋該模組名稱。<br />
<br />
若 udev 未在開機期間檢測與載入正確的模組,請參閱 [[Kernel modules#Loading]]。<br />
<br />
== 網路介面 ==<br />
<br />
=== 裝置名稱 ===<br />
<br />
對於多網路卡的電腦,固定裝置名稱非常重要。許多設定問題都是因為介面卡名稱的改動造成的。<br />
<br />
[[udev]] 負責命名裝置。Systemd v197 則有[http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames 可預測之網路介面名稱]並可自動支配靜態名稱給網路裝置。介面名稱以 {{ic|en}} (乙太網路)、 {{ic|wl}} (無線網路) 或是 {{ic|ww}} (WWAN)作為前置字串並附上一個自動產生的識別名稱,進而產生了類似 {{ic|enp0s25}} 這樣的名稱。 <br />
<br />
要禁用這種行為,可以加上一個連接:<br />
<br />
# ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules<br />
<br />
自早期版本升級 systemd 的使用者會有一自動建立的空規則檔案。因此,若您想使用一貫的裝置名稱,只需要刪除該檔案。<br />
<br />
{{提示|您可以執行 {{ic|ip link}} 或是 {{ic|ls /sys/class/net}} 以列出所有可用的介面。}}<br />
<br />
{{註記|當您更改了介面名稱規則後,別忘了更新所有跟網路有關的組態檔案與自定的 systemd unit 檔案以因應該更改。特別是當您啟用了 [[netctl#Basic method|netctl 靜態設定檔]] ,請執行 {{ic|netctl reenable ''profile''}} 以更新所有產生的服務檔案。}}<br />
<br />
==== 更改裝置名稱 ====<br />
<br />
您可以使用 udev-rule 來手動定義裝置名稱。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"<br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"<br />
</nowiki>}}<br />
<br />
請注意這兩點:<br />
<br />
* 使用這個指令以取得 MAC 位置:{{ic|cat /sys/class/net/''device_name''/address}}。<br />
* 請確定 udev 規則中使用的是小寫的十六進位數值而不是大寫。<br />
<br />
若您的網路卡為動態 MAC ,您可以使用 DEVPATH ,例如:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"<br />
</nowiki>}}<br />
<br />
{{註記|當使用了靜態的名稱時,'''應該要避免使用類似 "eth''X''" 與 "wlan''X''"''' 這樣的名稱,因為這可能會導致核心與 udev 在開機時發生衝突。而剛好相反地,最好使用核心預設不會使用的介面名稱,如 {{ic|net0}} 、 {{ic|net1}} 、 {{ic|wifi0}} 、 {{ic|wifi1}} 。詳細說明請參閱 [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames systemd] 文件。}}<br />
<br />
=== 設定裝置的 MTU 與佇列長度 ===<br />
<br />
您可以手動定義 udev 規則來更改裝置的 MTU 與佇列長度。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1480", ATTR{tx_queue_len}="2000"<br />
</nowiki>}}<br />
<br />
=== 取得目前的裝置名稱 ===<br />
<br />
目前的 NIC 名稱可以通過 sysfs 找到<br />
<br />
{{hc|$ ls /sys/class/net|<br />
lo eth0 eth1 firewire0<br />
}}<br />
<br />
=== 啟用與禁用網路介面 ===<br />
<br />
您可以使用下列指令來啟用或禁用網路介面:<br />
<br />
# ip link set eth0 up<br />
# ip link set eth0 down<br />
<br />
要確認結果,請執行:<br />
<br />
{{hc|$ ip link show dev eth0|<br />
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000<br />
...<br />
}}<br />
<br />
== 組態設定 IP 位址 ==<br />
<br />
您有兩個選擇:使用 [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]] 指派動態位址,或是使用「靜態」的位址。<br />
<br />
=== 動態 IP 位址 ===<br />
<br />
==== 手動執行 DHCP 用戶端 Daemon ====<br />
<br />
{{註記|請特別注意 {{ic|dhcpcd}} (DHCP ''Client'' Daemon,DHCP 用戶端 Daemon) 與 {{ic|dhcpd}} (DHCP ''(server)'' daemon,DHCP 伺服端 Daemon) 間的差異。}}<br />
<br />
{{hc|# dhcpcd eth0|<br />
dhcpcd: version 5.1.1 starting<br />
dhcpcd: eth0: broadcasting for a lease<br />
...<br />
dhcpcd: eth0: leased 192.168.1.70 for 86400 seconds<br />
}}<br />
<br />
緊接著, {{ic|ip addr show dev eth0}} 應該要顯示出您的 inet 位址。<br />
<br />
對部分的人而言,{{ic|dhcpcd}} 失敗時,可以使用 {{ic|dhclient}} (位於 {{Pkg|dhclient}} 軟體包中)<br />
<br />
==== 於啟動時執行 DHCP ====<br />
<br />
若您只是想使用 DHCP 來連線至您的乙太網路連線,您可以使用 {{ic|dhcpcd@.service}} (由 {{Pkg|dhcpcd}} 軟體包提供)。<br />
<br />
要啟動 {{ic|eth0}} 上的 DHCP ,只需要使用:<br />
<br />
# systemctl start dhcpcd@eth0.service<br />
<br />
您可以下列方法啟用該服務讓其於開機時自動啟動:<br />
<br />
# systemctl enable dhcpcd@eth0.service<br />
<br />
若您用了 DHCP 且您並 '''不想''' 讓您的 DNS 伺服器在每次啟動網路時自動指派,請將下列內容加到 {{ic|dhcpcd.conf}} 的最後一段中:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nohook resolv.conf<br />
}}<br />
<br />
另外,若您位於基於 MAC 位址的用戶端 IP 位址進行過濾的 DHCPv4 網路,您可能需要修改下列內容:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 Client ID as per RFC4361. <br />
duid<br />
}}<br />
<br />
為:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the hardware address of the interface for the Client ID (DHCPv4).<br />
clientid<br />
}}<br />
<br />
否則,您可能會因為 DHCP 伺服器無法正確讀取您的 [http://en.wikipedia.org/wiki/DHCPv6 DHCPv6-style] 用戶端 ID 而無法使用。詳細請參閱 [http://tools.ietf.org/html/rfc4361 RFC 4361] 。<br />
<br />
為防止 {{ic|dhcpcd}} 加入網域名稱伺服器至 {{ic|/etc/resolv.conf}} 中,請於其中使用 {{ic|nooption}} 選項:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nooption domain_name_servers<br />
}}<br />
<br />
接著加入您自己的 DNS 名稱伺服器至 {{ic|/etc/resolv.conf}} 中。<br />
<br />
若有多個不同的執行緒要控制 {{ic|/etc/resolv.conf}} (如 {{Pkg|dhcpcd}} 與 VPN 用戶端),您可能會想要使用 {{Pkg|openresolv}} 軟體包。使用 {{Pkg|openresolv}} 並不需要額外地設定 {{Pkg|dhcpcd}} 。<br />
<br />
==== DHCP 靜態路由 ====<br />
若您需要加入靜態路由用戶端,請於 {{ic|/usr/lib/dhcpcd/dhcpcd-hooks}} 中建立一個新的 dhcpcd hook-script 。下列範例展示了加入靜態路由至一個通過閘道為 192.168.192.5 ,位於 10.11.12.0/24 的 VPN 子網路:<br />
{{hc|/usr/lib/dhcpcd/dhcpcd-hooks/40-vpnroute|<br />
ip route add 10.11.12.0/24 via 192.168.192.5<br />
}}<br />
前置字串''40''表示其於 dhcpcd 啟動時的最後執行 hook-script 。<br />
<br />
=== 靜態 IP 位址 ===<br />
<br />
您可能因為各種原因而希望在您的網路中指派靜態 IP 位址,例如靜態的位址可以獲得一定程度的可預測性,或是您沒有可用的 DHCP 伺服器。<br />
<br />
{{註記|若您通過 Windows 機器來共享您的網路而不是使用路由器,請確保兩台電腦皆使用了靜態 IP 位址以避免區域網路問題。}}<br />
<br />
您需要:<br />
<br />
* 靜態 IP 位址<br />
* [[Wikipedia:Subnetwork|子網路遮罩]]<br />
* [[Wikipedia:Broadcast_address|廣播位址]]<br />
* [[Wikipedia:Default_gateway|預設閘道器]]的 IP 位址<br />
<br />
若您處在內部網路中,使用 192.168.*.* 這樣的 IP 位址較為安全,搭配其的子網路遮罩 255.255.255.0 ,廣播位址為 192.168.*.255 。而閘道通常是 192.168.*.1 或是 192.168.*.254 。<br />
<br />
==== 手動指派 ====<br />
<br />
您可於控制台中指派一靜態 IP 位址:<br />
<br />
# ip addr add <IP 位址>/<子網路遮罩> broadcast <廣播> dev <介面><br />
<br />
舉例來說:<br />
<br />
# ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev eth0<br />
<br />
{{註記|子網路遮罩使用了 [[Wikipedia:CIDR_notation|CIDR 表示法]](CIDR,Classless Inter-Domain Routing,無類別網路間路由)。}}<br />
<br />
詳情請參閱 {{ic|man ip}} 。<br />
<br />
以類似下列方法加上您的閘道:<br />
<br />
# ip route add default via <預設閘道 IP 位址><br />
<br />
舉例來說:<br />
<br />
# ip route add default via 192.168.1.1<br />
<br />
若您得到了 "No such process" 這樣的錯誤訊息,這代表您必須以 root 執行 {{ic|ip link set dev eth0 up}} 。<br />
<br />
==== 於啟動時通過 systemd 手動連線 ====<br />
<br />
先確保 dhcpcd 已停止並禁用:<br />
<br />
# systemctl status dhcpcd.service<br />
<br />
接著為 [[systemd]] 服務建立一個檔案。以正確的網路介面名稱取代其中的 {{ic|<interface>}} :<br />
<br />
{{hc|/etc/conf.d/network@<interface>|<nowiki><br />
address=192.168.0.15<br />
netmask=24<br />
broadcast=192.168.0.255<br />
gateway=192.168.0.1<br />
</nowiki>}}<br />
<br />
建立 systemd unit 檔案:<br />
<br />
{{hc|/etc/systemd/system/network@.service|<nowiki><br />
[Unit]<br />
Description=Network connectivity (%i)<br />
Wants=network.target<br />
Before=network.target<br />
BindsTo=sys-subsystem-net-devices-%i.device<br />
After=sys-subsystem-net-devices-%i.device<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
EnvironmentFile=/etc/conf.d/network@%i<br />
<br />
ExecStart=/usr/bin/ip link set dev %i up<br />
ExecStart=/usr/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i<br />
ExecStart=/usr/bin/ip route add default via ${gateway}<br />
<br />
ExecStop=/usr/bin/ip addr flush dev %i<br />
ExecStop=/usr/bin/ip link set dev %i down<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
啟用該 unit 並將其啟動,傳入介面名稱,例如 eno1 :<br />
<br />
# systemctl enable network@eno1.service<br />
# systemctl start network@eno1.service<br />
<br />
若您需要手動設定 nameservers ,請編輯 {{ic|/etc/resolv.conf}} 檔案:<br />
<br />
{{hc|/etc/resolv.conf|<br />
nameserver 208.67.222.222<br />
nameserver 208.67.220.220}}<br />
<br />
若 {{ic|/etc/resolv.conf}} 被持續遭到複寫,請參考 [[Resolv.conf]] 以瞭解如何解決此問題。<br />
<br />
有幾個類似的方法來讓 systemd 啟動網路,其中的差異為檔案內容,並且其可以寫死 EnvironmentFile 定義的參考檔案中抓到的參數。因此可以作為一種替代的,將介面名稱放置於 /etc/conf.d/ 中的 EnvironmentFile ,接著直接使用介面名稱而不是 %i 。如此一來,檔案名稱便不需要「@」。這也是一種有用的方法,詳情請參閱[http://www.freedesktop.org/software/systemd/man/systemd.unit.html Systemd 服務文件]。<br />
<br />
==== 計算位址 ====<br />
<br />
您可以使用 {{Pkg|ipcalc}} 提供的 {{ic|ipcalc}} 來計算 IP 廣播、網域、子網路遮罩與主機範圍等進階設定舉例來說,我使用了位於防火牆後的乙太網路來連線 Windows 機器至 Arch。為了安全性與網路組織,我將他們放置於各自獨立的網路,接著組態設定子網路遮罩與廣播位址,如此一來網路中就只有兩台機器。為了找出子網路遮罩跟廣播位址,我使用了 ipcalc ,提供其 Arch firewire nic 的 IP 位址 10.66.66.1 ,並指定 ipcalc 要建立一個只有兩台主機的網路。<br />
<br />
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|<nowiki><br />
Address: 10.66.66.1<br />
<br />
Netmask: 255.255.255.252 = 30<br />
Network: 10.66.66.0/30<br />
HostMin: 10.66.66.1<br />
HostMax: 10.66.66.2<br />
Broadcast: 10.66.66.3<br />
Hosts/Net: 2 Class A, Private Internet<br />
</nowiki>}}<br />
<br />
== 載入組態設定 ==<br />
<br />
要測試您的設定,您可以重新啟動電腦或是重新載入相關的 systemd 服務:<br />
<br />
# systemctl restart dhcpcd@eth0<br />
<br />
您可以試著 ping 您的閘道、 DNS 伺服器、 ISP 提供商或是其他網路上的站台。如此一來便可以確認您的網路連線問題為何,例如:<br />
<br />
$ ping -c 3 www.google.com<br />
<br />
== 附加設定 ==<br />
<br />
=== 筆記型電腦之 ifplugd ===<br />
<br />
{{Tip|{{Pkg|dhcpcd}} provides the same feature out of the box.}}<br />
<br />
{{Pkg|ifplugd}} in [[Official Repositories]] is a daemon which will automatically configure your Ethernet device when a cable is plugged in and automatically unconfigure it if the cable is pulled. This is useful on laptops with onboard network adapters, since it will only configure the interface when a cable is really connected. Another use is when you just need to restart the network but do not want to restart the computer or do it from the shell.<br />
<br />
By default it is configured to work for the {{ic|eth0}} device. This and other settings like delays can be configured in {{ic|/etc/ifplugd/ifplugd.conf}}.<br />
<br />
{{Note|[[Netctl]] package includes {{ic|netctl-ifplugd@.service}}, otherwise you can use {{ic|ifplugd@.service}} from {{Pkg|ifplugd}} package. Use for example {{ic|systemctl enable ifplugd@eth0.service}}.}}<br />
<br />
=== Bonding 或 LAG ===<br />
<br />
請參閱 [[netctl#Bonding]] 。<br />
<br />
=== IP 別名 ===<br />
<br />
{{Expansion|Manual method using [[Core Utilities#ip|ip]] should be added; then move current example using ''netctl'' into [[netctl]].}}<br />
<br />
IP 別名為讓同一個網路介面有多個 IP 位址。如此一來,單個節點的網路就能有多個網路連線,進而實現不同的作用。經典的使用方法為網頁與 FTP 伺服器的虛擬主機,或是重組伺服器而無需更新任何其他的機器(對於名稱伺服器來說特別有用)。<br />
<br />
==== 範例 ====<br />
<br />
您將需要來自[[Official Repositories|官方軟體套件庫]]的 {{Pkg|netctl}} 。<br />
<br />
準備組態設定檔:<br />
<br />
{{hc|/etc/netctl/mynetwork|<nowiki><br />
Connection='ethernet'<br />
Description='Five different addresses on the same NIC.'<br />
Interface='eth0'<br />
IP='static'<br />
Address=('192.168.1.10' '192.168.178.11' '192.168.1.12' '192.168.1.13' '192.168.1.14' '192.168.1.15')<br />
Gateway='192.168.1.1'<br />
DNS=('192.168.1.1')<br />
</nowiki>}}<br />
<br />
接著只需要將其執行:<br />
<br />
$ netctl start mynetwork<br />
<br />
=== 更改 MAC/硬體 位址 ===<br />
<br />
請參閱 [[MAC Address Spoofing]] 。<br />
<br />
=== 網路共享 ===<br />
<br />
請參閱 [[Internet Sharing]] 。<br />
<br />
=== 路由組態設定 ===<br />
<br />
請參閱 [[Router]] 。<br />
<br />
=== 區域網路主機名稱解析 ===<br />
<br />
先決條件為[[#.E8.A8.AD.E5.AE.9A.E4.B8.BB.E6.A9.9F.E5.90.8D.E7.A8.B1|設定主機名稱]]之後,主機名稱可在本機系統上解析:<br />
{{hc|$ ping hostname|<br />
PING hostname <nowiki>(192.168.1.2) 56(84) bytes of data.<br />
64 bytes from hostname (192.168.1.2): icmp_seq=1 ttl=64 time=0.043 ms</nowiki>}}<br />
要以其他機器的名稱來解析主機,需要手動設定各自的 {{ic|/etc/hosts}} 檔案或是廣播/解析名稱的服務。<br />
<br />
過度設定 DNS 伺服器,如 [[BIND]] 、 [[Unbound]] ,手動編輯 {{ic|/etc/hosts}} 過於繁瑣,或是您希望對於動態地將主機離開、加入網路有更大的靈活性,您可以在您的區域網路中使用 Zero-configuration networking 來進行主機名稱解析。這裡有兩個可用選擇:<br />
<br />
*[[Samba]] 提供了通過微軟 '''NetBIOS''' 的主機名稱解析。其只需要安裝 {{Pkg|samba}} 並啟用 {{ic|nmbd.service}} 服務。執行 Windows 、OS X 或執行了 {{ic|nmbd}} 的 Linux ,將能夠找到您的機器。<br />
<br />
*[[Avahi]] 提供通過 '''zeroconf''' 的主機名稱解析,也稱作 Avahi 或 Boujour 。它比 Samba 還需要稍微複雜一點的設定:詳情請參考 [[Avahi#Hostname resolution]]。執行 OS X 或執行了 Avahi daemon 的 Linux ,將能夠找到您的機器。Windows 並無內建 Avahi 用戶端或 Daemon 。<br />
<br />
== 診斷 ==<br />
<br />
=== Swapping computers on the cable modem ===<br />
<br />
Some cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.<br />
<br />
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].<br />
<br />
=== The TCP window scaling problem ===<br />
<br />
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.<br />
<br />
Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html RFC 1323] was written to improve the situation: Window Scaling. The "window" value, provided in all packets, will be modified by a Scale Factor defined once, at the very beginning of the connection.<br />
<br />
That 8-bit Scale Factor allows the Window to be up to 32 times higher than the initial 64Kb.<br />
<br />
It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts.<br />
<br />
The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.<br />
<br />
The resulting connection is at best very slow or broken.<br />
<br />
==== How to diagnose the problem ====<br />
<br />
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).<br />
<br />
When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|ip addr}} will report normal status... and actually everything appears normal.<br />
<br />
If you cannot browse any website, but you can ping some random hosts, chances are great that you're experiencing this problem: ping uses ICMP and is not affected by TCP problems.<br />
<br />
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).<br />
<br />
==== How to fix it (The bad way) ====<br />
<br />
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.<br />
<br />
# echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem<br />
<br />
==== How to fix it (The good way) ====<br />
<br />
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.d/99-disable_window_scaling.conf}} (see also [[sysctl]])<br />
<br />
net.ipv4.tcp_window_scaling = 0<br />
<br />
==== How to fix it (The best way) ====<br />
<br />
This problem is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.<br />
<br />
==== More about it ====<br />
<br />
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].<br />
<br />
There are also several relevant threads on the LKML.<br />
<br />
=== Realtek no link / WOL problem ===<br />
<br />
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice a problem where the NIC seems to be disabled on boot and has no Link light. This can usually be found on a dual boot system where Windows is also installed. It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause. These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots. You will be able to notice if this problem is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off. Normal operation should be that the link light is always on as long as the system is on, even during POST. This problem will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this problem:<br />
<br />
==== Method 1 - Rollback/change Windows driver ====<br />
<br />
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).<br />
<br />
==== Method 2 - Enable WOL in Windows driver ====<br />
<br />
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems). In Windows, under Device Manager, find your Realtek network adapter and double-click it. Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.<br />
<br />
In Windows XP (example)<br />
Right click my computer<br />
--> Hardware tab<br />
--> Device Manager<br />
--> Network Adapters<br />
--> "double click" Realtek ...<br />
--> Advanced tab<br />
--> Wake-On-Lan After Shutdown<br />
--> Enable<br />
<br />
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{ic|Disable}} has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.}}<br />
<br />
==== Method 3 - Newer Realtek Linux driver ====<br />
<br />
Any newer driver for these Realtek cards can be found for Linux on the realtek site. (untested but believed to also solve the problem).<br />
<br />
==== Method 4 - Enable ''LAN Boot ROM'' in BIOS/CMOS ====<br />
<br />
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.<br />
<br />
{{Note|This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.}}<br />
<br />
=== DLink G604T/DLink G502T DNS problem ===<br />
<br />
Users with a DLink G604T/DLink G502T router, using DHCP and have firmware v2.00+ (typically users with AUS firmware) may have problems with certain programs not resolving the DNS. One of these programs are unfortunatley pacman. The problem is basically the router in certain situations is not sending the DNS properly to DHCP, which causes programs to try and connect to servers with an IP address of 1.0.0.0 and fail with a connection timed out error<br />
<br />
==== How to diagnose the problem ====<br />
<br />
The best way to diagnose the problem is to use Firefox/Konqueror/links/seamonkey and to enable wget for pacman. If this is a fresh install of Arch Linux, then you may want to consider installing {{ic|links}} through the live CD.<br />
<br />
Firstly, enable wget for pacman (since it gives us info about pacman when it is downloading packages)<br />
Open {{ic|/etc/pacman.conf}} with your favourite editor and uncomment the following line (remove the # if it is there)<br />
<br />
XferCommand=/usr/bin/wget --passive-ftp -c -O %o %u<br />
<br />
While you are editing {{ic|/etc/pacman.conf}}, check the default mirror that pacman uses to download packages.<br />
<br />
Now open up the default mirror in an Internet browser to see if the mirror actually works. If it does work, then do {{ic|pacman -Syy}} (otherwise pick another working mirror and set it to the pacman default). If you get something similar to the following (notice the 1.0.0.0),<br />
<br />
<nowiki>ftp://mirror.pacific.net.au/linux/archlinux/extra/os/i686/extra.db.tar.gz</nowiki><br />
=> '/var/lib/pacman/community.db.tar.gz.part'<br />
Resolving mirror.pacific.net.au... 1.0.0.0<br />
<br />
then you most likely have this problem. The 1.0.0.0 means it is unable to resolve DNS, so we must add it to {{ic|/etc/resolv.conf}}.<br />
<br />
==== How to fix it ====<br />
<br />
{{Out of date|{{Pkg|dhcpcd}} does not use {{ic|/etc/conf.d/dhcpcd}} any more.}}<br />
<br />
Basically what we need to do is to manually add the DNS servers to our {{ic|/etc/resolv.conf}} file. The problem is that DHCP automatically deletes and replaces this file on boot, so we need to edit {{ic|/etc/conf.d/dhcpcd}} and change the flags to stop DHCP from doing this.<br />
<br />
When you open {{ic|/etc/conf.d/dhcpcd}}, you should see something close to the following:<br />
<br />
DHCPCD_ARGS="-t 30 -h $HOSTNAME"<br />
<br />
Add the {{ic|-R}} flag to the arguments, e.g.,<br />
<br />
DHCPCD_ARGS="-R -t 30 -h $HOSTNAME"<br />
<br />
{{Note|1=If you are using {{Pkg|dhcpcd}} >= 4.0.2, the {{ic|-R}} flag has been deprecated. Please see the [[#Run DHCP at boot]] section for information on how to use a custom {{ic|/etc/resolv.conf}} file.}}<br />
<br />
Save and close the file; now open {{ic|/etc/resolv.conf}}. You should see a single nameserver (most likely 10.1.1.1). This is the gateway to your router, which we need to connect to in order to get the DNS servers of your ISP. Paste the IP address into your browser and log in to your router. Go to the DNS section, and you should see an IP address in the Primary DNS Server field; copy it and paste it as a nameserver '''ABOVE''' the current gateway one.<br />
<br />
For example, {{ic|/etc/resolv.conf}} should look something along the lines of:<br />
<br />
nameserver 10.1.1.1<br />
<br />
If my primary DNS server is 211.29.132.12, then change {{ic|/etc/resolv.conf}} to:<br />
<br />
nameserver 211.29.132.12<br />
nameserver 10.1.1.1<br />
<br />
Now restart the network daemon by running {{ic|systemctl restart dhcpcd@<interface>}} and do {{ic|pacman -Syy}}. If it syncs correctly with the server, then the problem is solved.<br />
<br />
==== More about it ====<br />
<br />
This is the whirlpool forum (Australian ISP community) which talks about and gives the same solution to the problem:<br />
<br />
http://forums.whirlpool.net.au/forum-replies-archive.cfm/461625.html<br />
<br />
=== Check DHCP problem by releasing IP first ===<br />
<br />
Problem may occur when DHCP get wrong IP assignment. For example when two routers are tied together through VPN. The router that is connected to me by VPN may assigning IP address. To fix it. On a console, as root, release IP address:<br />
<br />
# dhcpcd -k<br />
<br />
Then request a new one:<br />
<br />
# dhcpcd<br />
<br />
Maybe you had to run those two commands many times.<br />
<br />
=== No eth0 with Atheros AR8161 ===<br />
<br />
{{Note|With the 3.10.2-1-ARCH kernel update, the alx ethernet driver module is included in the package.}}<br />
<br />
With the Atheros AR8161 Gigabit Ethernet card, the ethernet connection is not working out-of-the-box (with the installation media of March 2013). The module "alx" needs to be loaded but is not present.<br />
<br />
The driver from [http://linuxwireless.org/en/users/Download/stable/#compat-wireless_stable_releases compat-wireless] (that has become [https://backports.wiki.kernel.org/index.php/Releases compat-drives] since linux 3.7) need to be installed. The "-u" postfix annotates that Qualcomm have applied a driver under a unified driver.<br />
<br />
$ wget https://www.kernel.org/pub/linux/kernel/projects/backports/2013/03/28/compat-drivers-2013-03-28-5-u.tar.bz2<br />
$ tar xjf compat*<br />
$ cd compat*<br />
$ ./scripts/driver-select alx<br />
$ make<br />
$ sudo make install<br />
$ sudo modprobe alx<br />
<br />
The alx driver has not been added to Linux kernel due to various problems. Compatibility between the different kernel versions has been spotty. For better support follow the [http://lists.infradead.org/mailman/listinfo/unified-drivers mailing list]and [http://www.linuxfoundation.org/collaborate/workgroups/networking/alx alx page]for latest working solution for alx.<br />
<br />
The driver must be built and installed after every kernel change.<br />
<br />
Alternatively you can use the AUR package for [https://aur.archlinux.org/packages/compat-drivers-patched/ compat drivers], which installs many other drivers.<br />
<br />
=== No eth0 with Atheros AR9485 ===<br />
<br />
The ethernet (eth0) for Atheros AR9485 are not working out-of-the-box (with installation media of March 2013). The working solution for this is to install the package [https://aur.archlinux.org/packages/compat-drivers-patched/ compat-drivers-patched] from AUR.<br />
<br />
=== No carrier / no connection after suspend ===<br />
After suspend to RAM no connection is found although the network cable is plugged in. <br />
This may be caused by PCI power management. What is the output of<br />
<br />
# ip link show eth0<br />
<br />
If the line contains "NO-CARRIER" even though there's a cable connected to your eth0 port, it is possible that the device was auto-suspended and the media sense feature doesn't work. To solve this, first you need to find your ethernet controllers PCI address by<br />
<br />
# lspci<br />
<br />
This should look similar to this:<br />
<br />
...<br />
00:19.0 Ethernet controller: Intel Corporation 82577LM Gigabit Network Connection (rev 06)<br />
...<br />
<br />
So the address is 00:19.0.<br />
Now check the PM status of the device by issuing<br />
<br />
# cat "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
substituting 00:19.0 with the address obtained from lspci.<br />
If the output reads "auto", you can try to bring the device out of suspend by<br />
<br />
# echo on > "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
Don't forget to substitute the address again.<br />
<br />
{{Note|1=This appears to be a bug in kernel 3.8.4.1- (3.8.8.1 is still affected): [https://bbs.archlinux.org/viewtopic.php?id=159837&p=2 Forum discussion.] It also appears a fix is [https://lkml.org/lkml/2013/1/18/147 on the way. (It will be likely fixed in 3.9.)] In the meantime, the above is a suitable workaround.}}<br />
<br />
=== Broadcom BCM57780 ===<br />
<br />
This Broadcom chipset sometimes does not behave well unless you specify the order of the modules to be loaded. The modules are {{ic|broadcom}} and {{ic|tg3}}, the former needing to be loaded first.<br />
<br />
These steps should help if your computer has this chipset:<br />
$ lspci | grep Ethernet<br />
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)<br />
<br />
If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following (as root):<br />
# modprobe -r tg3<br />
# modprobe broadcom<br />
# modprobe tg3<br />
<br />
Now plug you network cable in. If this solves your problems you can make this permanent by adding {{ic|broadcom}} and {{ic|tg3}} (in this order) to the {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}}:<br />
<br />
MODULES=".. broadcom tg3 .."<br />
<br />
Then rebuild the initramfs:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|These methods may work for other chipsets, such as BCM57760.}}</div>Binotahttps://wiki.archlinux.org/index.php?title=User:Binota&diff=293559User:Binota2014-01-19T10:20:49Z<p>Binota: </p>
<hr />
<div>Hi there~<br />
<br />
I'm a new member of Arch Linux,<br />
<br />
also a new member of Linux:P<br />
<br />
translate is my hobby,<br />
<br />
that I'm help this wiki to translate some page to Chinese Traditional.<br />
<br />
If you want to know me more,<br />
<br />
you can contact me via e-mail~<br />
<br />
<br />
My E-Mail: binota【!!AT!!】binota【!!DOT!!】org</div>Binotahttps://wiki.archlinux.org/index.php?title=User:Binota&diff=293558User:Binota2014-01-19T10:15:42Z<p>Binota: Created page with "空空如也 =w=~"</p>
<hr />
<div>空空如也 =w=~</div>Binotahttps://wiki.archlinux.org/index.php?title=Network_configuration_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=293556Network configuration (正體中文)2014-01-19T10:12:22Z<p>Binota: /* Router Configuration */ Translated</p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:Networking (正體中文)]]<br />
[[Category:Getting and installing Arch (正體中文)]]<br />
<br />
[[cs:Configuring Network]]<br />
[[el:Configuring Network]]<br />
[[es:Configuring Network]]<br />
[[fr:Connexions reseau]]<br />
[[it:Configuring Network]]<br />
[[ja:Network Configuration]]<br />
[[nl:Configuring Network]]<br />
[[pt:Configuring Network]]<br />
[[ro:Configurare retea]]<br />
[[ru:Configuring Network]]<br />
[[sk:Configuring Network]]<br />
[[tr:Ağ_Yapılandırması]]<br />
[[zh-CN:Network Configuration]]<br />
[[zh-TW:Network Configuration]]<br />
{{Related articles start}}<br />
{{Related|Jumbo Frames}}<br />
{{Related|Firewalls}}<br />
{{Related|Wireless Setup}}<br />
{{Related|List of Applications#Network Managers}}<br />
{{Related articles end}}<br />
{{TranslationStatus (正體中文)|Network_Configuration|2014-01-19|293523}}<br />
<br />
本頁將介紹如何設定 '''有線''' 網路連線。若您需要設定 '''無線''' 網路,請參考[[Wireless Setup|無線網路設定]]。<br />
<br />
== 檢查連線 ==<br />
<br />
{{註記|若您在執行 ping 時收到了類似 {{ic|ping: icmp open socket: Operation not permitted}} 這樣的錯誤訊息,請嘗試重新安裝 {{ic|iputils}} 軟體包。}} <br />
<br />
一般來說,基本的安裝過程都已經建立了可運作的網路設定。請執行下列指令以進行檢查:<br />
<br />
{{註記|{{ic|-c 3}} 選項表示將會呼叫三次。詳細請參閱 {{ic|man ping}} 。}}<br />
{{提示|您也可以嘗試使用其他的 Domain ,如 www.hinet.net 。}}<br />
<br />
{{hc|$ ping -c 3 www.google.com|<nowiki><br />
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.<br />
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms<br />
64 bytes from 74.125.224.146: icmp_req=2 ttl=50 time=385 ms<br />
64 bytes from 74.125.224.146: icmp_req=3 ttl=50 time=298 ms<br />
<br />
--- www.l.google.com ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 1999ms<br />
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms<br />
</nowiki>}}<br />
<br />
如果沒問題的話,您可能只是想以本文的下列部分來自定您的設定。<br />
<br />
若剛才的指令出現了 unknown hosts 之類的訊息,代表您的機器無法解析網域。這可能是因為您的網路服務提供商/閘道器造成的。您可以嘗試 ping 一個靜態 IP 以實驗您的機器可否存取網際網路。<br />
{{提示|您也可以嘗試使用其他的 IP ,如 168.95.1.1 。}}<br />
<br />
{{hc|$ ping -c 3 8.8.8.8|<nowiki><br />
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.<br />
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms<br />
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms<br />
64 bytes from 8.8.8.8: icmp_req=3 ttl=53 time=70.6 ms<br />
<br />
--- 8.8.8.8 ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 2002ms<br />
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms<br />
</nowiki>}}<br />
<br />
{{註記|{{ic|8.8.8.8}} 為一個好記的靜態 IP 位置。這是 Google 的主要 DNS 伺服器,這表示其有一定的可信度,並且通常不會被系統或代理伺服器擋下。}}<br />
<br />
若您可以 ping 通該位置,您可能需要試著在 {{ic|/etc/resolv.conf}} 檔案中加上網域名稱伺服器。<br />
<br />
== 設定主機名稱 ==<br />
<br />
[[Wikipedia:Hostname|主機名稱]]為網路中用於識別機器的唯一識別名稱:主機名稱可以通過 {{ic|/etc/hostname}} 檔案來進行設定。一般來說該檔案包含了系統的網域名稱。下面為設定主機名稱的方法:<br />
<br />
# hostnamectl set-hostname '''myhostname'''<br />
<br />
這樣會將 '''myhostname''' 寫入 {{ic|/etc/hostname}} 檔案中。<br />
<br />
詳細請參閱 {{ic|man 5 hostname}} 與 {{ic|man 1 hostnamectl}} 。<br />
<br />
{{註記|<br />
* {{ic|hostnamectl}} 支援 FQDN<br />
* 您不需要編輯 {{ic|/etc/hosts}} 檔案,{{pkg|systemd}} 會提供主機名稱解析且預設安裝於所有系統。<br />
}}<br />
<br />
使用來自 {{Pkg|inetutils}} 的 {{ic|hostname}} 指令以設定臨時主機名稱(直到重新啟動):<br />
<br />
# hostname ''myhostname''<br />
<br />
== 裝置驅動程式 ==<br />
<br />
=== 檢查驅動程式狀態 ===<br />
<br />
[[udev]] 應該會檢測您的網路介面卡([[Wikipedia:Network_interface_controller|NIC]])並自動於啟動時載入必要的模組。檢查 {{ic|lspci -v}} 輸出內容中的「Ethernet controller」 項目(或類似的)。這應該會告訴您哪些核心模組包含了網路設備的驅動程式。舉例來說:<br />
<br />
{{hc|$ lspci -v|<br />
02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)<br />
...<br />
Kernel driver in use: atl1<br />
Kernel modules: atl1<br />
}}<br />
<br />
接下來,確認該驅動程式已經通過 {{ic|dmesg <nowiki>|</nowiki> grep ''module_name''}} 載入了。舉例來說:<br />
<br />
$ dmesg | grep atl1<br />
...<br />
atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex<br />
<br />
若驅動程式已成功加載可以跳過接下來這段。否則,您會需要知道哪些模組時您的特定型號的裝置需要哪個模組。<br />
<br />
=== 載入裝置模組 ===<br />
<br />
以 Google 搜尋正確的晶片組模組/驅動程式。常見的驅動模組有 Realtek 晶片組網卡的 {{ic|8139too}} ,或是 SiS 晶片組網卡的 {{ic|sis900}}。當您知道要使用何種模組了之後,試著[[Kernel modules#Manual module handling|手動將其載入]]。若您的到了錯誤訊息告訴您找不到該模組,則該驅動可能未包含於 Arch 核心中。您可以在 [[AUR]] 中搜尋該模組名稱。<br />
<br />
若 udev 未在開機期間檢測與載入正確的模組,請參閱 [[Kernel modules#Loading]]。<br />
<br />
== 網路介面 ==<br />
<br />
=== 裝置名稱 ===<br />
<br />
對於多網路卡的電腦,固定裝置名稱非常重要。許多設定問題都是因為介面卡名稱的改動造成的。<br />
<br />
[[udev]] 負責命名裝置。Systemd v197 則有[http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames 可預測之網路介面名稱]並可自動支配靜態名稱給網路裝置。介面名稱以 {{ic|en}} (乙太網路)、 {{ic|wl}} (無線網路) 或是 {{ic|ww}} (WWAN)作為前置字串並附上一個自動產生的識別名稱,進而產生了類似 {{ic|enp0s25}} 這樣的名稱。 <br />
<br />
要禁用這種行為,可以加上一個連接:<br />
<br />
# ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules<br />
<br />
自早期版本升級 systemd 的使用者會有一自動建立的空規則檔案。因此,若您想使用一貫的裝置名稱,只需要刪除該檔案。<br />
<br />
{{提示|您可以執行 {{ic|ip link}} 或是 {{ic|ls /sys/class/net}} 以列出所有可用的介面。}}<br />
<br />
{{註記|當您更改了介面名稱規則後,別忘了更新所有跟網路有關的組態檔案與自定的 systemd unit 檔案以因應該更改。特別是當您啟用了 [[netctl#Basic method|netctl 靜態設定檔]] ,請執行 {{ic|netctl reenable ''profile''}} 以更新所有產生的服務檔案。}}<br />
<br />
==== 更改裝置名稱 ====<br />
<br />
您可以使用 udev-rule 來手動定義裝置名稱。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"<br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"<br />
</nowiki>}}<br />
<br />
請注意這兩點:<br />
<br />
* 使用這個指令以取得 MAC 位置:{{ic|cat /sys/class/net/''device_name''/address}}。<br />
* 請確定 udev 規則中使用的是小寫的十六進位數值而不是大寫。<br />
<br />
若您的網路卡為動態 MAC ,您可以使用 DEVPATH ,例如:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"<br />
</nowiki>}}<br />
<br />
{{註記|當使用了靜態的名稱時,'''應該要避免使用類似 "eth''X''" 與 "wlan''X''"''' 這樣的名稱,因為這可能會導致核心與 udev 在開機時發生衝突。而剛好相反地,最好使用核心預設不會使用的介面名稱,如 {{ic|net0}} 、 {{ic|net1}} 、 {{ic|wifi0}} 、 {{ic|wifi1}} 。詳細說明請參閱 [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames systemd] 文件。}}<br />
<br />
=== 設定裝置的 MTU 與佇列長度 ===<br />
<br />
您可以手動定義 udev 規則來更改裝置的 MTU 與佇列長度。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1480", ATTR{tx_queue_len}="2000"<br />
</nowiki>}}<br />
<br />
=== 取得目前的裝置名稱 ===<br />
<br />
目前的 NIC 名稱可以通過 sysfs 找到<br />
<br />
{{hc|$ ls /sys/class/net|<br />
lo eth0 eth1 firewire0<br />
}}<br />
<br />
=== 啟用與禁用網路介面 ===<br />
<br />
您可以使用下列指令來啟用或禁用網路介面:<br />
<br />
# ip link set eth0 up<br />
# ip link set eth0 down<br />
<br />
要確認結果,請執行:<br />
<br />
{{hc|$ ip link show dev eth0|<br />
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000<br />
...<br />
}}<br />
<br />
== 組態設定 IP 位址 ==<br />
<br />
您有兩個選擇:使用 [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]] 指派動態位址,或是使用「靜態」的位址。<br />
<br />
=== 動態 IP 位址 ===<br />
<br />
==== 手動執行 DHCP 用戶端 Daemon ====<br />
<br />
{{註記|請特別注意 {{ic|dhcpcd}} (DHCP ''Client'' Daemon,DHCP 用戶端 Daemon) 與 {{ic|dhcpd}} (DHCP ''(server)'' daemon,DHCP 伺服端 Daemon) 間的差異。}}<br />
<br />
{{hc|# dhcpcd eth0|<br />
dhcpcd: version 5.1.1 starting<br />
dhcpcd: eth0: broadcasting for a lease<br />
...<br />
dhcpcd: eth0: leased 192.168.1.70 for 86400 seconds<br />
}}<br />
<br />
緊接著, {{ic|ip addr show dev eth0}} 應該要顯示出您的 inet 位址。<br />
<br />
對部分的人而言,{{ic|dhcpcd}} 失敗時,可以使用 {{ic|dhclient}} (位於 {{Pkg|dhclient}} 軟體包中)<br />
<br />
==== 於啟動時執行 DHCP ====<br />
<br />
若您只是想使用 DHCP 來連線至您的乙太網路連線,您可以使用 {{ic|dhcpcd@.service}} (由 {{Pkg|dhcpcd}} 軟體包提供)。<br />
<br />
要啟動 {{ic|eth0}} 上的 DHCP ,只需要使用:<br />
<br />
# systemctl start dhcpcd@eth0.service<br />
<br />
您可以下列方法啟用該服務讓其於開機時自動啟動:<br />
<br />
# systemctl enable dhcpcd@eth0.service<br />
<br />
若您用了 DHCP 且您並 '''不想''' 讓您的 DNS 伺服器在每次啟動您的網路時自動指派,請將下列內容加到 {{ic|dhcpcd.conf}} 的最後一段中:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nohook resolv.conf<br />
}}<br />
<br />
另外,若您位於基於 MAC 位址的用戶端 IP 位址進行過濾的 DHCPv4 網路,您可能需要修改下列內容:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 Client ID as per RFC4361. <br />
duid<br />
}}<br />
<br />
為:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the hardware address of the interface for the Client ID (DHCPv4).<br />
clientid<br />
}}<br />
<br />
否則,您可能會因為 DHCP 伺服器無法正確讀取您的 [http://en.wikipedia.org/wiki/DHCPv6 DHCPv6-style] 用戶端 ID 而無法使用。詳細請參閱 [http://tools.ietf.org/html/rfc4361 RFC 4361] 。<br />
<br />
為防止 {{ic|dhcpcd}} 加入網域名稱伺服器至 {{ic|/etc/resolv.conf}} 中,請於其中使用 {{ic|nooption}} 選項:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nooption domain_name_servers<br />
}}<br />
<br />
接著加入您自己的 DNS 名稱伺服器至 {{ic|/etc/resolv.conf}} 中。<br />
<br />
若有多個不同的執行緒要控制 {{ic|/etc/resolv.conf}} (如 {{Pkg|dhcpcd}} 與 VPN 用戶端),您可能會想要使用 {{Pkg|openresolv}} 軟體包。使用 {{Pkg|openresolv}} 並不需要額外地設定 {{Pkg|dhcpcd}} 。<br />
<br />
==== DHCP 靜態路由 ====<br />
若您需要加入靜態路由用戶端,請於 {{ic|/usr/lib/dhcpcd/dhcpcd-hooks}} 中建立一個新的 dhcpcd hook-script 。下列範例展示了加入靜態路由至一個通過閘道器為 192.168.192.5 ,位於 10.11.12.0/24 的 VPN 子網路:<br />
{{hc|/usr/lib/dhcpcd/dhcpcd-hooks/40-vpnroute|<br />
ip route add 10.11.12.0/24 via 192.168.192.5<br />
}}<br />
前置字串''40''表示其於 dhcpcd 啟動時的最後執行 hook-script 。<br />
<br />
=== 靜態 IP 位址 ===<br />
<br />
您可能因為各種原因而希望在您的網路中指派靜態 IP 位址,例如靜態的位址可以獲得一定程度的可預測性,或是您沒有可用的 DHCP 伺服器。<br />
<br />
{{註記|若您共通過 Windows 機器共享您的網路而沒有路由器,請確保兩台電腦皆使用了靜態 IP 位址以避免區域網路問題。}}<br />
<br />
您需要:<br />
<br />
* 靜態 IP 位址<br />
* [[Wikipedia:Subnetwork|子網路遮罩]]<br />
* [[Wikipedia:Broadcast_address|廣播位址]]<br />
* [[Wikipedia:Default_gateway|預設閘道器]]的 IP 位址<br />
<br />
若您處在內部網路中,使用 192.168.*.* 這樣的 IP 位址較為安全,搭配其的子網路遮罩 255.255.255.0 ,廣播位址為 192.168.*.255 。而閘道器通常是 192.168.*.1 或是 192.168.*.254 。<br />
<br />
==== 手動指派 ====<br />
<br />
您可於控制台中指派一靜態 IP 位址:<br />
<br />
# ip addr add <IP 位址>/<子網路遮罩> broadcast <廣播> dev <介面><br />
<br />
舉例來說:<br />
<br />
# ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev eth0<br />
<br />
{{註記|子網路遮罩使用了 [[Wikipedia:CIDR_notation|CIDR 表示法]](CIDR,Classless Inter-Domain Routing,無類別網路間路由)。}}<br />
<br />
詳情請參閱 {{ic|man ip}} 。<br />
<br />
以類似下列方法加上您的閘道器:<br />
<br />
# ip route add default via <預設閘道器 IP 位址><br />
<br />
舉例來說:<br />
<br />
# ip route add default via 192.168.1.1<br />
<br />
若您得到了 "No such process" 這樣的錯誤訊息,這代表您必須以 root 執行 {{ic|ip link set dev eth0 up}} 。<br />
<br />
==== 於啟動時通過 systemd 手動連線 ====<br />
<br />
先確保 dhcpcd 已停止並禁用:<br />
<br />
# systemctl status dhcpcd.service<br />
<br />
接著為 [[systemd]] 服務建立一個檔案。以正確的網路介面名稱取代其中的 {{ic|<interface>}} :<br />
<br />
{{hc|/etc/conf.d/network@<interface>|<nowiki><br />
address=192.168.0.15<br />
netmask=24<br />
broadcast=192.168.0.255<br />
gateway=192.168.0.1<br />
</nowiki>}}<br />
<br />
建立 systemd unit 檔案:<br />
<br />
{{hc|/etc/systemd/system/network@.service|<nowiki><br />
[Unit]<br />
Description=Network connectivity (%i)<br />
Wants=network.target<br />
Before=network.target<br />
BindsTo=sys-subsystem-net-devices-%i.device<br />
After=sys-subsystem-net-devices-%i.device<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
EnvironmentFile=/etc/conf.d/network@%i<br />
<br />
ExecStart=/usr/bin/ip link set dev %i up<br />
ExecStart=/usr/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i<br />
ExecStart=/usr/bin/ip route add default via ${gateway}<br />
<br />
ExecStop=/usr/bin/ip addr flush dev %i<br />
ExecStop=/usr/bin/ip link set dev %i down<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
啟用該 unit 並將其啟動,傳入介面名稱,例如 eno1 :<br />
<br />
# systemctl enable network@eno1.service<br />
# systemctl start network@eno1.service<br />
<br />
若您需要手動設定 nameservers ,請編輯 {{ic|/etc/resolv.conf}} 檔案:<br />
<br />
{{hc|/etc/resolv.conf|<br />
nameserver 208.67.222.222<br />
nameserver 208.67.220.220}}<br />
<br />
若 {{ic|/etc/resolv.conf}} 被持續遭到複寫,請參考 [[Resolv.conf]] 以瞭解如何解決此問題。<br />
<br />
有幾個類似的方法來讓 systemd 啟動網路,其中的差異為檔案內容,並且其可以寫死 EnvironmentFile 定義的參考檔案中抓到的參數。因此可以作為一種替代的,將介面名稱放置於 /etc/conf.d/ 中的 EnvironmentFile 接著直接使用介面名稱而不是 %i 。如此一來,檔案名稱便不需要「@」。這也是一種有用的方法來閱讀 http://www.freedesktop.org/software/systemd/man/systemd.unit.html 上的 systemd 服務文件。<br />
<br />
==== 計算位址 ====<br />
<br />
您可以使用 {{Pkg|ipcalc}} 提供的 {{ic|ipcalc}} 來計算 IP 廣播、網域、子網路遮罩與主機範圍等進階設定舉例來說,我使用了位於防火牆後的乙太網路來連線 Windows 機器至 Arch。為了安全性與網路組織,我將他們放置於各自獨立的網路,接著組態設定子網路遮罩與廣播位址,如此一來網路中就只有兩台機器。為了找出子網路遮罩跟廣播位址,我使用了 ipcalc ,提供其 Arch firewire nic 的 IP 位址 10.66.66.1 ,並指定 ipcalc 要建立一個只有兩台主機的網路。<br />
<br />
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|<nowiki><br />
Address: 10.66.66.1<br />
<br />
Netmask: 255.255.255.252 = 30<br />
Network: 10.66.66.0/30<br />
HostMin: 10.66.66.1<br />
HostMax: 10.66.66.2<br />
Broadcast: 10.66.66.3<br />
Hosts/Net: 2 Class A, Private Internet<br />
</nowiki>}}<br />
<br />
== 載入組態設定 ==<br />
<br />
要測試您的設定,您可以重新啟動電腦或是重新載入相關的 systemd 服務:<br />
<br />
# systemctl restart dhcpcd@eth0<br />
<br />
您可以試著 ping 您的閘道器、 DNS 伺服器、 ISP 提供商或是其他網路上的站台。如此一來便可以確認您的網路連線問題為何,例如:<br />
<br />
$ ping -c 3 www.google.com<br />
<br />
== 附加設定 ==<br />
<br />
=== 筆記型電腦之 ifplugd ===<br />
<br />
{{Tip|{{Pkg|dhcpcd}} provides the same feature out of the box.}}<br />
<br />
{{Pkg|ifplugd}} in [[Official Repositories]] is a daemon which will automatically configure your Ethernet device when a cable is plugged in and automatically unconfigure it if the cable is pulled. This is useful on laptops with onboard network adapters, since it will only configure the interface when a cable is really connected. Another use is when you just need to restart the network but do not want to restart the computer or do it from the shell.<br />
<br />
By default it is configured to work for the {{ic|eth0}} device. This and other settings like delays can be configured in {{ic|/etc/ifplugd/ifplugd.conf}}.<br />
<br />
{{Note|[[Netctl]] package includes {{ic|netctl-ifplugd@.service}}, otherwise you can use {{ic|ifplugd@.service}} from {{Pkg|ifplugd}} package. Use for example {{ic|systemctl enable ifplugd@eth0.service}}.}}<br />
<br />
=== Bonding 或 LAG ===<br />
<br />
請參閱 [[netctl#Bonding]] 。<br />
<br />
=== IP 別名 ===<br />
<br />
{{Expansion|Manual method using [[Core Utilities#ip|ip]] should be added; then move current example using ''netctl'' into [[netctl]].}}<br />
<br />
IP 別名為讓同一個網路介面有多個 IP 位址。如此一來,單個節點的網路就能有多個網路連線,進而實現不同的作用。經典的使用方法為網頁與 FTP 伺服器的虛擬主機,或是重組伺服器而無需更新任何其他的機器(對於名稱伺服器來說特別有用)。<br />
<br />
==== 範例 ====<br />
<br />
您將需要來自[[Official Repositories|官方軟體套件庫]]的 {{Pkg|netctl}} 。<br />
<br />
準備組態設定檔:<br />
<br />
{{hc|/etc/netctl/mynetwork|<nowiki><br />
Connection='ethernet'<br />
Description='Five different addresses on the same NIC.'<br />
Interface='eth0'<br />
IP='static'<br />
Address=('192.168.1.10' '192.168.178.11' '192.168.1.12' '192.168.1.13' '192.168.1.14' '192.168.1.15')<br />
Gateway='192.168.1.1'<br />
DNS=('192.168.1.1')<br />
</nowiki>}}<br />
<br />
接著只需要將其執行:<br />
<br />
$ netctl start mynetwork<br />
<br />
=== 更改 MAC/硬體 位址 ===<br />
<br />
請參閱 [[MAC Address Spoofing]] 。<br />
<br />
=== 網路共享 ===<br />
<br />
請參閱 [[Internet Sharing]] 。<br />
<br />
=== 路由組態設定 ===<br />
<br />
請參閱 [[Router]] 。<br />
<br />
=== 區域網路主機名稱解析 ===<br />
<br />
先決條件為[[#.E8.A8.AD.E5.AE.9A.E4.B8.BB.E6.A9.9F.E5.90.8D.E7.A8.B1|設定主機名稱]]之後,主機名稱可在本機系統上解析:<br />
{{hc|$ ping hostname|<br />
PING hostname <nowiki>(192.168.1.2) 56(84) bytes of data.<br />
64 bytes from hostname (192.168.1.2): icmp_seq=1 ttl=64 time=0.043 ms</nowiki>}}<br />
要以其他機器的名稱來解析主機,需要手動設定各自的 {{ic|/etc/hosts}} 檔案或是廣播/解析名稱的服務。<br />
<br />
過度設定 DNS 伺服器,如 [[BIND]] 、 [[Unbound]] ,手動編輯 {{ic|/etc/hosts}} 過於繁瑣,或是您希望對於動態地將主機離開、加入網路有更大的靈活性,您可以在您的區域網路中使用 Zero-configuration networking 來進行主機名稱解析。這裡有兩個可用選擇:<br />
<br />
*[[Samba]] 提供了通過微軟 '''NetBIOS''' 的主機名稱解析。其只需要安裝 {{Pkg|samba}} 並啟用 {{ic|nmbd.service}} 服務。執行 Windows 、OS X 或執行了 {{ic|nmbd}} 的 Linux ,將能夠找到您的機器。<br />
<br />
*[[Avahi]] 提供通過 '''zeroconf''' 的主機名稱解析,也稱作 Avahi 或 Boujour 。它比 Samba 還需要稍微複雜一點的設定:詳情請參考 [[Avahi#Hostname resolution]]。執行 OS X 或執行了 Avahi daemon 的 Linux ,將能夠找到您的機器。Windows 並無內建 Avahi 用戶端或 Daemon 。<br />
<br />
== 診斷 ==<br />
<br />
=== Swapping computers on the cable modem ===<br />
<br />
Some cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.<br />
<br />
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].<br />
<br />
=== The TCP window scaling problem ===<br />
<br />
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.<br />
<br />
Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html RFC 1323] was written to improve the situation: Window Scaling. The "window" value, provided in all packets, will be modified by a Scale Factor defined once, at the very beginning of the connection.<br />
<br />
That 8-bit Scale Factor allows the Window to be up to 32 times higher than the initial 64Kb.<br />
<br />
It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts.<br />
<br />
The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.<br />
<br />
The resulting connection is at best very slow or broken.<br />
<br />
==== How to diagnose the problem ====<br />
<br />
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).<br />
<br />
When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|ip addr}} will report normal status... and actually everything appears normal.<br />
<br />
If you cannot browse any website, but you can ping some random hosts, chances are great that you're experiencing this problem: ping uses ICMP and is not affected by TCP problems.<br />
<br />
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).<br />
<br />
==== How to fix it (The bad way) ====<br />
<br />
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.<br />
<br />
# echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem<br />
<br />
==== How to fix it (The good way) ====<br />
<br />
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.d/99-disable_window_scaling.conf}} (see also [[sysctl]])<br />
<br />
net.ipv4.tcp_window_scaling = 0<br />
<br />
==== How to fix it (The best way) ====<br />
<br />
This problem is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.<br />
<br />
==== More about it ====<br />
<br />
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].<br />
<br />
There are also several relevant threads on the LKML.<br />
<br />
=== Realtek no link / WOL problem ===<br />
<br />
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice a problem where the NIC seems to be disabled on boot and has no Link light. This can usually be found on a dual boot system where Windows is also installed. It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause. These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots. You will be able to notice if this problem is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off. Normal operation should be that the link light is always on as long as the system is on, even during POST. This problem will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this problem:<br />
<br />
==== Method 1 - Rollback/change Windows driver ====<br />
<br />
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).<br />
<br />
==== Method 2 - Enable WOL in Windows driver ====<br />
<br />
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems). In Windows, under Device Manager, find your Realtek network adapter and double-click it. Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.<br />
<br />
In Windows XP (example)<br />
Right click my computer<br />
--> Hardware tab<br />
--> Device Manager<br />
--> Network Adapters<br />
--> "double click" Realtek ...<br />
--> Advanced tab<br />
--> Wake-On-Lan After Shutdown<br />
--> Enable<br />
<br />
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{ic|Disable}} has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.}}<br />
<br />
==== Method 3 - Newer Realtek Linux driver ====<br />
<br />
Any newer driver for these Realtek cards can be found for Linux on the realtek site. (untested but believed to also solve the problem).<br />
<br />
==== Method 4 - Enable ''LAN Boot ROM'' in BIOS/CMOS ====<br />
<br />
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.<br />
<br />
{{Note|This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.}}<br />
<br />
=== DLink G604T/DLink G502T DNS problem ===<br />
<br />
Users with a DLink G604T/DLink G502T router, using DHCP and have firmware v2.00+ (typically users with AUS firmware) may have problems with certain programs not resolving the DNS. One of these programs are unfortunatley pacman. The problem is basically the router in certain situations is not sending the DNS properly to DHCP, which causes programs to try and connect to servers with an IP address of 1.0.0.0 and fail with a connection timed out error<br />
<br />
==== How to diagnose the problem ====<br />
<br />
The best way to diagnose the problem is to use Firefox/Konqueror/links/seamonkey and to enable wget for pacman. If this is a fresh install of Arch Linux, then you may want to consider installing {{ic|links}} through the live CD.<br />
<br />
Firstly, enable wget for pacman (since it gives us info about pacman when it is downloading packages)<br />
Open {{ic|/etc/pacman.conf}} with your favourite editor and uncomment the following line (remove the # if it is there)<br />
<br />
XferCommand=/usr/bin/wget --passive-ftp -c -O %o %u<br />
<br />
While you are editing {{ic|/etc/pacman.conf}}, check the default mirror that pacman uses to download packages.<br />
<br />
Now open up the default mirror in an Internet browser to see if the mirror actually works. If it does work, then do {{ic|pacman -Syy}} (otherwise pick another working mirror and set it to the pacman default). If you get something similar to the following (notice the 1.0.0.0),<br />
<br />
<nowiki>ftp://mirror.pacific.net.au/linux/archlinux/extra/os/i686/extra.db.tar.gz</nowiki><br />
=> '/var/lib/pacman/community.db.tar.gz.part'<br />
Resolving mirror.pacific.net.au... 1.0.0.0<br />
<br />
then you most likely have this problem. The 1.0.0.0 means it is unable to resolve DNS, so we must add it to {{ic|/etc/resolv.conf}}.<br />
<br />
==== How to fix it ====<br />
<br />
{{Out of date|{{Pkg|dhcpcd}} does not use {{ic|/etc/conf.d/dhcpcd}} any more.}}<br />
<br />
Basically what we need to do is to manually add the DNS servers to our {{ic|/etc/resolv.conf}} file. The problem is that DHCP automatically deletes and replaces this file on boot, so we need to edit {{ic|/etc/conf.d/dhcpcd}} and change the flags to stop DHCP from doing this.<br />
<br />
When you open {{ic|/etc/conf.d/dhcpcd}}, you should see something close to the following:<br />
<br />
DHCPCD_ARGS="-t 30 -h $HOSTNAME"<br />
<br />
Add the {{ic|-R}} flag to the arguments, e.g.,<br />
<br />
DHCPCD_ARGS="-R -t 30 -h $HOSTNAME"<br />
<br />
{{Note|1=If you are using {{Pkg|dhcpcd}} >= 4.0.2, the {{ic|-R}} flag has been deprecated. Please see the [[#Run DHCP at boot]] section for information on how to use a custom {{ic|/etc/resolv.conf}} file.}}<br />
<br />
Save and close the file; now open {{ic|/etc/resolv.conf}}. You should see a single nameserver (most likely 10.1.1.1). This is the gateway to your router, which we need to connect to in order to get the DNS servers of your ISP. Paste the IP address into your browser and log in to your router. Go to the DNS section, and you should see an IP address in the Primary DNS Server field; copy it and paste it as a nameserver '''ABOVE''' the current gateway one.<br />
<br />
For example, {{ic|/etc/resolv.conf}} should look something along the lines of:<br />
<br />
nameserver 10.1.1.1<br />
<br />
If my primary DNS server is 211.29.132.12, then change {{ic|/etc/resolv.conf}} to:<br />
<br />
nameserver 211.29.132.12<br />
nameserver 10.1.1.1<br />
<br />
Now restart the network daemon by running {{ic|systemctl restart dhcpcd@<interface>}} and do {{ic|pacman -Syy}}. If it syncs correctly with the server, then the problem is solved.<br />
<br />
==== More about it ====<br />
<br />
This is the whirlpool forum (Australian ISP community) which talks about and gives the same solution to the problem:<br />
<br />
http://forums.whirlpool.net.au/forum-replies-archive.cfm/461625.html<br />
<br />
=== Check DHCP problem by releasing IP first ===<br />
<br />
Problem may occur when DHCP get wrong IP assignment. For example when two routers are tied together through VPN. The router that is connected to me by VPN may assigning IP address. To fix it. On a console, as root, release IP address:<br />
<br />
# dhcpcd -k<br />
<br />
Then request a new one:<br />
<br />
# dhcpcd<br />
<br />
Maybe you had to run those two commands many times.<br />
<br />
=== No eth0 with Atheros AR8161 ===<br />
<br />
{{Note|With the 3.10.2-1-ARCH kernel update, the alx ethernet driver module is included in the package.}}<br />
<br />
With the Atheros AR8161 Gigabit Ethernet card, the ethernet connection is not working out-of-the-box (with the installation media of March 2013). The module "alx" needs to be loaded but is not present.<br />
<br />
The driver from [http://linuxwireless.org/en/users/Download/stable/#compat-wireless_stable_releases compat-wireless] (that has become [https://backports.wiki.kernel.org/index.php/Releases compat-drives] since linux 3.7) need to be installed. The "-u" postfix annotates that Qualcomm have applied a driver under a unified driver.<br />
<br />
$ wget https://www.kernel.org/pub/linux/kernel/projects/backports/2013/03/28/compat-drivers-2013-03-28-5-u.tar.bz2<br />
$ tar xjf compat*<br />
$ cd compat*<br />
$ ./scripts/driver-select alx<br />
$ make<br />
$ sudo make install<br />
$ sudo modprobe alx<br />
<br />
The alx driver has not been added to Linux kernel due to various problems. Compatibility between the different kernel versions has been spotty. For better support follow the [http://lists.infradead.org/mailman/listinfo/unified-drivers mailing list]and [http://www.linuxfoundation.org/collaborate/workgroups/networking/alx alx page]for latest working solution for alx.<br />
<br />
The driver must be built and installed after every kernel change.<br />
<br />
Alternatively you can use the AUR package for [https://aur.archlinux.org/packages/compat-drivers-patched/ compat drivers], which installs many other drivers.<br />
<br />
=== No eth0 with Atheros AR9485 ===<br />
<br />
The ethernet (eth0) for Atheros AR9485 are not working out-of-the-box (with installation media of March 2013). The working solution for this is to install the package [https://aur.archlinux.org/packages/compat-drivers-patched/ compat-drivers-patched] from AUR.<br />
<br />
=== No carrier / no connection after suspend ===<br />
After suspend to RAM no connection is found although the network cable is plugged in. <br />
This may be caused by PCI power management. What is the output of<br />
<br />
# ip link show eth0<br />
<br />
If the line contains "NO-CARRIER" even though there's a cable connected to your eth0 port, it is possible that the device was auto-suspended and the media sense feature doesn't work. To solve this, first you need to find your ethernet controllers PCI address by<br />
<br />
# lspci<br />
<br />
This should look similar to this:<br />
<br />
...<br />
00:19.0 Ethernet controller: Intel Corporation 82577LM Gigabit Network Connection (rev 06)<br />
...<br />
<br />
So the address is 00:19.0.<br />
Now check the PM status of the device by issuing<br />
<br />
# cat "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
substituting 00:19.0 with the address obtained from lspci.<br />
If the output reads "auto", you can try to bring the device out of suspend by<br />
<br />
# echo on > "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
Don't forget to substitute the address again.<br />
<br />
{{Note|1=This appears to be a bug in kernel 3.8.4.1- (3.8.8.1 is still affected): [https://bbs.archlinux.org/viewtopic.php?id=159837&p=2 Forum discussion.] It also appears a fix is [https://lkml.org/lkml/2013/1/18/147 on the way. (It will be likely fixed in 3.9.)] In the meantime, the above is a suitable workaround.}}<br />
<br />
=== Broadcom BCM57780 ===<br />
<br />
This Broadcom chipset sometimes does not behave well unless you specify the order of the modules to be loaded. The modules are {{ic|broadcom}} and {{ic|tg3}}, the former needing to be loaded first.<br />
<br />
These steps should help if your computer has this chipset:<br />
$ lspci | grep Ethernet<br />
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)<br />
<br />
If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following (as root):<br />
# modprobe -r tg3<br />
# modprobe broadcom<br />
# modprobe tg3<br />
<br />
Now plug you network cable in. If this solves your problems you can make this permanent by adding {{ic|broadcom}} and {{ic|tg3}} (in this order) to the {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}}:<br />
<br />
MODULES=".. broadcom tg3 .."<br />
<br />
Then rebuild the initramfs:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|These methods may work for other chipsets, such as BCM57760.}}</div>Binotahttps://wiki.archlinux.org/index.php?title=Network_configuration_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=293555Network configuration (正體中文)2014-01-19T10:12:03Z<p>Binota: /* Internet Sharing */ Translated</p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:Networking (正體中文)]]<br />
[[Category:Getting and installing Arch (正體中文)]]<br />
<br />
[[cs:Configuring Network]]<br />
[[el:Configuring Network]]<br />
[[es:Configuring Network]]<br />
[[fr:Connexions reseau]]<br />
[[it:Configuring Network]]<br />
[[ja:Network Configuration]]<br />
[[nl:Configuring Network]]<br />
[[pt:Configuring Network]]<br />
[[ro:Configurare retea]]<br />
[[ru:Configuring Network]]<br />
[[sk:Configuring Network]]<br />
[[tr:Ağ_Yapılandırması]]<br />
[[zh-CN:Network Configuration]]<br />
[[zh-TW:Network Configuration]]<br />
{{Related articles start}}<br />
{{Related|Jumbo Frames}}<br />
{{Related|Firewalls}}<br />
{{Related|Wireless Setup}}<br />
{{Related|List of Applications#Network Managers}}<br />
{{Related articles end}}<br />
{{TranslationStatus (正體中文)|Network_Configuration|2014-01-19|293523}}<br />
<br />
本頁將介紹如何設定 '''有線''' 網路連線。若您需要設定 '''無線''' 網路,請參考[[Wireless Setup|無線網路設定]]。<br />
<br />
== 檢查連線 ==<br />
<br />
{{註記|若您在執行 ping 時收到了類似 {{ic|ping: icmp open socket: Operation not permitted}} 這樣的錯誤訊息,請嘗試重新安裝 {{ic|iputils}} 軟體包。}} <br />
<br />
一般來說,基本的安裝過程都已經建立了可運作的網路設定。請執行下列指令以進行檢查:<br />
<br />
{{註記|{{ic|-c 3}} 選項表示將會呼叫三次。詳細請參閱 {{ic|man ping}} 。}}<br />
{{提示|您也可以嘗試使用其他的 Domain ,如 www.hinet.net 。}}<br />
<br />
{{hc|$ ping -c 3 www.google.com|<nowiki><br />
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.<br />
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms<br />
64 bytes from 74.125.224.146: icmp_req=2 ttl=50 time=385 ms<br />
64 bytes from 74.125.224.146: icmp_req=3 ttl=50 time=298 ms<br />
<br />
--- www.l.google.com ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 1999ms<br />
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms<br />
</nowiki>}}<br />
<br />
如果沒問題的話,您可能只是想以本文的下列部分來自定您的設定。<br />
<br />
若剛才的指令出現了 unknown hosts 之類的訊息,代表您的機器無法解析網域。這可能是因為您的網路服務提供商/閘道器造成的。您可以嘗試 ping 一個靜態 IP 以實驗您的機器可否存取網際網路。<br />
{{提示|您也可以嘗試使用其他的 IP ,如 168.95.1.1 。}}<br />
<br />
{{hc|$ ping -c 3 8.8.8.8|<nowiki><br />
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.<br />
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms<br />
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms<br />
64 bytes from 8.8.8.8: icmp_req=3 ttl=53 time=70.6 ms<br />
<br />
--- 8.8.8.8 ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 2002ms<br />
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms<br />
</nowiki>}}<br />
<br />
{{註記|{{ic|8.8.8.8}} 為一個好記的靜態 IP 位置。這是 Google 的主要 DNS 伺服器,這表示其有一定的可信度,並且通常不會被系統或代理伺服器擋下。}}<br />
<br />
若您可以 ping 通該位置,您可能需要試著在 {{ic|/etc/resolv.conf}} 檔案中加上網域名稱伺服器。<br />
<br />
== 設定主機名稱 ==<br />
<br />
[[Wikipedia:Hostname|主機名稱]]為網路中用於識別機器的唯一識別名稱:主機名稱可以通過 {{ic|/etc/hostname}} 檔案來進行設定。一般來說該檔案包含了系統的網域名稱。下面為設定主機名稱的方法:<br />
<br />
# hostnamectl set-hostname '''myhostname'''<br />
<br />
這樣會將 '''myhostname''' 寫入 {{ic|/etc/hostname}} 檔案中。<br />
<br />
詳細請參閱 {{ic|man 5 hostname}} 與 {{ic|man 1 hostnamectl}} 。<br />
<br />
{{註記|<br />
* {{ic|hostnamectl}} 支援 FQDN<br />
* 您不需要編輯 {{ic|/etc/hosts}} 檔案,{{pkg|systemd}} 會提供主機名稱解析且預設安裝於所有系統。<br />
}}<br />
<br />
使用來自 {{Pkg|inetutils}} 的 {{ic|hostname}} 指令以設定臨時主機名稱(直到重新啟動):<br />
<br />
# hostname ''myhostname''<br />
<br />
== 裝置驅動程式 ==<br />
<br />
=== 檢查驅動程式狀態 ===<br />
<br />
[[udev]] 應該會檢測您的網路介面卡([[Wikipedia:Network_interface_controller|NIC]])並自動於啟動時載入必要的模組。檢查 {{ic|lspci -v}} 輸出內容中的「Ethernet controller」 項目(或類似的)。這應該會告訴您哪些核心模組包含了網路設備的驅動程式。舉例來說:<br />
<br />
{{hc|$ lspci -v|<br />
02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)<br />
...<br />
Kernel driver in use: atl1<br />
Kernel modules: atl1<br />
}}<br />
<br />
接下來,確認該驅動程式已經通過 {{ic|dmesg <nowiki>|</nowiki> grep ''module_name''}} 載入了。舉例來說:<br />
<br />
$ dmesg | grep atl1<br />
...<br />
atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex<br />
<br />
若驅動程式已成功加載可以跳過接下來這段。否則,您會需要知道哪些模組時您的特定型號的裝置需要哪個模組。<br />
<br />
=== 載入裝置模組 ===<br />
<br />
以 Google 搜尋正確的晶片組模組/驅動程式。常見的驅動模組有 Realtek 晶片組網卡的 {{ic|8139too}} ,或是 SiS 晶片組網卡的 {{ic|sis900}}。當您知道要使用何種模組了之後,試著[[Kernel modules#Manual module handling|手動將其載入]]。若您的到了錯誤訊息告訴您找不到該模組,則該驅動可能未包含於 Arch 核心中。您可以在 [[AUR]] 中搜尋該模組名稱。<br />
<br />
若 udev 未在開機期間檢測與載入正確的模組,請參閱 [[Kernel modules#Loading]]。<br />
<br />
== 網路介面 ==<br />
<br />
=== 裝置名稱 ===<br />
<br />
對於多網路卡的電腦,固定裝置名稱非常重要。許多設定問題都是因為介面卡名稱的改動造成的。<br />
<br />
[[udev]] 負責命名裝置。Systemd v197 則有[http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames 可預測之網路介面名稱]並可自動支配靜態名稱給網路裝置。介面名稱以 {{ic|en}} (乙太網路)、 {{ic|wl}} (無線網路) 或是 {{ic|ww}} (WWAN)作為前置字串並附上一個自動產生的識別名稱,進而產生了類似 {{ic|enp0s25}} 這樣的名稱。 <br />
<br />
要禁用這種行為,可以加上一個連接:<br />
<br />
# ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules<br />
<br />
自早期版本升級 systemd 的使用者會有一自動建立的空規則檔案。因此,若您想使用一貫的裝置名稱,只需要刪除該檔案。<br />
<br />
{{提示|您可以執行 {{ic|ip link}} 或是 {{ic|ls /sys/class/net}} 以列出所有可用的介面。}}<br />
<br />
{{註記|當您更改了介面名稱規則後,別忘了更新所有跟網路有關的組態檔案與自定的 systemd unit 檔案以因應該更改。特別是當您啟用了 [[netctl#Basic method|netctl 靜態設定檔]] ,請執行 {{ic|netctl reenable ''profile''}} 以更新所有產生的服務檔案。}}<br />
<br />
==== 更改裝置名稱 ====<br />
<br />
您可以使用 udev-rule 來手動定義裝置名稱。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"<br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"<br />
</nowiki>}}<br />
<br />
請注意這兩點:<br />
<br />
* 使用這個指令以取得 MAC 位置:{{ic|cat /sys/class/net/''device_name''/address}}。<br />
* 請確定 udev 規則中使用的是小寫的十六進位數值而不是大寫。<br />
<br />
若您的網路卡為動態 MAC ,您可以使用 DEVPATH ,例如:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"<br />
</nowiki>}}<br />
<br />
{{註記|當使用了靜態的名稱時,'''應該要避免使用類似 "eth''X''" 與 "wlan''X''"''' 這樣的名稱,因為這可能會導致核心與 udev 在開機時發生衝突。而剛好相反地,最好使用核心預設不會使用的介面名稱,如 {{ic|net0}} 、 {{ic|net1}} 、 {{ic|wifi0}} 、 {{ic|wifi1}} 。詳細說明請參閱 [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames systemd] 文件。}}<br />
<br />
=== 設定裝置的 MTU 與佇列長度 ===<br />
<br />
您可以手動定義 udev 規則來更改裝置的 MTU 與佇列長度。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1480", ATTR{tx_queue_len}="2000"<br />
</nowiki>}}<br />
<br />
=== 取得目前的裝置名稱 ===<br />
<br />
目前的 NIC 名稱可以通過 sysfs 找到<br />
<br />
{{hc|$ ls /sys/class/net|<br />
lo eth0 eth1 firewire0<br />
}}<br />
<br />
=== 啟用與禁用網路介面 ===<br />
<br />
您可以使用下列指令來啟用或禁用網路介面:<br />
<br />
# ip link set eth0 up<br />
# ip link set eth0 down<br />
<br />
要確認結果,請執行:<br />
<br />
{{hc|$ ip link show dev eth0|<br />
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000<br />
...<br />
}}<br />
<br />
== 組態設定 IP 位址 ==<br />
<br />
您有兩個選擇:使用 [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]] 指派動態位址,或是使用「靜態」的位址。<br />
<br />
=== 動態 IP 位址 ===<br />
<br />
==== 手動執行 DHCP 用戶端 Daemon ====<br />
<br />
{{註記|請特別注意 {{ic|dhcpcd}} (DHCP ''Client'' Daemon,DHCP 用戶端 Daemon) 與 {{ic|dhcpd}} (DHCP ''(server)'' daemon,DHCP 伺服端 Daemon) 間的差異。}}<br />
<br />
{{hc|# dhcpcd eth0|<br />
dhcpcd: version 5.1.1 starting<br />
dhcpcd: eth0: broadcasting for a lease<br />
...<br />
dhcpcd: eth0: leased 192.168.1.70 for 86400 seconds<br />
}}<br />
<br />
緊接著, {{ic|ip addr show dev eth0}} 應該要顯示出您的 inet 位址。<br />
<br />
對部分的人而言,{{ic|dhcpcd}} 失敗時,可以使用 {{ic|dhclient}} (位於 {{Pkg|dhclient}} 軟體包中)<br />
<br />
==== 於啟動時執行 DHCP ====<br />
<br />
若您只是想使用 DHCP 來連線至您的乙太網路連線,您可以使用 {{ic|dhcpcd@.service}} (由 {{Pkg|dhcpcd}} 軟體包提供)。<br />
<br />
要啟動 {{ic|eth0}} 上的 DHCP ,只需要使用:<br />
<br />
# systemctl start dhcpcd@eth0.service<br />
<br />
您可以下列方法啟用該服務讓其於開機時自動啟動:<br />
<br />
# systemctl enable dhcpcd@eth0.service<br />
<br />
若您用了 DHCP 且您並 '''不想''' 讓您的 DNS 伺服器在每次啟動您的網路時自動指派,請將下列內容加到 {{ic|dhcpcd.conf}} 的最後一段中:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nohook resolv.conf<br />
}}<br />
<br />
另外,若您位於基於 MAC 位址的用戶端 IP 位址進行過濾的 DHCPv4 網路,您可能需要修改下列內容:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 Client ID as per RFC4361. <br />
duid<br />
}}<br />
<br />
為:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the hardware address of the interface for the Client ID (DHCPv4).<br />
clientid<br />
}}<br />
<br />
否則,您可能會因為 DHCP 伺服器無法正確讀取您的 [http://en.wikipedia.org/wiki/DHCPv6 DHCPv6-style] 用戶端 ID 而無法使用。詳細請參閱 [http://tools.ietf.org/html/rfc4361 RFC 4361] 。<br />
<br />
為防止 {{ic|dhcpcd}} 加入網域名稱伺服器至 {{ic|/etc/resolv.conf}} 中,請於其中使用 {{ic|nooption}} 選項:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nooption domain_name_servers<br />
}}<br />
<br />
接著加入您自己的 DNS 名稱伺服器至 {{ic|/etc/resolv.conf}} 中。<br />
<br />
若有多個不同的執行緒要控制 {{ic|/etc/resolv.conf}} (如 {{Pkg|dhcpcd}} 與 VPN 用戶端),您可能會想要使用 {{Pkg|openresolv}} 軟體包。使用 {{Pkg|openresolv}} 並不需要額外地設定 {{Pkg|dhcpcd}} 。<br />
<br />
==== DHCP 靜態路由 ====<br />
若您需要加入靜態路由用戶端,請於 {{ic|/usr/lib/dhcpcd/dhcpcd-hooks}} 中建立一個新的 dhcpcd hook-script 。下列範例展示了加入靜態路由至一個通過閘道器為 192.168.192.5 ,位於 10.11.12.0/24 的 VPN 子網路:<br />
{{hc|/usr/lib/dhcpcd/dhcpcd-hooks/40-vpnroute|<br />
ip route add 10.11.12.0/24 via 192.168.192.5<br />
}}<br />
前置字串''40''表示其於 dhcpcd 啟動時的最後執行 hook-script 。<br />
<br />
=== 靜態 IP 位址 ===<br />
<br />
您可能因為各種原因而希望在您的網路中指派靜態 IP 位址,例如靜態的位址可以獲得一定程度的可預測性,或是您沒有可用的 DHCP 伺服器。<br />
<br />
{{註記|若您共通過 Windows 機器共享您的網路而沒有路由器,請確保兩台電腦皆使用了靜態 IP 位址以避免區域網路問題。}}<br />
<br />
您需要:<br />
<br />
* 靜態 IP 位址<br />
* [[Wikipedia:Subnetwork|子網路遮罩]]<br />
* [[Wikipedia:Broadcast_address|廣播位址]]<br />
* [[Wikipedia:Default_gateway|預設閘道器]]的 IP 位址<br />
<br />
若您處在內部網路中,使用 192.168.*.* 這樣的 IP 位址較為安全,搭配其的子網路遮罩 255.255.255.0 ,廣播位址為 192.168.*.255 。而閘道器通常是 192.168.*.1 或是 192.168.*.254 。<br />
<br />
==== 手動指派 ====<br />
<br />
您可於控制台中指派一靜態 IP 位址:<br />
<br />
# ip addr add <IP 位址>/<子網路遮罩> broadcast <廣播> dev <介面><br />
<br />
舉例來說:<br />
<br />
# ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev eth0<br />
<br />
{{註記|子網路遮罩使用了 [[Wikipedia:CIDR_notation|CIDR 表示法]](CIDR,Classless Inter-Domain Routing,無類別網路間路由)。}}<br />
<br />
詳情請參閱 {{ic|man ip}} 。<br />
<br />
以類似下列方法加上您的閘道器:<br />
<br />
# ip route add default via <預設閘道器 IP 位址><br />
<br />
舉例來說:<br />
<br />
# ip route add default via 192.168.1.1<br />
<br />
若您得到了 "No such process" 這樣的錯誤訊息,這代表您必須以 root 執行 {{ic|ip link set dev eth0 up}} 。<br />
<br />
==== 於啟動時通過 systemd 手動連線 ====<br />
<br />
先確保 dhcpcd 已停止並禁用:<br />
<br />
# systemctl status dhcpcd.service<br />
<br />
接著為 [[systemd]] 服務建立一個檔案。以正確的網路介面名稱取代其中的 {{ic|<interface>}} :<br />
<br />
{{hc|/etc/conf.d/network@<interface>|<nowiki><br />
address=192.168.0.15<br />
netmask=24<br />
broadcast=192.168.0.255<br />
gateway=192.168.0.1<br />
</nowiki>}}<br />
<br />
建立 systemd unit 檔案:<br />
<br />
{{hc|/etc/systemd/system/network@.service|<nowiki><br />
[Unit]<br />
Description=Network connectivity (%i)<br />
Wants=network.target<br />
Before=network.target<br />
BindsTo=sys-subsystem-net-devices-%i.device<br />
After=sys-subsystem-net-devices-%i.device<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
EnvironmentFile=/etc/conf.d/network@%i<br />
<br />
ExecStart=/usr/bin/ip link set dev %i up<br />
ExecStart=/usr/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i<br />
ExecStart=/usr/bin/ip route add default via ${gateway}<br />
<br />
ExecStop=/usr/bin/ip addr flush dev %i<br />
ExecStop=/usr/bin/ip link set dev %i down<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
啟用該 unit 並將其啟動,傳入介面名稱,例如 eno1 :<br />
<br />
# systemctl enable network@eno1.service<br />
# systemctl start network@eno1.service<br />
<br />
若您需要手動設定 nameservers ,請編輯 {{ic|/etc/resolv.conf}} 檔案:<br />
<br />
{{hc|/etc/resolv.conf|<br />
nameserver 208.67.222.222<br />
nameserver 208.67.220.220}}<br />
<br />
若 {{ic|/etc/resolv.conf}} 被持續遭到複寫,請參考 [[Resolv.conf]] 以瞭解如何解決此問題。<br />
<br />
有幾個類似的方法來讓 systemd 啟動網路,其中的差異為檔案內容,並且其可以寫死 EnvironmentFile 定義的參考檔案中抓到的參數。因此可以作為一種替代的,將介面名稱放置於 /etc/conf.d/ 中的 EnvironmentFile 接著直接使用介面名稱而不是 %i 。如此一來,檔案名稱便不需要「@」。這也是一種有用的方法來閱讀 http://www.freedesktop.org/software/systemd/man/systemd.unit.html 上的 systemd 服務文件。<br />
<br />
==== 計算位址 ====<br />
<br />
您可以使用 {{Pkg|ipcalc}} 提供的 {{ic|ipcalc}} 來計算 IP 廣播、網域、子網路遮罩與主機範圍等進階設定舉例來說,我使用了位於防火牆後的乙太網路來連線 Windows 機器至 Arch。為了安全性與網路組織,我將他們放置於各自獨立的網路,接著組態設定子網路遮罩與廣播位址,如此一來網路中就只有兩台機器。為了找出子網路遮罩跟廣播位址,我使用了 ipcalc ,提供其 Arch firewire nic 的 IP 位址 10.66.66.1 ,並指定 ipcalc 要建立一個只有兩台主機的網路。<br />
<br />
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|<nowiki><br />
Address: 10.66.66.1<br />
<br />
Netmask: 255.255.255.252 = 30<br />
Network: 10.66.66.0/30<br />
HostMin: 10.66.66.1<br />
HostMax: 10.66.66.2<br />
Broadcast: 10.66.66.3<br />
Hosts/Net: 2 Class A, Private Internet<br />
</nowiki>}}<br />
<br />
== 載入組態設定 ==<br />
<br />
要測試您的設定,您可以重新啟動電腦或是重新載入相關的 systemd 服務:<br />
<br />
# systemctl restart dhcpcd@eth0<br />
<br />
您可以試著 ping 您的閘道器、 DNS 伺服器、 ISP 提供商或是其他網路上的站台。如此一來便可以確認您的網路連線問題為何,例如:<br />
<br />
$ ping -c 3 www.google.com<br />
<br />
== 附加設定 ==<br />
<br />
=== 筆記型電腦之 ifplugd ===<br />
<br />
{{Tip|{{Pkg|dhcpcd}} provides the same feature out of the box.}}<br />
<br />
{{Pkg|ifplugd}} in [[Official Repositories]] is a daemon which will automatically configure your Ethernet device when a cable is plugged in and automatically unconfigure it if the cable is pulled. This is useful on laptops with onboard network adapters, since it will only configure the interface when a cable is really connected. Another use is when you just need to restart the network but do not want to restart the computer or do it from the shell.<br />
<br />
By default it is configured to work for the {{ic|eth0}} device. This and other settings like delays can be configured in {{ic|/etc/ifplugd/ifplugd.conf}}.<br />
<br />
{{Note|[[Netctl]] package includes {{ic|netctl-ifplugd@.service}}, otherwise you can use {{ic|ifplugd@.service}} from {{Pkg|ifplugd}} package. Use for example {{ic|systemctl enable ifplugd@eth0.service}}.}}<br />
<br />
=== Bonding 或 LAG ===<br />
<br />
請參閱 [[netctl#Bonding]] 。<br />
<br />
=== IP 別名 ===<br />
<br />
{{Expansion|Manual method using [[Core Utilities#ip|ip]] should be added; then move current example using ''netctl'' into [[netctl]].}}<br />
<br />
IP 別名為讓同一個網路介面有多個 IP 位址。如此一來,單個節點的網路就能有多個網路連線,進而實現不同的作用。經典的使用方法為網頁與 FTP 伺服器的虛擬主機,或是重組伺服器而無需更新任何其他的機器(對於名稱伺服器來說特別有用)。<br />
<br />
==== 範例 ====<br />
<br />
您將需要來自[[Official Repositories|官方軟體套件庫]]的 {{Pkg|netctl}} 。<br />
<br />
準備組態設定檔:<br />
<br />
{{hc|/etc/netctl/mynetwork|<nowiki><br />
Connection='ethernet'<br />
Description='Five different addresses on the same NIC.'<br />
Interface='eth0'<br />
IP='static'<br />
Address=('192.168.1.10' '192.168.178.11' '192.168.1.12' '192.168.1.13' '192.168.1.14' '192.168.1.15')<br />
Gateway='192.168.1.1'<br />
DNS=('192.168.1.1')<br />
</nowiki>}}<br />
<br />
接著只需要將其執行:<br />
<br />
$ netctl start mynetwork<br />
<br />
=== 更改 MAC/硬體 位址 ===<br />
<br />
請參閱 [[MAC Address Spoofing]] 。<br />
<br />
=== 網路共享 ===<br />
<br />
請參閱 [[Internet Sharing]] 。<br />
<br />
=== Router Configuration ===<br />
<br />
請參閱 [[Router]] 。<br />
<br />
=== 區域網路主機名稱解析 ===<br />
<br />
先決條件為[[#.E8.A8.AD.E5.AE.9A.E4.B8.BB.E6.A9.9F.E5.90.8D.E7.A8.B1|設定主機名稱]]之後,主機名稱可在本機系統上解析:<br />
{{hc|$ ping hostname|<br />
PING hostname <nowiki>(192.168.1.2) 56(84) bytes of data.<br />
64 bytes from hostname (192.168.1.2): icmp_seq=1 ttl=64 time=0.043 ms</nowiki>}}<br />
要以其他機器的名稱來解析主機,需要手動設定各自的 {{ic|/etc/hosts}} 檔案或是廣播/解析名稱的服務。<br />
<br />
過度設定 DNS 伺服器,如 [[BIND]] 、 [[Unbound]] ,手動編輯 {{ic|/etc/hosts}} 過於繁瑣,或是您希望對於動態地將主機離開、加入網路有更大的靈活性,您可以在您的區域網路中使用 Zero-configuration networking 來進行主機名稱解析。這裡有兩個可用選擇:<br />
<br />
*[[Samba]] 提供了通過微軟 '''NetBIOS''' 的主機名稱解析。其只需要安裝 {{Pkg|samba}} 並啟用 {{ic|nmbd.service}} 服務。執行 Windows 、OS X 或執行了 {{ic|nmbd}} 的 Linux ,將能夠找到您的機器。<br />
<br />
*[[Avahi]] 提供通過 '''zeroconf''' 的主機名稱解析,也稱作 Avahi 或 Boujour 。它比 Samba 還需要稍微複雜一點的設定:詳情請參考 [[Avahi#Hostname resolution]]。執行 OS X 或執行了 Avahi daemon 的 Linux ,將能夠找到您的機器。Windows 並無內建 Avahi 用戶端或 Daemon 。<br />
<br />
== 診斷 ==<br />
<br />
=== Swapping computers on the cable modem ===<br />
<br />
Some cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.<br />
<br />
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].<br />
<br />
=== The TCP window scaling problem ===<br />
<br />
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.<br />
<br />
Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html RFC 1323] was written to improve the situation: Window Scaling. The "window" value, provided in all packets, will be modified by a Scale Factor defined once, at the very beginning of the connection.<br />
<br />
That 8-bit Scale Factor allows the Window to be up to 32 times higher than the initial 64Kb.<br />
<br />
It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts.<br />
<br />
The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.<br />
<br />
The resulting connection is at best very slow or broken.<br />
<br />
==== How to diagnose the problem ====<br />
<br />
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).<br />
<br />
When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|ip addr}} will report normal status... and actually everything appears normal.<br />
<br />
If you cannot browse any website, but you can ping some random hosts, chances are great that you're experiencing this problem: ping uses ICMP and is not affected by TCP problems.<br />
<br />
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).<br />
<br />
==== How to fix it (The bad way) ====<br />
<br />
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.<br />
<br />
# echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem<br />
<br />
==== How to fix it (The good way) ====<br />
<br />
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.d/99-disable_window_scaling.conf}} (see also [[sysctl]])<br />
<br />
net.ipv4.tcp_window_scaling = 0<br />
<br />
==== How to fix it (The best way) ====<br />
<br />
This problem is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.<br />
<br />
==== More about it ====<br />
<br />
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].<br />
<br />
There are also several relevant threads on the LKML.<br />
<br />
=== Realtek no link / WOL problem ===<br />
<br />
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice a problem where the NIC seems to be disabled on boot and has no Link light. This can usually be found on a dual boot system where Windows is also installed. It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause. These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots. You will be able to notice if this problem is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off. Normal operation should be that the link light is always on as long as the system is on, even during POST. This problem will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this problem:<br />
<br />
==== Method 1 - Rollback/change Windows driver ====<br />
<br />
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).<br />
<br />
==== Method 2 - Enable WOL in Windows driver ====<br />
<br />
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems). In Windows, under Device Manager, find your Realtek network adapter and double-click it. Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.<br />
<br />
In Windows XP (example)<br />
Right click my computer<br />
--> Hardware tab<br />
--> Device Manager<br />
--> Network Adapters<br />
--> "double click" Realtek ...<br />
--> Advanced tab<br />
--> Wake-On-Lan After Shutdown<br />
--> Enable<br />
<br />
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{ic|Disable}} has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.}}<br />
<br />
==== Method 3 - Newer Realtek Linux driver ====<br />
<br />
Any newer driver for these Realtek cards can be found for Linux on the realtek site. (untested but believed to also solve the problem).<br />
<br />
==== Method 4 - Enable ''LAN Boot ROM'' in BIOS/CMOS ====<br />
<br />
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.<br />
<br />
{{Note|This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.}}<br />
<br />
=== DLink G604T/DLink G502T DNS problem ===<br />
<br />
Users with a DLink G604T/DLink G502T router, using DHCP and have firmware v2.00+ (typically users with AUS firmware) may have problems with certain programs not resolving the DNS. One of these programs are unfortunatley pacman. The problem is basically the router in certain situations is not sending the DNS properly to DHCP, which causes programs to try and connect to servers with an IP address of 1.0.0.0 and fail with a connection timed out error<br />
<br />
==== How to diagnose the problem ====<br />
<br />
The best way to diagnose the problem is to use Firefox/Konqueror/links/seamonkey and to enable wget for pacman. If this is a fresh install of Arch Linux, then you may want to consider installing {{ic|links}} through the live CD.<br />
<br />
Firstly, enable wget for pacman (since it gives us info about pacman when it is downloading packages)<br />
Open {{ic|/etc/pacman.conf}} with your favourite editor and uncomment the following line (remove the # if it is there)<br />
<br />
XferCommand=/usr/bin/wget --passive-ftp -c -O %o %u<br />
<br />
While you are editing {{ic|/etc/pacman.conf}}, check the default mirror that pacman uses to download packages.<br />
<br />
Now open up the default mirror in an Internet browser to see if the mirror actually works. If it does work, then do {{ic|pacman -Syy}} (otherwise pick another working mirror and set it to the pacman default). If you get something similar to the following (notice the 1.0.0.0),<br />
<br />
<nowiki>ftp://mirror.pacific.net.au/linux/archlinux/extra/os/i686/extra.db.tar.gz</nowiki><br />
=> '/var/lib/pacman/community.db.tar.gz.part'<br />
Resolving mirror.pacific.net.au... 1.0.0.0<br />
<br />
then you most likely have this problem. The 1.0.0.0 means it is unable to resolve DNS, so we must add it to {{ic|/etc/resolv.conf}}.<br />
<br />
==== How to fix it ====<br />
<br />
{{Out of date|{{Pkg|dhcpcd}} does not use {{ic|/etc/conf.d/dhcpcd}} any more.}}<br />
<br />
Basically what we need to do is to manually add the DNS servers to our {{ic|/etc/resolv.conf}} file. The problem is that DHCP automatically deletes and replaces this file on boot, so we need to edit {{ic|/etc/conf.d/dhcpcd}} and change the flags to stop DHCP from doing this.<br />
<br />
When you open {{ic|/etc/conf.d/dhcpcd}}, you should see something close to the following:<br />
<br />
DHCPCD_ARGS="-t 30 -h $HOSTNAME"<br />
<br />
Add the {{ic|-R}} flag to the arguments, e.g.,<br />
<br />
DHCPCD_ARGS="-R -t 30 -h $HOSTNAME"<br />
<br />
{{Note|1=If you are using {{Pkg|dhcpcd}} >= 4.0.2, the {{ic|-R}} flag has been deprecated. Please see the [[#Run DHCP at boot]] section for information on how to use a custom {{ic|/etc/resolv.conf}} file.}}<br />
<br />
Save and close the file; now open {{ic|/etc/resolv.conf}}. You should see a single nameserver (most likely 10.1.1.1). This is the gateway to your router, which we need to connect to in order to get the DNS servers of your ISP. Paste the IP address into your browser and log in to your router. Go to the DNS section, and you should see an IP address in the Primary DNS Server field; copy it and paste it as a nameserver '''ABOVE''' the current gateway one.<br />
<br />
For example, {{ic|/etc/resolv.conf}} should look something along the lines of:<br />
<br />
nameserver 10.1.1.1<br />
<br />
If my primary DNS server is 211.29.132.12, then change {{ic|/etc/resolv.conf}} to:<br />
<br />
nameserver 211.29.132.12<br />
nameserver 10.1.1.1<br />
<br />
Now restart the network daemon by running {{ic|systemctl restart dhcpcd@<interface>}} and do {{ic|pacman -Syy}}. If it syncs correctly with the server, then the problem is solved.<br />
<br />
==== More about it ====<br />
<br />
This is the whirlpool forum (Australian ISP community) which talks about and gives the same solution to the problem:<br />
<br />
http://forums.whirlpool.net.au/forum-replies-archive.cfm/461625.html<br />
<br />
=== Check DHCP problem by releasing IP first ===<br />
<br />
Problem may occur when DHCP get wrong IP assignment. For example when two routers are tied together through VPN. The router that is connected to me by VPN may assigning IP address. To fix it. On a console, as root, release IP address:<br />
<br />
# dhcpcd -k<br />
<br />
Then request a new one:<br />
<br />
# dhcpcd<br />
<br />
Maybe you had to run those two commands many times.<br />
<br />
=== No eth0 with Atheros AR8161 ===<br />
<br />
{{Note|With the 3.10.2-1-ARCH kernel update, the alx ethernet driver module is included in the package.}}<br />
<br />
With the Atheros AR8161 Gigabit Ethernet card, the ethernet connection is not working out-of-the-box (with the installation media of March 2013). The module "alx" needs to be loaded but is not present.<br />
<br />
The driver from [http://linuxwireless.org/en/users/Download/stable/#compat-wireless_stable_releases compat-wireless] (that has become [https://backports.wiki.kernel.org/index.php/Releases compat-drives] since linux 3.7) need to be installed. The "-u" postfix annotates that Qualcomm have applied a driver under a unified driver.<br />
<br />
$ wget https://www.kernel.org/pub/linux/kernel/projects/backports/2013/03/28/compat-drivers-2013-03-28-5-u.tar.bz2<br />
$ tar xjf compat*<br />
$ cd compat*<br />
$ ./scripts/driver-select alx<br />
$ make<br />
$ sudo make install<br />
$ sudo modprobe alx<br />
<br />
The alx driver has not been added to Linux kernel due to various problems. Compatibility between the different kernel versions has been spotty. For better support follow the [http://lists.infradead.org/mailman/listinfo/unified-drivers mailing list]and [http://www.linuxfoundation.org/collaborate/workgroups/networking/alx alx page]for latest working solution for alx.<br />
<br />
The driver must be built and installed after every kernel change.<br />
<br />
Alternatively you can use the AUR package for [https://aur.archlinux.org/packages/compat-drivers-patched/ compat drivers], which installs many other drivers.<br />
<br />
=== No eth0 with Atheros AR9485 ===<br />
<br />
The ethernet (eth0) for Atheros AR9485 are not working out-of-the-box (with installation media of March 2013). The working solution for this is to install the package [https://aur.archlinux.org/packages/compat-drivers-patched/ compat-drivers-patched] from AUR.<br />
<br />
=== No carrier / no connection after suspend ===<br />
After suspend to RAM no connection is found although the network cable is plugged in. <br />
This may be caused by PCI power management. What is the output of<br />
<br />
# ip link show eth0<br />
<br />
If the line contains "NO-CARRIER" even though there's a cable connected to your eth0 port, it is possible that the device was auto-suspended and the media sense feature doesn't work. To solve this, first you need to find your ethernet controllers PCI address by<br />
<br />
# lspci<br />
<br />
This should look similar to this:<br />
<br />
...<br />
00:19.0 Ethernet controller: Intel Corporation 82577LM Gigabit Network Connection (rev 06)<br />
...<br />
<br />
So the address is 00:19.0.<br />
Now check the PM status of the device by issuing<br />
<br />
# cat "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
substituting 00:19.0 with the address obtained from lspci.<br />
If the output reads "auto", you can try to bring the device out of suspend by<br />
<br />
# echo on > "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
Don't forget to substitute the address again.<br />
<br />
{{Note|1=This appears to be a bug in kernel 3.8.4.1- (3.8.8.1 is still affected): [https://bbs.archlinux.org/viewtopic.php?id=159837&p=2 Forum discussion.] It also appears a fix is [https://lkml.org/lkml/2013/1/18/147 on the way. (It will be likely fixed in 3.9.)] In the meantime, the above is a suitable workaround.}}<br />
<br />
=== Broadcom BCM57780 ===<br />
<br />
This Broadcom chipset sometimes does not behave well unless you specify the order of the modules to be loaded. The modules are {{ic|broadcom}} and {{ic|tg3}}, the former needing to be loaded first.<br />
<br />
These steps should help if your computer has this chipset:<br />
$ lspci | grep Ethernet<br />
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)<br />
<br />
If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following (as root):<br />
# modprobe -r tg3<br />
# modprobe broadcom<br />
# modprobe tg3<br />
<br />
Now plug you network cable in. If this solves your problems you can make this permanent by adding {{ic|broadcom}} and {{ic|tg3}} (in this order) to the {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}}:<br />
<br />
MODULES=".. broadcom tg3 .."<br />
<br />
Then rebuild the initramfs:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|These methods may work for other chipsets, such as BCM57760.}}</div>Binotahttps://wiki.archlinux.org/index.php?title=Network_configuration_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=293554Network configuration (正體中文)2014-01-19T10:10:29Z<p>Binota: /* 區域網路主機名稱解析 */</p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:Networking (正體中文)]]<br />
[[Category:Getting and installing Arch (正體中文)]]<br />
<br />
[[cs:Configuring Network]]<br />
[[el:Configuring Network]]<br />
[[es:Configuring Network]]<br />
[[fr:Connexions reseau]]<br />
[[it:Configuring Network]]<br />
[[ja:Network Configuration]]<br />
[[nl:Configuring Network]]<br />
[[pt:Configuring Network]]<br />
[[ro:Configurare retea]]<br />
[[ru:Configuring Network]]<br />
[[sk:Configuring Network]]<br />
[[tr:Ağ_Yapılandırması]]<br />
[[zh-CN:Network Configuration]]<br />
[[zh-TW:Network Configuration]]<br />
{{Related articles start}}<br />
{{Related|Jumbo Frames}}<br />
{{Related|Firewalls}}<br />
{{Related|Wireless Setup}}<br />
{{Related|List of Applications#Network Managers}}<br />
{{Related articles end}}<br />
{{TranslationStatus (正體中文)|Network_Configuration|2014-01-19|293523}}<br />
<br />
本頁將介紹如何設定 '''有線''' 網路連線。若您需要設定 '''無線''' 網路,請參考[[Wireless Setup|無線網路設定]]。<br />
<br />
== 檢查連線 ==<br />
<br />
{{註記|若您在執行 ping 時收到了類似 {{ic|ping: icmp open socket: Operation not permitted}} 這樣的錯誤訊息,請嘗試重新安裝 {{ic|iputils}} 軟體包。}} <br />
<br />
一般來說,基本的安裝過程都已經建立了可運作的網路設定。請執行下列指令以進行檢查:<br />
<br />
{{註記|{{ic|-c 3}} 選項表示將會呼叫三次。詳細請參閱 {{ic|man ping}} 。}}<br />
{{提示|您也可以嘗試使用其他的 Domain ,如 www.hinet.net 。}}<br />
<br />
{{hc|$ ping -c 3 www.google.com|<nowiki><br />
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.<br />
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms<br />
64 bytes from 74.125.224.146: icmp_req=2 ttl=50 time=385 ms<br />
64 bytes from 74.125.224.146: icmp_req=3 ttl=50 time=298 ms<br />
<br />
--- www.l.google.com ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 1999ms<br />
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms<br />
</nowiki>}}<br />
<br />
如果沒問題的話,您可能只是想以本文的下列部分來自定您的設定。<br />
<br />
若剛才的指令出現了 unknown hosts 之類的訊息,代表您的機器無法解析網域。這可能是因為您的網路服務提供商/閘道器造成的。您可以嘗試 ping 一個靜態 IP 以實驗您的機器可否存取網際網路。<br />
{{提示|您也可以嘗試使用其他的 IP ,如 168.95.1.1 。}}<br />
<br />
{{hc|$ ping -c 3 8.8.8.8|<nowiki><br />
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.<br />
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms<br />
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms<br />
64 bytes from 8.8.8.8: icmp_req=3 ttl=53 time=70.6 ms<br />
<br />
--- 8.8.8.8 ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 2002ms<br />
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms<br />
</nowiki>}}<br />
<br />
{{註記|{{ic|8.8.8.8}} 為一個好記的靜態 IP 位置。這是 Google 的主要 DNS 伺服器,這表示其有一定的可信度,並且通常不會被系統或代理伺服器擋下。}}<br />
<br />
若您可以 ping 通該位置,您可能需要試著在 {{ic|/etc/resolv.conf}} 檔案中加上網域名稱伺服器。<br />
<br />
== 設定主機名稱 ==<br />
<br />
[[Wikipedia:Hostname|主機名稱]]為網路中用於識別機器的唯一識別名稱:主機名稱可以通過 {{ic|/etc/hostname}} 檔案來進行設定。一般來說該檔案包含了系統的網域名稱。下面為設定主機名稱的方法:<br />
<br />
# hostnamectl set-hostname '''myhostname'''<br />
<br />
這樣會將 '''myhostname''' 寫入 {{ic|/etc/hostname}} 檔案中。<br />
<br />
詳細請參閱 {{ic|man 5 hostname}} 與 {{ic|man 1 hostnamectl}} 。<br />
<br />
{{註記|<br />
* {{ic|hostnamectl}} 支援 FQDN<br />
* 您不需要編輯 {{ic|/etc/hosts}} 檔案,{{pkg|systemd}} 會提供主機名稱解析且預設安裝於所有系統。<br />
}}<br />
<br />
使用來自 {{Pkg|inetutils}} 的 {{ic|hostname}} 指令以設定臨時主機名稱(直到重新啟動):<br />
<br />
# hostname ''myhostname''<br />
<br />
== 裝置驅動程式 ==<br />
<br />
=== 檢查驅動程式狀態 ===<br />
<br />
[[udev]] 應該會檢測您的網路介面卡([[Wikipedia:Network_interface_controller|NIC]])並自動於啟動時載入必要的模組。檢查 {{ic|lspci -v}} 輸出內容中的「Ethernet controller」 項目(或類似的)。這應該會告訴您哪些核心模組包含了網路設備的驅動程式。舉例來說:<br />
<br />
{{hc|$ lspci -v|<br />
02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)<br />
...<br />
Kernel driver in use: atl1<br />
Kernel modules: atl1<br />
}}<br />
<br />
接下來,確認該驅動程式已經通過 {{ic|dmesg <nowiki>|</nowiki> grep ''module_name''}} 載入了。舉例來說:<br />
<br />
$ dmesg | grep atl1<br />
...<br />
atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex<br />
<br />
若驅動程式已成功加載可以跳過接下來這段。否則,您會需要知道哪些模組時您的特定型號的裝置需要哪個模組。<br />
<br />
=== 載入裝置模組 ===<br />
<br />
以 Google 搜尋正確的晶片組模組/驅動程式。常見的驅動模組有 Realtek 晶片組網卡的 {{ic|8139too}} ,或是 SiS 晶片組網卡的 {{ic|sis900}}。當您知道要使用何種模組了之後,試著[[Kernel modules#Manual module handling|手動將其載入]]。若您的到了錯誤訊息告訴您找不到該模組,則該驅動可能未包含於 Arch 核心中。您可以在 [[AUR]] 中搜尋該模組名稱。<br />
<br />
若 udev 未在開機期間檢測與載入正確的模組,請參閱 [[Kernel modules#Loading]]。<br />
<br />
== 網路介面 ==<br />
<br />
=== 裝置名稱 ===<br />
<br />
對於多網路卡的電腦,固定裝置名稱非常重要。許多設定問題都是因為介面卡名稱的改動造成的。<br />
<br />
[[udev]] 負責命名裝置。Systemd v197 則有[http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames 可預測之網路介面名稱]並可自動支配靜態名稱給網路裝置。介面名稱以 {{ic|en}} (乙太網路)、 {{ic|wl}} (無線網路) 或是 {{ic|ww}} (WWAN)作為前置字串並附上一個自動產生的識別名稱,進而產生了類似 {{ic|enp0s25}} 這樣的名稱。 <br />
<br />
要禁用這種行為,可以加上一個連接:<br />
<br />
# ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules<br />
<br />
自早期版本升級 systemd 的使用者會有一自動建立的空規則檔案。因此,若您想使用一貫的裝置名稱,只需要刪除該檔案。<br />
<br />
{{提示|您可以執行 {{ic|ip link}} 或是 {{ic|ls /sys/class/net}} 以列出所有可用的介面。}}<br />
<br />
{{註記|當您更改了介面名稱規則後,別忘了更新所有跟網路有關的組態檔案與自定的 systemd unit 檔案以因應該更改。特別是當您啟用了 [[netctl#Basic method|netctl 靜態設定檔]] ,請執行 {{ic|netctl reenable ''profile''}} 以更新所有產生的服務檔案。}}<br />
<br />
==== 更改裝置名稱 ====<br />
<br />
您可以使用 udev-rule 來手動定義裝置名稱。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"<br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"<br />
</nowiki>}}<br />
<br />
請注意這兩點:<br />
<br />
* 使用這個指令以取得 MAC 位置:{{ic|cat /sys/class/net/''device_name''/address}}。<br />
* 請確定 udev 規則中使用的是小寫的十六進位數值而不是大寫。<br />
<br />
若您的網路卡為動態 MAC ,您可以使用 DEVPATH ,例如:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"<br />
</nowiki>}}<br />
<br />
{{註記|當使用了靜態的名稱時,'''應該要避免使用類似 "eth''X''" 與 "wlan''X''"''' 這樣的名稱,因為這可能會導致核心與 udev 在開機時發生衝突。而剛好相反地,最好使用核心預設不會使用的介面名稱,如 {{ic|net0}} 、 {{ic|net1}} 、 {{ic|wifi0}} 、 {{ic|wifi1}} 。詳細說明請參閱 [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames systemd] 文件。}}<br />
<br />
=== 設定裝置的 MTU 與佇列長度 ===<br />
<br />
您可以手動定義 udev 規則來更改裝置的 MTU 與佇列長度。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1480", ATTR{tx_queue_len}="2000"<br />
</nowiki>}}<br />
<br />
=== 取得目前的裝置名稱 ===<br />
<br />
目前的 NIC 名稱可以通過 sysfs 找到<br />
<br />
{{hc|$ ls /sys/class/net|<br />
lo eth0 eth1 firewire0<br />
}}<br />
<br />
=== 啟用與禁用網路介面 ===<br />
<br />
您可以使用下列指令來啟用或禁用網路介面:<br />
<br />
# ip link set eth0 up<br />
# ip link set eth0 down<br />
<br />
要確認結果,請執行:<br />
<br />
{{hc|$ ip link show dev eth0|<br />
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000<br />
...<br />
}}<br />
<br />
== 組態設定 IP 位址 ==<br />
<br />
您有兩個選擇:使用 [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]] 指派動態位址,或是使用「靜態」的位址。<br />
<br />
=== 動態 IP 位址 ===<br />
<br />
==== 手動執行 DHCP 用戶端 Daemon ====<br />
<br />
{{註記|請特別注意 {{ic|dhcpcd}} (DHCP ''Client'' Daemon,DHCP 用戶端 Daemon) 與 {{ic|dhcpd}} (DHCP ''(server)'' daemon,DHCP 伺服端 Daemon) 間的差異。}}<br />
<br />
{{hc|# dhcpcd eth0|<br />
dhcpcd: version 5.1.1 starting<br />
dhcpcd: eth0: broadcasting for a lease<br />
...<br />
dhcpcd: eth0: leased 192.168.1.70 for 86400 seconds<br />
}}<br />
<br />
緊接著, {{ic|ip addr show dev eth0}} 應該要顯示出您的 inet 位址。<br />
<br />
對部分的人而言,{{ic|dhcpcd}} 失敗時,可以使用 {{ic|dhclient}} (位於 {{Pkg|dhclient}} 軟體包中)<br />
<br />
==== 於啟動時執行 DHCP ====<br />
<br />
若您只是想使用 DHCP 來連線至您的乙太網路連線,您可以使用 {{ic|dhcpcd@.service}} (由 {{Pkg|dhcpcd}} 軟體包提供)。<br />
<br />
要啟動 {{ic|eth0}} 上的 DHCP ,只需要使用:<br />
<br />
# systemctl start dhcpcd@eth0.service<br />
<br />
您可以下列方法啟用該服務讓其於開機時自動啟動:<br />
<br />
# systemctl enable dhcpcd@eth0.service<br />
<br />
若您用了 DHCP 且您並 '''不想''' 讓您的 DNS 伺服器在每次啟動您的網路時自動指派,請將下列內容加到 {{ic|dhcpcd.conf}} 的最後一段中:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nohook resolv.conf<br />
}}<br />
<br />
另外,若您位於基於 MAC 位址的用戶端 IP 位址進行過濾的 DHCPv4 網路,您可能需要修改下列內容:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 Client ID as per RFC4361. <br />
duid<br />
}}<br />
<br />
為:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the hardware address of the interface for the Client ID (DHCPv4).<br />
clientid<br />
}}<br />
<br />
否則,您可能會因為 DHCP 伺服器無法正確讀取您的 [http://en.wikipedia.org/wiki/DHCPv6 DHCPv6-style] 用戶端 ID 而無法使用。詳細請參閱 [http://tools.ietf.org/html/rfc4361 RFC 4361] 。<br />
<br />
為防止 {{ic|dhcpcd}} 加入網域名稱伺服器至 {{ic|/etc/resolv.conf}} 中,請於其中使用 {{ic|nooption}} 選項:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nooption domain_name_servers<br />
}}<br />
<br />
接著加入您自己的 DNS 名稱伺服器至 {{ic|/etc/resolv.conf}} 中。<br />
<br />
若有多個不同的執行緒要控制 {{ic|/etc/resolv.conf}} (如 {{Pkg|dhcpcd}} 與 VPN 用戶端),您可能會想要使用 {{Pkg|openresolv}} 軟體包。使用 {{Pkg|openresolv}} 並不需要額外地設定 {{Pkg|dhcpcd}} 。<br />
<br />
==== DHCP 靜態路由 ====<br />
若您需要加入靜態路由用戶端,請於 {{ic|/usr/lib/dhcpcd/dhcpcd-hooks}} 中建立一個新的 dhcpcd hook-script 。下列範例展示了加入靜態路由至一個通過閘道器為 192.168.192.5 ,位於 10.11.12.0/24 的 VPN 子網路:<br />
{{hc|/usr/lib/dhcpcd/dhcpcd-hooks/40-vpnroute|<br />
ip route add 10.11.12.0/24 via 192.168.192.5<br />
}}<br />
前置字串''40''表示其於 dhcpcd 啟動時的最後執行 hook-script 。<br />
<br />
=== 靜態 IP 位址 ===<br />
<br />
您可能因為各種原因而希望在您的網路中指派靜態 IP 位址,例如靜態的位址可以獲得一定程度的可預測性,或是您沒有可用的 DHCP 伺服器。<br />
<br />
{{註記|若您共通過 Windows 機器共享您的網路而沒有路由器,請確保兩台電腦皆使用了靜態 IP 位址以避免區域網路問題。}}<br />
<br />
您需要:<br />
<br />
* 靜態 IP 位址<br />
* [[Wikipedia:Subnetwork|子網路遮罩]]<br />
* [[Wikipedia:Broadcast_address|廣播位址]]<br />
* [[Wikipedia:Default_gateway|預設閘道器]]的 IP 位址<br />
<br />
若您處在內部網路中,使用 192.168.*.* 這樣的 IP 位址較為安全,搭配其的子網路遮罩 255.255.255.0 ,廣播位址為 192.168.*.255 。而閘道器通常是 192.168.*.1 或是 192.168.*.254 。<br />
<br />
==== 手動指派 ====<br />
<br />
您可於控制台中指派一靜態 IP 位址:<br />
<br />
# ip addr add <IP 位址>/<子網路遮罩> broadcast <廣播> dev <介面><br />
<br />
舉例來說:<br />
<br />
# ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev eth0<br />
<br />
{{註記|子網路遮罩使用了 [[Wikipedia:CIDR_notation|CIDR 表示法]](CIDR,Classless Inter-Domain Routing,無類別網路間路由)。}}<br />
<br />
詳情請參閱 {{ic|man ip}} 。<br />
<br />
以類似下列方法加上您的閘道器:<br />
<br />
# ip route add default via <預設閘道器 IP 位址><br />
<br />
舉例來說:<br />
<br />
# ip route add default via 192.168.1.1<br />
<br />
若您得到了 "No such process" 這樣的錯誤訊息,這代表您必須以 root 執行 {{ic|ip link set dev eth0 up}} 。<br />
<br />
==== 於啟動時通過 systemd 手動連線 ====<br />
<br />
先確保 dhcpcd 已停止並禁用:<br />
<br />
# systemctl status dhcpcd.service<br />
<br />
接著為 [[systemd]] 服務建立一個檔案。以正確的網路介面名稱取代其中的 {{ic|<interface>}} :<br />
<br />
{{hc|/etc/conf.d/network@<interface>|<nowiki><br />
address=192.168.0.15<br />
netmask=24<br />
broadcast=192.168.0.255<br />
gateway=192.168.0.1<br />
</nowiki>}}<br />
<br />
建立 systemd unit 檔案:<br />
<br />
{{hc|/etc/systemd/system/network@.service|<nowiki><br />
[Unit]<br />
Description=Network connectivity (%i)<br />
Wants=network.target<br />
Before=network.target<br />
BindsTo=sys-subsystem-net-devices-%i.device<br />
After=sys-subsystem-net-devices-%i.device<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
EnvironmentFile=/etc/conf.d/network@%i<br />
<br />
ExecStart=/usr/bin/ip link set dev %i up<br />
ExecStart=/usr/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i<br />
ExecStart=/usr/bin/ip route add default via ${gateway}<br />
<br />
ExecStop=/usr/bin/ip addr flush dev %i<br />
ExecStop=/usr/bin/ip link set dev %i down<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
啟用該 unit 並將其啟動,傳入介面名稱,例如 eno1 :<br />
<br />
# systemctl enable network@eno1.service<br />
# systemctl start network@eno1.service<br />
<br />
若您需要手動設定 nameservers ,請編輯 {{ic|/etc/resolv.conf}} 檔案:<br />
<br />
{{hc|/etc/resolv.conf|<br />
nameserver 208.67.222.222<br />
nameserver 208.67.220.220}}<br />
<br />
若 {{ic|/etc/resolv.conf}} 被持續遭到複寫,請參考 [[Resolv.conf]] 以瞭解如何解決此問題。<br />
<br />
有幾個類似的方法來讓 systemd 啟動網路,其中的差異為檔案內容,並且其可以寫死 EnvironmentFile 定義的參考檔案中抓到的參數。因此可以作為一種替代的,將介面名稱放置於 /etc/conf.d/ 中的 EnvironmentFile 接著直接使用介面名稱而不是 %i 。如此一來,檔案名稱便不需要「@」。這也是一種有用的方法來閱讀 http://www.freedesktop.org/software/systemd/man/systemd.unit.html 上的 systemd 服務文件。<br />
<br />
==== 計算位址 ====<br />
<br />
您可以使用 {{Pkg|ipcalc}} 提供的 {{ic|ipcalc}} 來計算 IP 廣播、網域、子網路遮罩與主機範圍等進階設定舉例來說,我使用了位於防火牆後的乙太網路來連線 Windows 機器至 Arch。為了安全性與網路組織,我將他們放置於各自獨立的網路,接著組態設定子網路遮罩與廣播位址,如此一來網路中就只有兩台機器。為了找出子網路遮罩跟廣播位址,我使用了 ipcalc ,提供其 Arch firewire nic 的 IP 位址 10.66.66.1 ,並指定 ipcalc 要建立一個只有兩台主機的網路。<br />
<br />
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|<nowiki><br />
Address: 10.66.66.1<br />
<br />
Netmask: 255.255.255.252 = 30<br />
Network: 10.66.66.0/30<br />
HostMin: 10.66.66.1<br />
HostMax: 10.66.66.2<br />
Broadcast: 10.66.66.3<br />
Hosts/Net: 2 Class A, Private Internet<br />
</nowiki>}}<br />
<br />
== 載入組態設定 ==<br />
<br />
要測試您的設定,您可以重新啟動電腦或是重新載入相關的 systemd 服務:<br />
<br />
# systemctl restart dhcpcd@eth0<br />
<br />
您可以試著 ping 您的閘道器、 DNS 伺服器、 ISP 提供商或是其他網路上的站台。如此一來便可以確認您的網路連線問題為何,例如:<br />
<br />
$ ping -c 3 www.google.com<br />
<br />
== 附加設定 ==<br />
<br />
=== 筆記型電腦之 ifplugd ===<br />
<br />
{{Tip|{{Pkg|dhcpcd}} provides the same feature out of the box.}}<br />
<br />
{{Pkg|ifplugd}} in [[Official Repositories]] is a daemon which will automatically configure your Ethernet device when a cable is plugged in and automatically unconfigure it if the cable is pulled. This is useful on laptops with onboard network adapters, since it will only configure the interface when a cable is really connected. Another use is when you just need to restart the network but do not want to restart the computer or do it from the shell.<br />
<br />
By default it is configured to work for the {{ic|eth0}} device. This and other settings like delays can be configured in {{ic|/etc/ifplugd/ifplugd.conf}}.<br />
<br />
{{Note|[[Netctl]] package includes {{ic|netctl-ifplugd@.service}}, otherwise you can use {{ic|ifplugd@.service}} from {{Pkg|ifplugd}} package. Use for example {{ic|systemctl enable ifplugd@eth0.service}}.}}<br />
<br />
=== Bonding 或 LAG ===<br />
<br />
請參閱 [[netctl#Bonding]] 。<br />
<br />
=== IP 別名 ===<br />
<br />
{{Expansion|Manual method using [[Core Utilities#ip|ip]] should be added; then move current example using ''netctl'' into [[netctl]].}}<br />
<br />
IP 別名為讓同一個網路介面有多個 IP 位址。如此一來,單個節點的網路就能有多個網路連線,進而實現不同的作用。經典的使用方法為網頁與 FTP 伺服器的虛擬主機,或是重組伺服器而無需更新任何其他的機器(對於名稱伺服器來說特別有用)。<br />
<br />
==== 範例 ====<br />
<br />
您將需要來自[[Official Repositories|官方軟體套件庫]]的 {{Pkg|netctl}} 。<br />
<br />
準備組態設定檔:<br />
<br />
{{hc|/etc/netctl/mynetwork|<nowiki><br />
Connection='ethernet'<br />
Description='Five different addresses on the same NIC.'<br />
Interface='eth0'<br />
IP='static'<br />
Address=('192.168.1.10' '192.168.178.11' '192.168.1.12' '192.168.1.13' '192.168.1.14' '192.168.1.15')<br />
Gateway='192.168.1.1'<br />
DNS=('192.168.1.1')<br />
</nowiki>}}<br />
<br />
接著只需要將其執行:<br />
<br />
$ netctl start mynetwork<br />
<br />
=== 更改 MAC/硬體 位址 ===<br />
<br />
請參閱 [[MAC Address Spoofing]] 。<br />
<br />
=== Internet Sharing ===<br />
<br />
請參閱 [[Internet Sharing]] 。<br />
<br />
=== Router Configuration ===<br />
<br />
請參閱 [[Router]] 。<br />
<br />
=== 區域網路主機名稱解析 ===<br />
<br />
先決條件為[[#.E8.A8.AD.E5.AE.9A.E4.B8.BB.E6.A9.9F.E5.90.8D.E7.A8.B1|設定主機名稱]]之後,主機名稱可在本機系統上解析:<br />
{{hc|$ ping hostname|<br />
PING hostname <nowiki>(192.168.1.2) 56(84) bytes of data.<br />
64 bytes from hostname (192.168.1.2): icmp_seq=1 ttl=64 time=0.043 ms</nowiki>}}<br />
要以其他機器的名稱來解析主機,需要手動設定各自的 {{ic|/etc/hosts}} 檔案或是廣播/解析名稱的服務。<br />
<br />
過度設定 DNS 伺服器,如 [[BIND]] 、 [[Unbound]] ,手動編輯 {{ic|/etc/hosts}} 過於繁瑣,或是您希望對於動態地將主機離開、加入網路有更大的靈活性,您可以在您的區域網路中使用 Zero-configuration networking 來進行主機名稱解析。這裡有兩個可用選擇:<br />
<br />
*[[Samba]] 提供了通過微軟 '''NetBIOS''' 的主機名稱解析。其只需要安裝 {{Pkg|samba}} 並啟用 {{ic|nmbd.service}} 服務。執行 Windows 、OS X 或執行了 {{ic|nmbd}} 的 Linux ,將能夠找到您的機器。<br />
<br />
*[[Avahi]] 提供通過 '''zeroconf''' 的主機名稱解析,也稱作 Avahi 或 Boujour 。它比 Samba 還需要稍微複雜一點的設定:詳情請參考 [[Avahi#Hostname resolution]]。執行 OS X 或執行了 Avahi daemon 的 Linux ,將能夠找到您的機器。Windows 並無內建 Avahi 用戶端或 Daemon 。<br />
<br />
== 診斷 ==<br />
<br />
=== Swapping computers on the cable modem ===<br />
<br />
Some cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.<br />
<br />
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].<br />
<br />
=== The TCP window scaling problem ===<br />
<br />
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.<br />
<br />
Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html RFC 1323] was written to improve the situation: Window Scaling. The "window" value, provided in all packets, will be modified by a Scale Factor defined once, at the very beginning of the connection.<br />
<br />
That 8-bit Scale Factor allows the Window to be up to 32 times higher than the initial 64Kb.<br />
<br />
It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts.<br />
<br />
The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.<br />
<br />
The resulting connection is at best very slow or broken.<br />
<br />
==== How to diagnose the problem ====<br />
<br />
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).<br />
<br />
When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|ip addr}} will report normal status... and actually everything appears normal.<br />
<br />
If you cannot browse any website, but you can ping some random hosts, chances are great that you're experiencing this problem: ping uses ICMP and is not affected by TCP problems.<br />
<br />
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).<br />
<br />
==== How to fix it (The bad way) ====<br />
<br />
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.<br />
<br />
# echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem<br />
<br />
==== How to fix it (The good way) ====<br />
<br />
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.d/99-disable_window_scaling.conf}} (see also [[sysctl]])<br />
<br />
net.ipv4.tcp_window_scaling = 0<br />
<br />
==== How to fix it (The best way) ====<br />
<br />
This problem is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.<br />
<br />
==== More about it ====<br />
<br />
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].<br />
<br />
There are also several relevant threads on the LKML.<br />
<br />
=== Realtek no link / WOL problem ===<br />
<br />
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice a problem where the NIC seems to be disabled on boot and has no Link light. This can usually be found on a dual boot system where Windows is also installed. It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause. These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots. You will be able to notice if this problem is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off. Normal operation should be that the link light is always on as long as the system is on, even during POST. This problem will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this problem:<br />
<br />
==== Method 1 - Rollback/change Windows driver ====<br />
<br />
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).<br />
<br />
==== Method 2 - Enable WOL in Windows driver ====<br />
<br />
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems). In Windows, under Device Manager, find your Realtek network adapter and double-click it. Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.<br />
<br />
In Windows XP (example)<br />
Right click my computer<br />
--> Hardware tab<br />
--> Device Manager<br />
--> Network Adapters<br />
--> "double click" Realtek ...<br />
--> Advanced tab<br />
--> Wake-On-Lan After Shutdown<br />
--> Enable<br />
<br />
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{ic|Disable}} has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.}}<br />
<br />
==== Method 3 - Newer Realtek Linux driver ====<br />
<br />
Any newer driver for these Realtek cards can be found for Linux on the realtek site. (untested but believed to also solve the problem).<br />
<br />
==== Method 4 - Enable ''LAN Boot ROM'' in BIOS/CMOS ====<br />
<br />
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.<br />
<br />
{{Note|This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.}}<br />
<br />
=== DLink G604T/DLink G502T DNS problem ===<br />
<br />
Users with a DLink G604T/DLink G502T router, using DHCP and have firmware v2.00+ (typically users with AUS firmware) may have problems with certain programs not resolving the DNS. One of these programs are unfortunatley pacman. The problem is basically the router in certain situations is not sending the DNS properly to DHCP, which causes programs to try and connect to servers with an IP address of 1.0.0.0 and fail with a connection timed out error<br />
<br />
==== How to diagnose the problem ====<br />
<br />
The best way to diagnose the problem is to use Firefox/Konqueror/links/seamonkey and to enable wget for pacman. If this is a fresh install of Arch Linux, then you may want to consider installing {{ic|links}} through the live CD.<br />
<br />
Firstly, enable wget for pacman (since it gives us info about pacman when it is downloading packages)<br />
Open {{ic|/etc/pacman.conf}} with your favourite editor and uncomment the following line (remove the # if it is there)<br />
<br />
XferCommand=/usr/bin/wget --passive-ftp -c -O %o %u<br />
<br />
While you are editing {{ic|/etc/pacman.conf}}, check the default mirror that pacman uses to download packages.<br />
<br />
Now open up the default mirror in an Internet browser to see if the mirror actually works. If it does work, then do {{ic|pacman -Syy}} (otherwise pick another working mirror and set it to the pacman default). If you get something similar to the following (notice the 1.0.0.0),<br />
<br />
<nowiki>ftp://mirror.pacific.net.au/linux/archlinux/extra/os/i686/extra.db.tar.gz</nowiki><br />
=> '/var/lib/pacman/community.db.tar.gz.part'<br />
Resolving mirror.pacific.net.au... 1.0.0.0<br />
<br />
then you most likely have this problem. The 1.0.0.0 means it is unable to resolve DNS, so we must add it to {{ic|/etc/resolv.conf}}.<br />
<br />
==== How to fix it ====<br />
<br />
{{Out of date|{{Pkg|dhcpcd}} does not use {{ic|/etc/conf.d/dhcpcd}} any more.}}<br />
<br />
Basically what we need to do is to manually add the DNS servers to our {{ic|/etc/resolv.conf}} file. The problem is that DHCP automatically deletes and replaces this file on boot, so we need to edit {{ic|/etc/conf.d/dhcpcd}} and change the flags to stop DHCP from doing this.<br />
<br />
When you open {{ic|/etc/conf.d/dhcpcd}}, you should see something close to the following:<br />
<br />
DHCPCD_ARGS="-t 30 -h $HOSTNAME"<br />
<br />
Add the {{ic|-R}} flag to the arguments, e.g.,<br />
<br />
DHCPCD_ARGS="-R -t 30 -h $HOSTNAME"<br />
<br />
{{Note|1=If you are using {{Pkg|dhcpcd}} >= 4.0.2, the {{ic|-R}} flag has been deprecated. Please see the [[#Run DHCP at boot]] section for information on how to use a custom {{ic|/etc/resolv.conf}} file.}}<br />
<br />
Save and close the file; now open {{ic|/etc/resolv.conf}}. You should see a single nameserver (most likely 10.1.1.1). This is the gateway to your router, which we need to connect to in order to get the DNS servers of your ISP. Paste the IP address into your browser and log in to your router. Go to the DNS section, and you should see an IP address in the Primary DNS Server field; copy it and paste it as a nameserver '''ABOVE''' the current gateway one.<br />
<br />
For example, {{ic|/etc/resolv.conf}} should look something along the lines of:<br />
<br />
nameserver 10.1.1.1<br />
<br />
If my primary DNS server is 211.29.132.12, then change {{ic|/etc/resolv.conf}} to:<br />
<br />
nameserver 211.29.132.12<br />
nameserver 10.1.1.1<br />
<br />
Now restart the network daemon by running {{ic|systemctl restart dhcpcd@<interface>}} and do {{ic|pacman -Syy}}. If it syncs correctly with the server, then the problem is solved.<br />
<br />
==== More about it ====<br />
<br />
This is the whirlpool forum (Australian ISP community) which talks about and gives the same solution to the problem:<br />
<br />
http://forums.whirlpool.net.au/forum-replies-archive.cfm/461625.html<br />
<br />
=== Check DHCP problem by releasing IP first ===<br />
<br />
Problem may occur when DHCP get wrong IP assignment. For example when two routers are tied together through VPN. The router that is connected to me by VPN may assigning IP address. To fix it. On a console, as root, release IP address:<br />
<br />
# dhcpcd -k<br />
<br />
Then request a new one:<br />
<br />
# dhcpcd<br />
<br />
Maybe you had to run those two commands many times.<br />
<br />
=== No eth0 with Atheros AR8161 ===<br />
<br />
{{Note|With the 3.10.2-1-ARCH kernel update, the alx ethernet driver module is included in the package.}}<br />
<br />
With the Atheros AR8161 Gigabit Ethernet card, the ethernet connection is not working out-of-the-box (with the installation media of March 2013). The module "alx" needs to be loaded but is not present.<br />
<br />
The driver from [http://linuxwireless.org/en/users/Download/stable/#compat-wireless_stable_releases compat-wireless] (that has become [https://backports.wiki.kernel.org/index.php/Releases compat-drives] since linux 3.7) need to be installed. The "-u" postfix annotates that Qualcomm have applied a driver under a unified driver.<br />
<br />
$ wget https://www.kernel.org/pub/linux/kernel/projects/backports/2013/03/28/compat-drivers-2013-03-28-5-u.tar.bz2<br />
$ tar xjf compat*<br />
$ cd compat*<br />
$ ./scripts/driver-select alx<br />
$ make<br />
$ sudo make install<br />
$ sudo modprobe alx<br />
<br />
The alx driver has not been added to Linux kernel due to various problems. Compatibility between the different kernel versions has been spotty. For better support follow the [http://lists.infradead.org/mailman/listinfo/unified-drivers mailing list]and [http://www.linuxfoundation.org/collaborate/workgroups/networking/alx alx page]for latest working solution for alx.<br />
<br />
The driver must be built and installed after every kernel change.<br />
<br />
Alternatively you can use the AUR package for [https://aur.archlinux.org/packages/compat-drivers-patched/ compat drivers], which installs many other drivers.<br />
<br />
=== No eth0 with Atheros AR9485 ===<br />
<br />
The ethernet (eth0) for Atheros AR9485 are not working out-of-the-box (with installation media of March 2013). The working solution for this is to install the package [https://aur.archlinux.org/packages/compat-drivers-patched/ compat-drivers-patched] from AUR.<br />
<br />
=== No carrier / no connection after suspend ===<br />
After suspend to RAM no connection is found although the network cable is plugged in. <br />
This may be caused by PCI power management. What is the output of<br />
<br />
# ip link show eth0<br />
<br />
If the line contains "NO-CARRIER" even though there's a cable connected to your eth0 port, it is possible that the device was auto-suspended and the media sense feature doesn't work. To solve this, first you need to find your ethernet controllers PCI address by<br />
<br />
# lspci<br />
<br />
This should look similar to this:<br />
<br />
...<br />
00:19.0 Ethernet controller: Intel Corporation 82577LM Gigabit Network Connection (rev 06)<br />
...<br />
<br />
So the address is 00:19.0.<br />
Now check the PM status of the device by issuing<br />
<br />
# cat "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
substituting 00:19.0 with the address obtained from lspci.<br />
If the output reads "auto", you can try to bring the device out of suspend by<br />
<br />
# echo on > "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
Don't forget to substitute the address again.<br />
<br />
{{Note|1=This appears to be a bug in kernel 3.8.4.1- (3.8.8.1 is still affected): [https://bbs.archlinux.org/viewtopic.php?id=159837&p=2 Forum discussion.] It also appears a fix is [https://lkml.org/lkml/2013/1/18/147 on the way. (It will be likely fixed in 3.9.)] In the meantime, the above is a suitable workaround.}}<br />
<br />
=== Broadcom BCM57780 ===<br />
<br />
This Broadcom chipset sometimes does not behave well unless you specify the order of the modules to be loaded. The modules are {{ic|broadcom}} and {{ic|tg3}}, the former needing to be loaded first.<br />
<br />
These steps should help if your computer has this chipset:<br />
$ lspci | grep Ethernet<br />
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)<br />
<br />
If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following (as root):<br />
# modprobe -r tg3<br />
# modprobe broadcom<br />
# modprobe tg3<br />
<br />
Now plug you network cable in. If this solves your problems you can make this permanent by adding {{ic|broadcom}} and {{ic|tg3}} (in this order) to the {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}}:<br />
<br />
MODULES=".. broadcom tg3 .."<br />
<br />
Then rebuild the initramfs:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|These methods may work for other chipsets, such as BCM57760.}}</div>Binotahttps://wiki.archlinux.org/index.php?title=Network_configuration_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=293552Network configuration (正體中文)2014-01-19T10:10:10Z<p>Binota: /* 區域網路主機名稱解析 */</p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:Networking (正體中文)]]<br />
[[Category:Getting and installing Arch (正體中文)]]<br />
<br />
[[cs:Configuring Network]]<br />
[[el:Configuring Network]]<br />
[[es:Configuring Network]]<br />
[[fr:Connexions reseau]]<br />
[[it:Configuring Network]]<br />
[[ja:Network Configuration]]<br />
[[nl:Configuring Network]]<br />
[[pt:Configuring Network]]<br />
[[ro:Configurare retea]]<br />
[[ru:Configuring Network]]<br />
[[sk:Configuring Network]]<br />
[[tr:Ağ_Yapılandırması]]<br />
[[zh-CN:Network Configuration]]<br />
[[zh-TW:Network Configuration]]<br />
{{Related articles start}}<br />
{{Related|Jumbo Frames}}<br />
{{Related|Firewalls}}<br />
{{Related|Wireless Setup}}<br />
{{Related|List of Applications#Network Managers}}<br />
{{Related articles end}}<br />
{{TranslationStatus (正體中文)|Network_Configuration|2014-01-19|293523}}<br />
<br />
本頁將介紹如何設定 '''有線''' 網路連線。若您需要設定 '''無線''' 網路,請參考[[Wireless Setup|無線網路設定]]。<br />
<br />
== 檢查連線 ==<br />
<br />
{{註記|若您在執行 ping 時收到了類似 {{ic|ping: icmp open socket: Operation not permitted}} 這樣的錯誤訊息,請嘗試重新安裝 {{ic|iputils}} 軟體包。}} <br />
<br />
一般來說,基本的安裝過程都已經建立了可運作的網路設定。請執行下列指令以進行檢查:<br />
<br />
{{註記|{{ic|-c 3}} 選項表示將會呼叫三次。詳細請參閱 {{ic|man ping}} 。}}<br />
{{提示|您也可以嘗試使用其他的 Domain ,如 www.hinet.net 。}}<br />
<br />
{{hc|$ ping -c 3 www.google.com|<nowiki><br />
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.<br />
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms<br />
64 bytes from 74.125.224.146: icmp_req=2 ttl=50 time=385 ms<br />
64 bytes from 74.125.224.146: icmp_req=3 ttl=50 time=298 ms<br />
<br />
--- www.l.google.com ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 1999ms<br />
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms<br />
</nowiki>}}<br />
<br />
如果沒問題的話,您可能只是想以本文的下列部分來自定您的設定。<br />
<br />
若剛才的指令出現了 unknown hosts 之類的訊息,代表您的機器無法解析網域。這可能是因為您的網路服務提供商/閘道器造成的。您可以嘗試 ping 一個靜態 IP 以實驗您的機器可否存取網際網路。<br />
{{提示|您也可以嘗試使用其他的 IP ,如 168.95.1.1 。}}<br />
<br />
{{hc|$ ping -c 3 8.8.8.8|<nowiki><br />
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.<br />
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms<br />
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms<br />
64 bytes from 8.8.8.8: icmp_req=3 ttl=53 time=70.6 ms<br />
<br />
--- 8.8.8.8 ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 2002ms<br />
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms<br />
</nowiki>}}<br />
<br />
{{註記|{{ic|8.8.8.8}} 為一個好記的靜態 IP 位置。這是 Google 的主要 DNS 伺服器,這表示其有一定的可信度,並且通常不會被系統或代理伺服器擋下。}}<br />
<br />
若您可以 ping 通該位置,您可能需要試著在 {{ic|/etc/resolv.conf}} 檔案中加上網域名稱伺服器。<br />
<br />
== 設定主機名稱 ==<br />
<br />
[[Wikipedia:Hostname|主機名稱]]為網路中用於識別機器的唯一識別名稱:主機名稱可以通過 {{ic|/etc/hostname}} 檔案來進行設定。一般來說該檔案包含了系統的網域名稱。下面為設定主機名稱的方法:<br />
<br />
# hostnamectl set-hostname '''myhostname'''<br />
<br />
這樣會將 '''myhostname''' 寫入 {{ic|/etc/hostname}} 檔案中。<br />
<br />
詳細請參閱 {{ic|man 5 hostname}} 與 {{ic|man 1 hostnamectl}} 。<br />
<br />
{{註記|<br />
* {{ic|hostnamectl}} 支援 FQDN<br />
* 您不需要編輯 {{ic|/etc/hosts}} 檔案,{{pkg|systemd}} 會提供主機名稱解析且預設安裝於所有系統。<br />
}}<br />
<br />
使用來自 {{Pkg|inetutils}} 的 {{ic|hostname}} 指令以設定臨時主機名稱(直到重新啟動):<br />
<br />
# hostname ''myhostname''<br />
<br />
== 裝置驅動程式 ==<br />
<br />
=== 檢查驅動程式狀態 ===<br />
<br />
[[udev]] 應該會檢測您的網路介面卡([[Wikipedia:Network_interface_controller|NIC]])並自動於啟動時載入必要的模組。檢查 {{ic|lspci -v}} 輸出內容中的「Ethernet controller」 項目(或類似的)。這應該會告訴您哪些核心模組包含了網路設備的驅動程式。舉例來說:<br />
<br />
{{hc|$ lspci -v|<br />
02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)<br />
...<br />
Kernel driver in use: atl1<br />
Kernel modules: atl1<br />
}}<br />
<br />
接下來,確認該驅動程式已經通過 {{ic|dmesg <nowiki>|</nowiki> grep ''module_name''}} 載入了。舉例來說:<br />
<br />
$ dmesg | grep atl1<br />
...<br />
atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex<br />
<br />
若驅動程式已成功加載可以跳過接下來這段。否則,您會需要知道哪些模組時您的特定型號的裝置需要哪個模組。<br />
<br />
=== 載入裝置模組 ===<br />
<br />
以 Google 搜尋正確的晶片組模組/驅動程式。常見的驅動模組有 Realtek 晶片組網卡的 {{ic|8139too}} ,或是 SiS 晶片組網卡的 {{ic|sis900}}。當您知道要使用何種模組了之後,試著[[Kernel modules#Manual module handling|手動將其載入]]。若您的到了錯誤訊息告訴您找不到該模組,則該驅動可能未包含於 Arch 核心中。您可以在 [[AUR]] 中搜尋該模組名稱。<br />
<br />
若 udev 未在開機期間檢測與載入正確的模組,請參閱 [[Kernel modules#Loading]]。<br />
<br />
== 網路介面 ==<br />
<br />
=== 裝置名稱 ===<br />
<br />
對於多網路卡的電腦,固定裝置名稱非常重要。許多設定問題都是因為介面卡名稱的改動造成的。<br />
<br />
[[udev]] 負責命名裝置。Systemd v197 則有[http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames 可預測之網路介面名稱]並可自動支配靜態名稱給網路裝置。介面名稱以 {{ic|en}} (乙太網路)、 {{ic|wl}} (無線網路) 或是 {{ic|ww}} (WWAN)作為前置字串並附上一個自動產生的識別名稱,進而產生了類似 {{ic|enp0s25}} 這樣的名稱。 <br />
<br />
要禁用這種行為,可以加上一個連接:<br />
<br />
# ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules<br />
<br />
自早期版本升級 systemd 的使用者會有一自動建立的空規則檔案。因此,若您想使用一貫的裝置名稱,只需要刪除該檔案。<br />
<br />
{{提示|您可以執行 {{ic|ip link}} 或是 {{ic|ls /sys/class/net}} 以列出所有可用的介面。}}<br />
<br />
{{註記|當您更改了介面名稱規則後,別忘了更新所有跟網路有關的組態檔案與自定的 systemd unit 檔案以因應該更改。特別是當您啟用了 [[netctl#Basic method|netctl 靜態設定檔]] ,請執行 {{ic|netctl reenable ''profile''}} 以更新所有產生的服務檔案。}}<br />
<br />
==== 更改裝置名稱 ====<br />
<br />
您可以使用 udev-rule 來手動定義裝置名稱。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"<br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"<br />
</nowiki>}}<br />
<br />
請注意這兩點:<br />
<br />
* 使用這個指令以取得 MAC 位置:{{ic|cat /sys/class/net/''device_name''/address}}。<br />
* 請確定 udev 規則中使用的是小寫的十六進位數值而不是大寫。<br />
<br />
若您的網路卡為動態 MAC ,您可以使用 DEVPATH ,例如:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"<br />
</nowiki>}}<br />
<br />
{{註記|當使用了靜態的名稱時,'''應該要避免使用類似 "eth''X''" 與 "wlan''X''"''' 這樣的名稱,因為這可能會導致核心與 udev 在開機時發生衝突。而剛好相反地,最好使用核心預設不會使用的介面名稱,如 {{ic|net0}} 、 {{ic|net1}} 、 {{ic|wifi0}} 、 {{ic|wifi1}} 。詳細說明請參閱 [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames systemd] 文件。}}<br />
<br />
=== 設定裝置的 MTU 與佇列長度 ===<br />
<br />
您可以手動定義 udev 規則來更改裝置的 MTU 與佇列長度。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1480", ATTR{tx_queue_len}="2000"<br />
</nowiki>}}<br />
<br />
=== 取得目前的裝置名稱 ===<br />
<br />
目前的 NIC 名稱可以通過 sysfs 找到<br />
<br />
{{hc|$ ls /sys/class/net|<br />
lo eth0 eth1 firewire0<br />
}}<br />
<br />
=== 啟用與禁用網路介面 ===<br />
<br />
您可以使用下列指令來啟用或禁用網路介面:<br />
<br />
# ip link set eth0 up<br />
# ip link set eth0 down<br />
<br />
要確認結果,請執行:<br />
<br />
{{hc|$ ip link show dev eth0|<br />
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000<br />
...<br />
}}<br />
<br />
== 組態設定 IP 位址 ==<br />
<br />
您有兩個選擇:使用 [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]] 指派動態位址,或是使用「靜態」的位址。<br />
<br />
=== 動態 IP 位址 ===<br />
<br />
==== 手動執行 DHCP 用戶端 Daemon ====<br />
<br />
{{註記|請特別注意 {{ic|dhcpcd}} (DHCP ''Client'' Daemon,DHCP 用戶端 Daemon) 與 {{ic|dhcpd}} (DHCP ''(server)'' daemon,DHCP 伺服端 Daemon) 間的差異。}}<br />
<br />
{{hc|# dhcpcd eth0|<br />
dhcpcd: version 5.1.1 starting<br />
dhcpcd: eth0: broadcasting for a lease<br />
...<br />
dhcpcd: eth0: leased 192.168.1.70 for 86400 seconds<br />
}}<br />
<br />
緊接著, {{ic|ip addr show dev eth0}} 應該要顯示出您的 inet 位址。<br />
<br />
對部分的人而言,{{ic|dhcpcd}} 失敗時,可以使用 {{ic|dhclient}} (位於 {{Pkg|dhclient}} 軟體包中)<br />
<br />
==== 於啟動時執行 DHCP ====<br />
<br />
若您只是想使用 DHCP 來連線至您的乙太網路連線,您可以使用 {{ic|dhcpcd@.service}} (由 {{Pkg|dhcpcd}} 軟體包提供)。<br />
<br />
要啟動 {{ic|eth0}} 上的 DHCP ,只需要使用:<br />
<br />
# systemctl start dhcpcd@eth0.service<br />
<br />
您可以下列方法啟用該服務讓其於開機時自動啟動:<br />
<br />
# systemctl enable dhcpcd@eth0.service<br />
<br />
若您用了 DHCP 且您並 '''不想''' 讓您的 DNS 伺服器在每次啟動您的網路時自動指派,請將下列內容加到 {{ic|dhcpcd.conf}} 的最後一段中:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nohook resolv.conf<br />
}}<br />
<br />
另外,若您位於基於 MAC 位址的用戶端 IP 位址進行過濾的 DHCPv4 網路,您可能需要修改下列內容:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 Client ID as per RFC4361. <br />
duid<br />
}}<br />
<br />
為:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the hardware address of the interface for the Client ID (DHCPv4).<br />
clientid<br />
}}<br />
<br />
否則,您可能會因為 DHCP 伺服器無法正確讀取您的 [http://en.wikipedia.org/wiki/DHCPv6 DHCPv6-style] 用戶端 ID 而無法使用。詳細請參閱 [http://tools.ietf.org/html/rfc4361 RFC 4361] 。<br />
<br />
為防止 {{ic|dhcpcd}} 加入網域名稱伺服器至 {{ic|/etc/resolv.conf}} 中,請於其中使用 {{ic|nooption}} 選項:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nooption domain_name_servers<br />
}}<br />
<br />
接著加入您自己的 DNS 名稱伺服器至 {{ic|/etc/resolv.conf}} 中。<br />
<br />
若有多個不同的執行緒要控制 {{ic|/etc/resolv.conf}} (如 {{Pkg|dhcpcd}} 與 VPN 用戶端),您可能會想要使用 {{Pkg|openresolv}} 軟體包。使用 {{Pkg|openresolv}} 並不需要額外地設定 {{Pkg|dhcpcd}} 。<br />
<br />
==== DHCP 靜態路由 ====<br />
若您需要加入靜態路由用戶端,請於 {{ic|/usr/lib/dhcpcd/dhcpcd-hooks}} 中建立一個新的 dhcpcd hook-script 。下列範例展示了加入靜態路由至一個通過閘道器為 192.168.192.5 ,位於 10.11.12.0/24 的 VPN 子網路:<br />
{{hc|/usr/lib/dhcpcd/dhcpcd-hooks/40-vpnroute|<br />
ip route add 10.11.12.0/24 via 192.168.192.5<br />
}}<br />
前置字串''40''表示其於 dhcpcd 啟動時的最後執行 hook-script 。<br />
<br />
=== 靜態 IP 位址 ===<br />
<br />
您可能因為各種原因而希望在您的網路中指派靜態 IP 位址,例如靜態的位址可以獲得一定程度的可預測性,或是您沒有可用的 DHCP 伺服器。<br />
<br />
{{註記|若您共通過 Windows 機器共享您的網路而沒有路由器,請確保兩台電腦皆使用了靜態 IP 位址以避免區域網路問題。}}<br />
<br />
您需要:<br />
<br />
* 靜態 IP 位址<br />
* [[Wikipedia:Subnetwork|子網路遮罩]]<br />
* [[Wikipedia:Broadcast_address|廣播位址]]<br />
* [[Wikipedia:Default_gateway|預設閘道器]]的 IP 位址<br />
<br />
若您處在內部網路中,使用 192.168.*.* 這樣的 IP 位址較為安全,搭配其的子網路遮罩 255.255.255.0 ,廣播位址為 192.168.*.255 。而閘道器通常是 192.168.*.1 或是 192.168.*.254 。<br />
<br />
==== 手動指派 ====<br />
<br />
您可於控制台中指派一靜態 IP 位址:<br />
<br />
# ip addr add <IP 位址>/<子網路遮罩> broadcast <廣播> dev <介面><br />
<br />
舉例來說:<br />
<br />
# ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev eth0<br />
<br />
{{註記|子網路遮罩使用了 [[Wikipedia:CIDR_notation|CIDR 表示法]](CIDR,Classless Inter-Domain Routing,無類別網路間路由)。}}<br />
<br />
詳情請參閱 {{ic|man ip}} 。<br />
<br />
以類似下列方法加上您的閘道器:<br />
<br />
# ip route add default via <預設閘道器 IP 位址><br />
<br />
舉例來說:<br />
<br />
# ip route add default via 192.168.1.1<br />
<br />
若您得到了 "No such process" 這樣的錯誤訊息,這代表您必須以 root 執行 {{ic|ip link set dev eth0 up}} 。<br />
<br />
==== 於啟動時通過 systemd 手動連線 ====<br />
<br />
先確保 dhcpcd 已停止並禁用:<br />
<br />
# systemctl status dhcpcd.service<br />
<br />
接著為 [[systemd]] 服務建立一個檔案。以正確的網路介面名稱取代其中的 {{ic|<interface>}} :<br />
<br />
{{hc|/etc/conf.d/network@<interface>|<nowiki><br />
address=192.168.0.15<br />
netmask=24<br />
broadcast=192.168.0.255<br />
gateway=192.168.0.1<br />
</nowiki>}}<br />
<br />
建立 systemd unit 檔案:<br />
<br />
{{hc|/etc/systemd/system/network@.service|<nowiki><br />
[Unit]<br />
Description=Network connectivity (%i)<br />
Wants=network.target<br />
Before=network.target<br />
BindsTo=sys-subsystem-net-devices-%i.device<br />
After=sys-subsystem-net-devices-%i.device<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
EnvironmentFile=/etc/conf.d/network@%i<br />
<br />
ExecStart=/usr/bin/ip link set dev %i up<br />
ExecStart=/usr/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i<br />
ExecStart=/usr/bin/ip route add default via ${gateway}<br />
<br />
ExecStop=/usr/bin/ip addr flush dev %i<br />
ExecStop=/usr/bin/ip link set dev %i down<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
啟用該 unit 並將其啟動,傳入介面名稱,例如 eno1 :<br />
<br />
# systemctl enable network@eno1.service<br />
# systemctl start network@eno1.service<br />
<br />
若您需要手動設定 nameservers ,請編輯 {{ic|/etc/resolv.conf}} 檔案:<br />
<br />
{{hc|/etc/resolv.conf|<br />
nameserver 208.67.222.222<br />
nameserver 208.67.220.220}}<br />
<br />
若 {{ic|/etc/resolv.conf}} 被持續遭到複寫,請參考 [[Resolv.conf]] 以瞭解如何解決此問題。<br />
<br />
有幾個類似的方法來讓 systemd 啟動網路,其中的差異為檔案內容,並且其可以寫死 EnvironmentFile 定義的參考檔案中抓到的參數。因此可以作為一種替代的,將介面名稱放置於 /etc/conf.d/ 中的 EnvironmentFile 接著直接使用介面名稱而不是 %i 。如此一來,檔案名稱便不需要「@」。這也是一種有用的方法來閱讀 http://www.freedesktop.org/software/systemd/man/systemd.unit.html 上的 systemd 服務文件。<br />
<br />
==== 計算位址 ====<br />
<br />
您可以使用 {{Pkg|ipcalc}} 提供的 {{ic|ipcalc}} 來計算 IP 廣播、網域、子網路遮罩與主機範圍等進階設定舉例來說,我使用了位於防火牆後的乙太網路來連線 Windows 機器至 Arch。為了安全性與網路組織,我將他們放置於各自獨立的網路,接著組態設定子網路遮罩與廣播位址,如此一來網路中就只有兩台機器。為了找出子網路遮罩跟廣播位址,我使用了 ipcalc ,提供其 Arch firewire nic 的 IP 位址 10.66.66.1 ,並指定 ipcalc 要建立一個只有兩台主機的網路。<br />
<br />
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|<nowiki><br />
Address: 10.66.66.1<br />
<br />
Netmask: 255.255.255.252 = 30<br />
Network: 10.66.66.0/30<br />
HostMin: 10.66.66.1<br />
HostMax: 10.66.66.2<br />
Broadcast: 10.66.66.3<br />
Hosts/Net: 2 Class A, Private Internet<br />
</nowiki>}}<br />
<br />
== 載入組態設定 ==<br />
<br />
要測試您的設定,您可以重新啟動電腦或是重新載入相關的 systemd 服務:<br />
<br />
# systemctl restart dhcpcd@eth0<br />
<br />
您可以試著 ping 您的閘道器、 DNS 伺服器、 ISP 提供商或是其他網路上的站台。如此一來便可以確認您的網路連線問題為何,例如:<br />
<br />
$ ping -c 3 www.google.com<br />
<br />
== 附加設定 ==<br />
<br />
=== 筆記型電腦之 ifplugd ===<br />
<br />
{{Tip|{{Pkg|dhcpcd}} provides the same feature out of the box.}}<br />
<br />
{{Pkg|ifplugd}} in [[Official Repositories]] is a daemon which will automatically configure your Ethernet device when a cable is plugged in and automatically unconfigure it if the cable is pulled. This is useful on laptops with onboard network adapters, since it will only configure the interface when a cable is really connected. Another use is when you just need to restart the network but do not want to restart the computer or do it from the shell.<br />
<br />
By default it is configured to work for the {{ic|eth0}} device. This and other settings like delays can be configured in {{ic|/etc/ifplugd/ifplugd.conf}}.<br />
<br />
{{Note|[[Netctl]] package includes {{ic|netctl-ifplugd@.service}}, otherwise you can use {{ic|ifplugd@.service}} from {{Pkg|ifplugd}} package. Use for example {{ic|systemctl enable ifplugd@eth0.service}}.}}<br />
<br />
=== Bonding 或 LAG ===<br />
<br />
請參閱 [[netctl#Bonding]] 。<br />
<br />
=== IP 別名 ===<br />
<br />
{{Expansion|Manual method using [[Core Utilities#ip|ip]] should be added; then move current example using ''netctl'' into [[netctl]].}}<br />
<br />
IP 別名為讓同一個網路介面有多個 IP 位址。如此一來,單個節點的網路就能有多個網路連線,進而實現不同的作用。經典的使用方法為網頁與 FTP 伺服器的虛擬主機,或是重組伺服器而無需更新任何其他的機器(對於名稱伺服器來說特別有用)。<br />
<br />
==== 範例 ====<br />
<br />
您將需要來自[[Official Repositories|官方軟體套件庫]]的 {{Pkg|netctl}} 。<br />
<br />
準備組態設定檔:<br />
<br />
{{hc|/etc/netctl/mynetwork|<nowiki><br />
Connection='ethernet'<br />
Description='Five different addresses on the same NIC.'<br />
Interface='eth0'<br />
IP='static'<br />
Address=('192.168.1.10' '192.168.178.11' '192.168.1.12' '192.168.1.13' '192.168.1.14' '192.168.1.15')<br />
Gateway='192.168.1.1'<br />
DNS=('192.168.1.1')<br />
</nowiki>}}<br />
<br />
接著只需要將其執行:<br />
<br />
$ netctl start mynetwork<br />
<br />
=== 更改 MAC/硬體 位址 ===<br />
<br />
請參閱 [[MAC Address Spoofing]] 。<br />
<br />
=== Internet Sharing ===<br />
<br />
請參閱 [[Internet Sharing]] 。<br />
<br />
=== Router Configuration ===<br />
<br />
請參閱 [[Router]] 。<br />
<br />
=== 區域網路主機名稱解析 ===<br />
<br />
先決條件為[[#.E8.A8.AD.E5.AE.9A.E4.B8.BB.E6.A9.9F.E5.90.8D.E7.A8.B1|設定主機名稱]]之後,主機名稱可在本機系統上解析:<br />
{{hc|$ ping hostname|<br />
PING hostname <nowiki>(192.168.1.2) 56(84) bytes of data.<br />
64 bytes from hostname (192.168.1.2): icmp_seq=1 ttl=64 time=0.043 ms</nowiki>}}<br />
要以其他機器的名稱來解析主機,需要手動設定各自的 {{ic|/etc/hosts}} 檔案或是廣播/解析名稱的服務。<br />
<br />
過度設定 DNS 伺服器,如 [[BIND]] 、 [[Unbound]] ,手動編輯 {{ic|/etc/hosts}} 過於繁瑣,或是您希望對於動態地將主機離開、加入網路有更大的靈活性,您可以在您的區域網路中使用 Zero-configuration networking 來進行主機名稱解析。這裡有兩個可用選擇:<br />
<br />
*[[Samba]] 提供了通過微軟 '''NetBIOS''' 的主機名稱解析。其只需要安裝 {{Pkg|samba}} 並啟用 {{ic|nmbd.service}} 服務。執行 Windows 、OS X 或執行了 {{ic|nmbd}} 的 Linux ,將能夠找到您的機器。<br />
<br />
*[[Avahi]] 提供通過 '''zeroconf''' 的主機名稱解析,也稱作 Avahi 或 Boujour 。它比 Samba 還需要稍微複雜一點的設定:詳情請參考[Avahi#Hostname resolution]]。執行 OS X 或執行了 Avahi daemon 的 Linux ,將能夠找到您的機器。Windows 並無內建 Avahi 用戶端或 Daemon 。<br />
<br />
== 診斷 ==<br />
<br />
=== Swapping computers on the cable modem ===<br />
<br />
Some cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.<br />
<br />
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].<br />
<br />
=== The TCP window scaling problem ===<br />
<br />
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.<br />
<br />
Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html RFC 1323] was written to improve the situation: Window Scaling. The "window" value, provided in all packets, will be modified by a Scale Factor defined once, at the very beginning of the connection.<br />
<br />
That 8-bit Scale Factor allows the Window to be up to 32 times higher than the initial 64Kb.<br />
<br />
It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts.<br />
<br />
The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.<br />
<br />
The resulting connection is at best very slow or broken.<br />
<br />
==== How to diagnose the problem ====<br />
<br />
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).<br />
<br />
When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|ip addr}} will report normal status... and actually everything appears normal.<br />
<br />
If you cannot browse any website, but you can ping some random hosts, chances are great that you're experiencing this problem: ping uses ICMP and is not affected by TCP problems.<br />
<br />
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).<br />
<br />
==== How to fix it (The bad way) ====<br />
<br />
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.<br />
<br />
# echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem<br />
<br />
==== How to fix it (The good way) ====<br />
<br />
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.d/99-disable_window_scaling.conf}} (see also [[sysctl]])<br />
<br />
net.ipv4.tcp_window_scaling = 0<br />
<br />
==== How to fix it (The best way) ====<br />
<br />
This problem is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.<br />
<br />
==== More about it ====<br />
<br />
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].<br />
<br />
There are also several relevant threads on the LKML.<br />
<br />
=== Realtek no link / WOL problem ===<br />
<br />
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice a problem where the NIC seems to be disabled on boot and has no Link light. This can usually be found on a dual boot system where Windows is also installed. It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause. These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots. You will be able to notice if this problem is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off. Normal operation should be that the link light is always on as long as the system is on, even during POST. This problem will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this problem:<br />
<br />
==== Method 1 - Rollback/change Windows driver ====<br />
<br />
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).<br />
<br />
==== Method 2 - Enable WOL in Windows driver ====<br />
<br />
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems). In Windows, under Device Manager, find your Realtek network adapter and double-click it. Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.<br />
<br />
In Windows XP (example)<br />
Right click my computer<br />
--> Hardware tab<br />
--> Device Manager<br />
--> Network Adapters<br />
--> "double click" Realtek ...<br />
--> Advanced tab<br />
--> Wake-On-Lan After Shutdown<br />
--> Enable<br />
<br />
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{ic|Disable}} has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.}}<br />
<br />
==== Method 3 - Newer Realtek Linux driver ====<br />
<br />
Any newer driver for these Realtek cards can be found for Linux on the realtek site. (untested but believed to also solve the problem).<br />
<br />
==== Method 4 - Enable ''LAN Boot ROM'' in BIOS/CMOS ====<br />
<br />
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.<br />
<br />
{{Note|This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.}}<br />
<br />
=== DLink G604T/DLink G502T DNS problem ===<br />
<br />
Users with a DLink G604T/DLink G502T router, using DHCP and have firmware v2.00+ (typically users with AUS firmware) may have problems with certain programs not resolving the DNS. One of these programs are unfortunatley pacman. The problem is basically the router in certain situations is not sending the DNS properly to DHCP, which causes programs to try and connect to servers with an IP address of 1.0.0.0 and fail with a connection timed out error<br />
<br />
==== How to diagnose the problem ====<br />
<br />
The best way to diagnose the problem is to use Firefox/Konqueror/links/seamonkey and to enable wget for pacman. If this is a fresh install of Arch Linux, then you may want to consider installing {{ic|links}} through the live CD.<br />
<br />
Firstly, enable wget for pacman (since it gives us info about pacman when it is downloading packages)<br />
Open {{ic|/etc/pacman.conf}} with your favourite editor and uncomment the following line (remove the # if it is there)<br />
<br />
XferCommand=/usr/bin/wget --passive-ftp -c -O %o %u<br />
<br />
While you are editing {{ic|/etc/pacman.conf}}, check the default mirror that pacman uses to download packages.<br />
<br />
Now open up the default mirror in an Internet browser to see if the mirror actually works. If it does work, then do {{ic|pacman -Syy}} (otherwise pick another working mirror and set it to the pacman default). If you get something similar to the following (notice the 1.0.0.0),<br />
<br />
<nowiki>ftp://mirror.pacific.net.au/linux/archlinux/extra/os/i686/extra.db.tar.gz</nowiki><br />
=> '/var/lib/pacman/community.db.tar.gz.part'<br />
Resolving mirror.pacific.net.au... 1.0.0.0<br />
<br />
then you most likely have this problem. The 1.0.0.0 means it is unable to resolve DNS, so we must add it to {{ic|/etc/resolv.conf}}.<br />
<br />
==== How to fix it ====<br />
<br />
{{Out of date|{{Pkg|dhcpcd}} does not use {{ic|/etc/conf.d/dhcpcd}} any more.}}<br />
<br />
Basically what we need to do is to manually add the DNS servers to our {{ic|/etc/resolv.conf}} file. The problem is that DHCP automatically deletes and replaces this file on boot, so we need to edit {{ic|/etc/conf.d/dhcpcd}} and change the flags to stop DHCP from doing this.<br />
<br />
When you open {{ic|/etc/conf.d/dhcpcd}}, you should see something close to the following:<br />
<br />
DHCPCD_ARGS="-t 30 -h $HOSTNAME"<br />
<br />
Add the {{ic|-R}} flag to the arguments, e.g.,<br />
<br />
DHCPCD_ARGS="-R -t 30 -h $HOSTNAME"<br />
<br />
{{Note|1=If you are using {{Pkg|dhcpcd}} >= 4.0.2, the {{ic|-R}} flag has been deprecated. Please see the [[#Run DHCP at boot]] section for information on how to use a custom {{ic|/etc/resolv.conf}} file.}}<br />
<br />
Save and close the file; now open {{ic|/etc/resolv.conf}}. You should see a single nameserver (most likely 10.1.1.1). This is the gateway to your router, which we need to connect to in order to get the DNS servers of your ISP. Paste the IP address into your browser and log in to your router. Go to the DNS section, and you should see an IP address in the Primary DNS Server field; copy it and paste it as a nameserver '''ABOVE''' the current gateway one.<br />
<br />
For example, {{ic|/etc/resolv.conf}} should look something along the lines of:<br />
<br />
nameserver 10.1.1.1<br />
<br />
If my primary DNS server is 211.29.132.12, then change {{ic|/etc/resolv.conf}} to:<br />
<br />
nameserver 211.29.132.12<br />
nameserver 10.1.1.1<br />
<br />
Now restart the network daemon by running {{ic|systemctl restart dhcpcd@<interface>}} and do {{ic|pacman -Syy}}. If it syncs correctly with the server, then the problem is solved.<br />
<br />
==== More about it ====<br />
<br />
This is the whirlpool forum (Australian ISP community) which talks about and gives the same solution to the problem:<br />
<br />
http://forums.whirlpool.net.au/forum-replies-archive.cfm/461625.html<br />
<br />
=== Check DHCP problem by releasing IP first ===<br />
<br />
Problem may occur when DHCP get wrong IP assignment. For example when two routers are tied together through VPN. The router that is connected to me by VPN may assigning IP address. To fix it. On a console, as root, release IP address:<br />
<br />
# dhcpcd -k<br />
<br />
Then request a new one:<br />
<br />
# dhcpcd<br />
<br />
Maybe you had to run those two commands many times.<br />
<br />
=== No eth0 with Atheros AR8161 ===<br />
<br />
{{Note|With the 3.10.2-1-ARCH kernel update, the alx ethernet driver module is included in the package.}}<br />
<br />
With the Atheros AR8161 Gigabit Ethernet card, the ethernet connection is not working out-of-the-box (with the installation media of March 2013). The module "alx" needs to be loaded but is not present.<br />
<br />
The driver from [http://linuxwireless.org/en/users/Download/stable/#compat-wireless_stable_releases compat-wireless] (that has become [https://backports.wiki.kernel.org/index.php/Releases compat-drives] since linux 3.7) need to be installed. The "-u" postfix annotates that Qualcomm have applied a driver under a unified driver.<br />
<br />
$ wget https://www.kernel.org/pub/linux/kernel/projects/backports/2013/03/28/compat-drivers-2013-03-28-5-u.tar.bz2<br />
$ tar xjf compat*<br />
$ cd compat*<br />
$ ./scripts/driver-select alx<br />
$ make<br />
$ sudo make install<br />
$ sudo modprobe alx<br />
<br />
The alx driver has not been added to Linux kernel due to various problems. Compatibility between the different kernel versions has been spotty. For better support follow the [http://lists.infradead.org/mailman/listinfo/unified-drivers mailing list]and [http://www.linuxfoundation.org/collaborate/workgroups/networking/alx alx page]for latest working solution for alx.<br />
<br />
The driver must be built and installed after every kernel change.<br />
<br />
Alternatively you can use the AUR package for [https://aur.archlinux.org/packages/compat-drivers-patched/ compat drivers], which installs many other drivers.<br />
<br />
=== No eth0 with Atheros AR9485 ===<br />
<br />
The ethernet (eth0) for Atheros AR9485 are not working out-of-the-box (with installation media of March 2013). The working solution for this is to install the package [https://aur.archlinux.org/packages/compat-drivers-patched/ compat-drivers-patched] from AUR.<br />
<br />
=== No carrier / no connection after suspend ===<br />
After suspend to RAM no connection is found although the network cable is plugged in. <br />
This may be caused by PCI power management. What is the output of<br />
<br />
# ip link show eth0<br />
<br />
If the line contains "NO-CARRIER" even though there's a cable connected to your eth0 port, it is possible that the device was auto-suspended and the media sense feature doesn't work. To solve this, first you need to find your ethernet controllers PCI address by<br />
<br />
# lspci<br />
<br />
This should look similar to this:<br />
<br />
...<br />
00:19.0 Ethernet controller: Intel Corporation 82577LM Gigabit Network Connection (rev 06)<br />
...<br />
<br />
So the address is 00:19.0.<br />
Now check the PM status of the device by issuing<br />
<br />
# cat "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
substituting 00:19.0 with the address obtained from lspci.<br />
If the output reads "auto", you can try to bring the device out of suspend by<br />
<br />
# echo on > "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
Don't forget to substitute the address again.<br />
<br />
{{Note|1=This appears to be a bug in kernel 3.8.4.1- (3.8.8.1 is still affected): [https://bbs.archlinux.org/viewtopic.php?id=159837&p=2 Forum discussion.] It also appears a fix is [https://lkml.org/lkml/2013/1/18/147 on the way. (It will be likely fixed in 3.9.)] In the meantime, the above is a suitable workaround.}}<br />
<br />
=== Broadcom BCM57780 ===<br />
<br />
This Broadcom chipset sometimes does not behave well unless you specify the order of the modules to be loaded. The modules are {{ic|broadcom}} and {{ic|tg3}}, the former needing to be loaded first.<br />
<br />
These steps should help if your computer has this chipset:<br />
$ lspci | grep Ethernet<br />
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)<br />
<br />
If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following (as root):<br />
# modprobe -r tg3<br />
# modprobe broadcom<br />
# modprobe tg3<br />
<br />
Now plug you network cable in. If this solves your problems you can make this permanent by adding {{ic|broadcom}} and {{ic|tg3}} (in this order) to the {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}}:<br />
<br />
MODULES=".. broadcom tg3 .."<br />
<br />
Then rebuild the initramfs:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|These methods may work for other chipsets, such as BCM57760.}}</div>Binotahttps://wiki.archlinux.org/index.php?title=Network_configuration_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=293551Network configuration (正體中文)2014-01-19T10:09:48Z<p>Binota: /* 區域網路主機名稱解析 */ Translated</p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:Networking (正體中文)]]<br />
[[Category:Getting and installing Arch (正體中文)]]<br />
<br />
[[cs:Configuring Network]]<br />
[[el:Configuring Network]]<br />
[[es:Configuring Network]]<br />
[[fr:Connexions reseau]]<br />
[[it:Configuring Network]]<br />
[[ja:Network Configuration]]<br />
[[nl:Configuring Network]]<br />
[[pt:Configuring Network]]<br />
[[ro:Configurare retea]]<br />
[[ru:Configuring Network]]<br />
[[sk:Configuring Network]]<br />
[[tr:Ağ_Yapılandırması]]<br />
[[zh-CN:Network Configuration]]<br />
[[zh-TW:Network Configuration]]<br />
{{Related articles start}}<br />
{{Related|Jumbo Frames}}<br />
{{Related|Firewalls}}<br />
{{Related|Wireless Setup}}<br />
{{Related|List of Applications#Network Managers}}<br />
{{Related articles end}}<br />
{{TranslationStatus (正體中文)|Network_Configuration|2014-01-19|293523}}<br />
<br />
本頁將介紹如何設定 '''有線''' 網路連線。若您需要設定 '''無線''' 網路,請參考[[Wireless Setup|無線網路設定]]。<br />
<br />
== 檢查連線 ==<br />
<br />
{{註記|若您在執行 ping 時收到了類似 {{ic|ping: icmp open socket: Operation not permitted}} 這樣的錯誤訊息,請嘗試重新安裝 {{ic|iputils}} 軟體包。}} <br />
<br />
一般來說,基本的安裝過程都已經建立了可運作的網路設定。請執行下列指令以進行檢查:<br />
<br />
{{註記|{{ic|-c 3}} 選項表示將會呼叫三次。詳細請參閱 {{ic|man ping}} 。}}<br />
{{提示|您也可以嘗試使用其他的 Domain ,如 www.hinet.net 。}}<br />
<br />
{{hc|$ ping -c 3 www.google.com|<nowiki><br />
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.<br />
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms<br />
64 bytes from 74.125.224.146: icmp_req=2 ttl=50 time=385 ms<br />
64 bytes from 74.125.224.146: icmp_req=3 ttl=50 time=298 ms<br />
<br />
--- www.l.google.com ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 1999ms<br />
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms<br />
</nowiki>}}<br />
<br />
如果沒問題的話,您可能只是想以本文的下列部分來自定您的設定。<br />
<br />
若剛才的指令出現了 unknown hosts 之類的訊息,代表您的機器無法解析網域。這可能是因為您的網路服務提供商/閘道器造成的。您可以嘗試 ping 一個靜態 IP 以實驗您的機器可否存取網際網路。<br />
{{提示|您也可以嘗試使用其他的 IP ,如 168.95.1.1 。}}<br />
<br />
{{hc|$ ping -c 3 8.8.8.8|<nowiki><br />
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.<br />
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms<br />
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms<br />
64 bytes from 8.8.8.8: icmp_req=3 ttl=53 time=70.6 ms<br />
<br />
--- 8.8.8.8 ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 2002ms<br />
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms<br />
</nowiki>}}<br />
<br />
{{註記|{{ic|8.8.8.8}} 為一個好記的靜態 IP 位置。這是 Google 的主要 DNS 伺服器,這表示其有一定的可信度,並且通常不會被系統或代理伺服器擋下。}}<br />
<br />
若您可以 ping 通該位置,您可能需要試著在 {{ic|/etc/resolv.conf}} 檔案中加上網域名稱伺服器。<br />
<br />
== 設定主機名稱 ==<br />
<br />
[[Wikipedia:Hostname|主機名稱]]為網路中用於識別機器的唯一識別名稱:主機名稱可以通過 {{ic|/etc/hostname}} 檔案來進行設定。一般來說該檔案包含了系統的網域名稱。下面為設定主機名稱的方法:<br />
<br />
# hostnamectl set-hostname '''myhostname'''<br />
<br />
這樣會將 '''myhostname''' 寫入 {{ic|/etc/hostname}} 檔案中。<br />
<br />
詳細請參閱 {{ic|man 5 hostname}} 與 {{ic|man 1 hostnamectl}} 。<br />
<br />
{{註記|<br />
* {{ic|hostnamectl}} 支援 FQDN<br />
* 您不需要編輯 {{ic|/etc/hosts}} 檔案,{{pkg|systemd}} 會提供主機名稱解析且預設安裝於所有系統。<br />
}}<br />
<br />
使用來自 {{Pkg|inetutils}} 的 {{ic|hostname}} 指令以設定臨時主機名稱(直到重新啟動):<br />
<br />
# hostname ''myhostname''<br />
<br />
== 裝置驅動程式 ==<br />
<br />
=== 檢查驅動程式狀態 ===<br />
<br />
[[udev]] 應該會檢測您的網路介面卡([[Wikipedia:Network_interface_controller|NIC]])並自動於啟動時載入必要的模組。檢查 {{ic|lspci -v}} 輸出內容中的「Ethernet controller」 項目(或類似的)。這應該會告訴您哪些核心模組包含了網路設備的驅動程式。舉例來說:<br />
<br />
{{hc|$ lspci -v|<br />
02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)<br />
...<br />
Kernel driver in use: atl1<br />
Kernel modules: atl1<br />
}}<br />
<br />
接下來,確認該驅動程式已經通過 {{ic|dmesg <nowiki>|</nowiki> grep ''module_name''}} 載入了。舉例來說:<br />
<br />
$ dmesg | grep atl1<br />
...<br />
atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex<br />
<br />
若驅動程式已成功加載可以跳過接下來這段。否則,您會需要知道哪些模組時您的特定型號的裝置需要哪個模組。<br />
<br />
=== 載入裝置模組 ===<br />
<br />
以 Google 搜尋正確的晶片組模組/驅動程式。常見的驅動模組有 Realtek 晶片組網卡的 {{ic|8139too}} ,或是 SiS 晶片組網卡的 {{ic|sis900}}。當您知道要使用何種模組了之後,試著[[Kernel modules#Manual module handling|手動將其載入]]。若您的到了錯誤訊息告訴您找不到該模組,則該驅動可能未包含於 Arch 核心中。您可以在 [[AUR]] 中搜尋該模組名稱。<br />
<br />
若 udev 未在開機期間檢測與載入正確的模組,請參閱 [[Kernel modules#Loading]]。<br />
<br />
== 網路介面 ==<br />
<br />
=== 裝置名稱 ===<br />
<br />
對於多網路卡的電腦,固定裝置名稱非常重要。許多設定問題都是因為介面卡名稱的改動造成的。<br />
<br />
[[udev]] 負責命名裝置。Systemd v197 則有[http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames 可預測之網路介面名稱]並可自動支配靜態名稱給網路裝置。介面名稱以 {{ic|en}} (乙太網路)、 {{ic|wl}} (無線網路) 或是 {{ic|ww}} (WWAN)作為前置字串並附上一個自動產生的識別名稱,進而產生了類似 {{ic|enp0s25}} 這樣的名稱。 <br />
<br />
要禁用這種行為,可以加上一個連接:<br />
<br />
# ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules<br />
<br />
自早期版本升級 systemd 的使用者會有一自動建立的空規則檔案。因此,若您想使用一貫的裝置名稱,只需要刪除該檔案。<br />
<br />
{{提示|您可以執行 {{ic|ip link}} 或是 {{ic|ls /sys/class/net}} 以列出所有可用的介面。}}<br />
<br />
{{註記|當您更改了介面名稱規則後,別忘了更新所有跟網路有關的組態檔案與自定的 systemd unit 檔案以因應該更改。特別是當您啟用了 [[netctl#Basic method|netctl 靜態設定檔]] ,請執行 {{ic|netctl reenable ''profile''}} 以更新所有產生的服務檔案。}}<br />
<br />
==== 更改裝置名稱 ====<br />
<br />
您可以使用 udev-rule 來手動定義裝置名稱。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"<br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"<br />
</nowiki>}}<br />
<br />
請注意這兩點:<br />
<br />
* 使用這個指令以取得 MAC 位置:{{ic|cat /sys/class/net/''device_name''/address}}。<br />
* 請確定 udev 規則中使用的是小寫的十六進位數值而不是大寫。<br />
<br />
若您的網路卡為動態 MAC ,您可以使用 DEVPATH ,例如:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"<br />
</nowiki>}}<br />
<br />
{{註記|當使用了靜態的名稱時,'''應該要避免使用類似 "eth''X''" 與 "wlan''X''"''' 這樣的名稱,因為這可能會導致核心與 udev 在開機時發生衝突。而剛好相反地,最好使用核心預設不會使用的介面名稱,如 {{ic|net0}} 、 {{ic|net1}} 、 {{ic|wifi0}} 、 {{ic|wifi1}} 。詳細說明請參閱 [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames systemd] 文件。}}<br />
<br />
=== 設定裝置的 MTU 與佇列長度 ===<br />
<br />
您可以手動定義 udev 規則來更改裝置的 MTU 與佇列長度。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1480", ATTR{tx_queue_len}="2000"<br />
</nowiki>}}<br />
<br />
=== 取得目前的裝置名稱 ===<br />
<br />
目前的 NIC 名稱可以通過 sysfs 找到<br />
<br />
{{hc|$ ls /sys/class/net|<br />
lo eth0 eth1 firewire0<br />
}}<br />
<br />
=== 啟用與禁用網路介面 ===<br />
<br />
您可以使用下列指令來啟用或禁用網路介面:<br />
<br />
# ip link set eth0 up<br />
# ip link set eth0 down<br />
<br />
要確認結果,請執行:<br />
<br />
{{hc|$ ip link show dev eth0|<br />
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000<br />
...<br />
}}<br />
<br />
== 組態設定 IP 位址 ==<br />
<br />
您有兩個選擇:使用 [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]] 指派動態位址,或是使用「靜態」的位址。<br />
<br />
=== 動態 IP 位址 ===<br />
<br />
==== 手動執行 DHCP 用戶端 Daemon ====<br />
<br />
{{註記|請特別注意 {{ic|dhcpcd}} (DHCP ''Client'' Daemon,DHCP 用戶端 Daemon) 與 {{ic|dhcpd}} (DHCP ''(server)'' daemon,DHCP 伺服端 Daemon) 間的差異。}}<br />
<br />
{{hc|# dhcpcd eth0|<br />
dhcpcd: version 5.1.1 starting<br />
dhcpcd: eth0: broadcasting for a lease<br />
...<br />
dhcpcd: eth0: leased 192.168.1.70 for 86400 seconds<br />
}}<br />
<br />
緊接著, {{ic|ip addr show dev eth0}} 應該要顯示出您的 inet 位址。<br />
<br />
對部分的人而言,{{ic|dhcpcd}} 失敗時,可以使用 {{ic|dhclient}} (位於 {{Pkg|dhclient}} 軟體包中)<br />
<br />
==== 於啟動時執行 DHCP ====<br />
<br />
若您只是想使用 DHCP 來連線至您的乙太網路連線,您可以使用 {{ic|dhcpcd@.service}} (由 {{Pkg|dhcpcd}} 軟體包提供)。<br />
<br />
要啟動 {{ic|eth0}} 上的 DHCP ,只需要使用:<br />
<br />
# systemctl start dhcpcd@eth0.service<br />
<br />
您可以下列方法啟用該服務讓其於開機時自動啟動:<br />
<br />
# systemctl enable dhcpcd@eth0.service<br />
<br />
若您用了 DHCP 且您並 '''不想''' 讓您的 DNS 伺服器在每次啟動您的網路時自動指派,請將下列內容加到 {{ic|dhcpcd.conf}} 的最後一段中:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nohook resolv.conf<br />
}}<br />
<br />
另外,若您位於基於 MAC 位址的用戶端 IP 位址進行過濾的 DHCPv4 網路,您可能需要修改下列內容:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 Client ID as per RFC4361. <br />
duid<br />
}}<br />
<br />
為:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the hardware address of the interface for the Client ID (DHCPv4).<br />
clientid<br />
}}<br />
<br />
否則,您可能會因為 DHCP 伺服器無法正確讀取您的 [http://en.wikipedia.org/wiki/DHCPv6 DHCPv6-style] 用戶端 ID 而無法使用。詳細請參閱 [http://tools.ietf.org/html/rfc4361 RFC 4361] 。<br />
<br />
為防止 {{ic|dhcpcd}} 加入網域名稱伺服器至 {{ic|/etc/resolv.conf}} 中,請於其中使用 {{ic|nooption}} 選項:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nooption domain_name_servers<br />
}}<br />
<br />
接著加入您自己的 DNS 名稱伺服器至 {{ic|/etc/resolv.conf}} 中。<br />
<br />
若有多個不同的執行緒要控制 {{ic|/etc/resolv.conf}} (如 {{Pkg|dhcpcd}} 與 VPN 用戶端),您可能會想要使用 {{Pkg|openresolv}} 軟體包。使用 {{Pkg|openresolv}} 並不需要額外地設定 {{Pkg|dhcpcd}} 。<br />
<br />
==== DHCP 靜態路由 ====<br />
若您需要加入靜態路由用戶端,請於 {{ic|/usr/lib/dhcpcd/dhcpcd-hooks}} 中建立一個新的 dhcpcd hook-script 。下列範例展示了加入靜態路由至一個通過閘道器為 192.168.192.5 ,位於 10.11.12.0/24 的 VPN 子網路:<br />
{{hc|/usr/lib/dhcpcd/dhcpcd-hooks/40-vpnroute|<br />
ip route add 10.11.12.0/24 via 192.168.192.5<br />
}}<br />
前置字串''40''表示其於 dhcpcd 啟動時的最後執行 hook-script 。<br />
<br />
=== 靜態 IP 位址 ===<br />
<br />
您可能因為各種原因而希望在您的網路中指派靜態 IP 位址,例如靜態的位址可以獲得一定程度的可預測性,或是您沒有可用的 DHCP 伺服器。<br />
<br />
{{註記|若您共通過 Windows 機器共享您的網路而沒有路由器,請確保兩台電腦皆使用了靜態 IP 位址以避免區域網路問題。}}<br />
<br />
您需要:<br />
<br />
* 靜態 IP 位址<br />
* [[Wikipedia:Subnetwork|子網路遮罩]]<br />
* [[Wikipedia:Broadcast_address|廣播位址]]<br />
* [[Wikipedia:Default_gateway|預設閘道器]]的 IP 位址<br />
<br />
若您處在內部網路中,使用 192.168.*.* 這樣的 IP 位址較為安全,搭配其的子網路遮罩 255.255.255.0 ,廣播位址為 192.168.*.255 。而閘道器通常是 192.168.*.1 或是 192.168.*.254 。<br />
<br />
==== 手動指派 ====<br />
<br />
您可於控制台中指派一靜態 IP 位址:<br />
<br />
# ip addr add <IP 位址>/<子網路遮罩> broadcast <廣播> dev <介面><br />
<br />
舉例來說:<br />
<br />
# ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev eth0<br />
<br />
{{註記|子網路遮罩使用了 [[Wikipedia:CIDR_notation|CIDR 表示法]](CIDR,Classless Inter-Domain Routing,無類別網路間路由)。}}<br />
<br />
詳情請參閱 {{ic|man ip}} 。<br />
<br />
以類似下列方法加上您的閘道器:<br />
<br />
# ip route add default via <預設閘道器 IP 位址><br />
<br />
舉例來說:<br />
<br />
# ip route add default via 192.168.1.1<br />
<br />
若您得到了 "No such process" 這樣的錯誤訊息,這代表您必須以 root 執行 {{ic|ip link set dev eth0 up}} 。<br />
<br />
==== 於啟動時通過 systemd 手動連線 ====<br />
<br />
先確保 dhcpcd 已停止並禁用:<br />
<br />
# systemctl status dhcpcd.service<br />
<br />
接著為 [[systemd]] 服務建立一個檔案。以正確的網路介面名稱取代其中的 {{ic|<interface>}} :<br />
<br />
{{hc|/etc/conf.d/network@<interface>|<nowiki><br />
address=192.168.0.15<br />
netmask=24<br />
broadcast=192.168.0.255<br />
gateway=192.168.0.1<br />
</nowiki>}}<br />
<br />
建立 systemd unit 檔案:<br />
<br />
{{hc|/etc/systemd/system/network@.service|<nowiki><br />
[Unit]<br />
Description=Network connectivity (%i)<br />
Wants=network.target<br />
Before=network.target<br />
BindsTo=sys-subsystem-net-devices-%i.device<br />
After=sys-subsystem-net-devices-%i.device<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
EnvironmentFile=/etc/conf.d/network@%i<br />
<br />
ExecStart=/usr/bin/ip link set dev %i up<br />
ExecStart=/usr/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i<br />
ExecStart=/usr/bin/ip route add default via ${gateway}<br />
<br />
ExecStop=/usr/bin/ip addr flush dev %i<br />
ExecStop=/usr/bin/ip link set dev %i down<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
啟用該 unit 並將其啟動,傳入介面名稱,例如 eno1 :<br />
<br />
# systemctl enable network@eno1.service<br />
# systemctl start network@eno1.service<br />
<br />
若您需要手動設定 nameservers ,請編輯 {{ic|/etc/resolv.conf}} 檔案:<br />
<br />
{{hc|/etc/resolv.conf|<br />
nameserver 208.67.222.222<br />
nameserver 208.67.220.220}}<br />
<br />
若 {{ic|/etc/resolv.conf}} 被持續遭到複寫,請參考 [[Resolv.conf]] 以瞭解如何解決此問題。<br />
<br />
有幾個類似的方法來讓 systemd 啟動網路,其中的差異為檔案內容,並且其可以寫死 EnvironmentFile 定義的參考檔案中抓到的參數。因此可以作為一種替代的,將介面名稱放置於 /etc/conf.d/ 中的 EnvironmentFile 接著直接使用介面名稱而不是 %i 。如此一來,檔案名稱便不需要「@」。這也是一種有用的方法來閱讀 http://www.freedesktop.org/software/systemd/man/systemd.unit.html 上的 systemd 服務文件。<br />
<br />
==== 計算位址 ====<br />
<br />
您可以使用 {{Pkg|ipcalc}} 提供的 {{ic|ipcalc}} 來計算 IP 廣播、網域、子網路遮罩與主機範圍等進階設定舉例來說,我使用了位於防火牆後的乙太網路來連線 Windows 機器至 Arch。為了安全性與網路組織,我將他們放置於各自獨立的網路,接著組態設定子網路遮罩與廣播位址,如此一來網路中就只有兩台機器。為了找出子網路遮罩跟廣播位址,我使用了 ipcalc ,提供其 Arch firewire nic 的 IP 位址 10.66.66.1 ,並指定 ipcalc 要建立一個只有兩台主機的網路。<br />
<br />
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|<nowiki><br />
Address: 10.66.66.1<br />
<br />
Netmask: 255.255.255.252 = 30<br />
Network: 10.66.66.0/30<br />
HostMin: 10.66.66.1<br />
HostMax: 10.66.66.2<br />
Broadcast: 10.66.66.3<br />
Hosts/Net: 2 Class A, Private Internet<br />
</nowiki>}}<br />
<br />
== 載入組態設定 ==<br />
<br />
要測試您的設定,您可以重新啟動電腦或是重新載入相關的 systemd 服務:<br />
<br />
# systemctl restart dhcpcd@eth0<br />
<br />
您可以試著 ping 您的閘道器、 DNS 伺服器、 ISP 提供商或是其他網路上的站台。如此一來便可以確認您的網路連線問題為何,例如:<br />
<br />
$ ping -c 3 www.google.com<br />
<br />
== 附加設定 ==<br />
<br />
=== 筆記型電腦之 ifplugd ===<br />
<br />
{{Tip|{{Pkg|dhcpcd}} provides the same feature out of the box.}}<br />
<br />
{{Pkg|ifplugd}} in [[Official Repositories]] is a daemon which will automatically configure your Ethernet device when a cable is plugged in and automatically unconfigure it if the cable is pulled. This is useful on laptops with onboard network adapters, since it will only configure the interface when a cable is really connected. Another use is when you just need to restart the network but do not want to restart the computer or do it from the shell.<br />
<br />
By default it is configured to work for the {{ic|eth0}} device. This and other settings like delays can be configured in {{ic|/etc/ifplugd/ifplugd.conf}}.<br />
<br />
{{Note|[[Netctl]] package includes {{ic|netctl-ifplugd@.service}}, otherwise you can use {{ic|ifplugd@.service}} from {{Pkg|ifplugd}} package. Use for example {{ic|systemctl enable ifplugd@eth0.service}}.}}<br />
<br />
=== Bonding 或 LAG ===<br />
<br />
請參閱 [[netctl#Bonding]] 。<br />
<br />
=== IP 別名 ===<br />
<br />
{{Expansion|Manual method using [[Core Utilities#ip|ip]] should be added; then move current example using ''netctl'' into [[netctl]].}}<br />
<br />
IP 別名為讓同一個網路介面有多個 IP 位址。如此一來,單個節點的網路就能有多個網路連線,進而實現不同的作用。經典的使用方法為網頁與 FTP 伺服器的虛擬主機,或是重組伺服器而無需更新任何其他的機器(對於名稱伺服器來說特別有用)。<br />
<br />
==== 範例 ====<br />
<br />
您將需要來自[[Official Repositories|官方軟體套件庫]]的 {{Pkg|netctl}} 。<br />
<br />
準備組態設定檔:<br />
<br />
{{hc|/etc/netctl/mynetwork|<nowiki><br />
Connection='ethernet'<br />
Description='Five different addresses on the same NIC.'<br />
Interface='eth0'<br />
IP='static'<br />
Address=('192.168.1.10' '192.168.178.11' '192.168.1.12' '192.168.1.13' '192.168.1.14' '192.168.1.15')<br />
Gateway='192.168.1.1'<br />
DNS=('192.168.1.1')<br />
</nowiki>}}<br />
<br />
接著只需要將其執行:<br />
<br />
$ netctl start mynetwork<br />
<br />
=== 更改 MAC/硬體 位址 ===<br />
<br />
請參閱 [[MAC Address Spoofing]] 。<br />
<br />
=== Internet Sharing ===<br />
<br />
請參閱 [[Internet Sharing]] 。<br />
<br />
=== Router Configuration ===<br />
<br />
請參閱 [[Router]] 。<br />
<br />
=== 區域網路主機名稱解析 ===<br />
<br />
先決條件為[[#.E8.A8.AD.E5.AE.9A.E4.B8.BB.E6.A9.9F.E5.90.8D.E7.A8.B1|設定主機名稱]]之後,主機名稱可在本機系統上解析:<br />
{{hc|$ ping hostname|<br />
PING hostname <nowiki>(192.168.1.2) 56(84) bytes of data.<br />
64 bytes from hostname (192.168.1.2): icmp_seq=1 ttl=64 time=0.043 ms</nowiki>}}<br />
要以其他機器的名稱來解析主機,需要手動設定各自的 {{ic|/etc/hosts}} 檔案或是廣播/解析名稱的服務。<br />
<br />
過度設定 DNS 伺服器,如 [[BIND]] 、 [[Unbound]] ,手動編輯 {{ic|/etc/hosts}} 過於繁瑣,或是您希望對於動態地將主機離開、加入網路有更大的靈活性,您可以在您的區域網路中使用 Zero-configuration networking 來進行主機名稱解析。這裡有兩個可用選擇:<br />
<br />
*[[Samba]] 提供了通過微軟 '''NetBIOS''' 的主機名稱解析。其只需要安裝 {{Pkg|samba}} 並啟用 {{ic|nmbd.service}} 服務。執行 Windows 、OS X 或執行了 {{ic|nmbd}} 的 Linux ,將能夠找到您的機器。<br />
<br />
*[[Avahi]] 提供通過 '''zeroconf''' 的主機名稱解析,也稱作 Avahi 或 Boujour 。它比 Samba 還需要稍微複雜一點的設定:詳情請參考[Avahi#Hostname resolution|Avahi#主機名稱解析]]。執行 OS X 或執行了 Avahi daemon 的 Linux ,將能夠找到您的機器。Windows 並無內建 Avahi 用戶端或 Daemon 。<br />
<br />
== 診斷 ==<br />
<br />
=== Swapping computers on the cable modem ===<br />
<br />
Some cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.<br />
<br />
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].<br />
<br />
=== The TCP window scaling problem ===<br />
<br />
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.<br />
<br />
Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html RFC 1323] was written to improve the situation: Window Scaling. The "window" value, provided in all packets, will be modified by a Scale Factor defined once, at the very beginning of the connection.<br />
<br />
That 8-bit Scale Factor allows the Window to be up to 32 times higher than the initial 64Kb.<br />
<br />
It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts.<br />
<br />
The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.<br />
<br />
The resulting connection is at best very slow or broken.<br />
<br />
==== How to diagnose the problem ====<br />
<br />
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).<br />
<br />
When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|ip addr}} will report normal status... and actually everything appears normal.<br />
<br />
If you cannot browse any website, but you can ping some random hosts, chances are great that you're experiencing this problem: ping uses ICMP and is not affected by TCP problems.<br />
<br />
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).<br />
<br />
==== How to fix it (The bad way) ====<br />
<br />
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.<br />
<br />
# echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem<br />
<br />
==== How to fix it (The good way) ====<br />
<br />
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.d/99-disable_window_scaling.conf}} (see also [[sysctl]])<br />
<br />
net.ipv4.tcp_window_scaling = 0<br />
<br />
==== How to fix it (The best way) ====<br />
<br />
This problem is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.<br />
<br />
==== More about it ====<br />
<br />
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].<br />
<br />
There are also several relevant threads on the LKML.<br />
<br />
=== Realtek no link / WOL problem ===<br />
<br />
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice a problem where the NIC seems to be disabled on boot and has no Link light. This can usually be found on a dual boot system where Windows is also installed. It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause. These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots. You will be able to notice if this problem is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off. Normal operation should be that the link light is always on as long as the system is on, even during POST. This problem will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this problem:<br />
<br />
==== Method 1 - Rollback/change Windows driver ====<br />
<br />
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).<br />
<br />
==== Method 2 - Enable WOL in Windows driver ====<br />
<br />
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems). In Windows, under Device Manager, find your Realtek network adapter and double-click it. Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.<br />
<br />
In Windows XP (example)<br />
Right click my computer<br />
--> Hardware tab<br />
--> Device Manager<br />
--> Network Adapters<br />
--> "double click" Realtek ...<br />
--> Advanced tab<br />
--> Wake-On-Lan After Shutdown<br />
--> Enable<br />
<br />
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{ic|Disable}} has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.}}<br />
<br />
==== Method 3 - Newer Realtek Linux driver ====<br />
<br />
Any newer driver for these Realtek cards can be found for Linux on the realtek site. (untested but believed to also solve the problem).<br />
<br />
==== Method 4 - Enable ''LAN Boot ROM'' in BIOS/CMOS ====<br />
<br />
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.<br />
<br />
{{Note|This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.}}<br />
<br />
=== DLink G604T/DLink G502T DNS problem ===<br />
<br />
Users with a DLink G604T/DLink G502T router, using DHCP and have firmware v2.00+ (typically users with AUS firmware) may have problems with certain programs not resolving the DNS. One of these programs are unfortunatley pacman. The problem is basically the router in certain situations is not sending the DNS properly to DHCP, which causes programs to try and connect to servers with an IP address of 1.0.0.0 and fail with a connection timed out error<br />
<br />
==== How to diagnose the problem ====<br />
<br />
The best way to diagnose the problem is to use Firefox/Konqueror/links/seamonkey and to enable wget for pacman. If this is a fresh install of Arch Linux, then you may want to consider installing {{ic|links}} through the live CD.<br />
<br />
Firstly, enable wget for pacman (since it gives us info about pacman when it is downloading packages)<br />
Open {{ic|/etc/pacman.conf}} with your favourite editor and uncomment the following line (remove the # if it is there)<br />
<br />
XferCommand=/usr/bin/wget --passive-ftp -c -O %o %u<br />
<br />
While you are editing {{ic|/etc/pacman.conf}}, check the default mirror that pacman uses to download packages.<br />
<br />
Now open up the default mirror in an Internet browser to see if the mirror actually works. If it does work, then do {{ic|pacman -Syy}} (otherwise pick another working mirror and set it to the pacman default). If you get something similar to the following (notice the 1.0.0.0),<br />
<br />
<nowiki>ftp://mirror.pacific.net.au/linux/archlinux/extra/os/i686/extra.db.tar.gz</nowiki><br />
=> '/var/lib/pacman/community.db.tar.gz.part'<br />
Resolving mirror.pacific.net.au... 1.0.0.0<br />
<br />
then you most likely have this problem. The 1.0.0.0 means it is unable to resolve DNS, so we must add it to {{ic|/etc/resolv.conf}}.<br />
<br />
==== How to fix it ====<br />
<br />
{{Out of date|{{Pkg|dhcpcd}} does not use {{ic|/etc/conf.d/dhcpcd}} any more.}}<br />
<br />
Basically what we need to do is to manually add the DNS servers to our {{ic|/etc/resolv.conf}} file. The problem is that DHCP automatically deletes and replaces this file on boot, so we need to edit {{ic|/etc/conf.d/dhcpcd}} and change the flags to stop DHCP from doing this.<br />
<br />
When you open {{ic|/etc/conf.d/dhcpcd}}, you should see something close to the following:<br />
<br />
DHCPCD_ARGS="-t 30 -h $HOSTNAME"<br />
<br />
Add the {{ic|-R}} flag to the arguments, e.g.,<br />
<br />
DHCPCD_ARGS="-R -t 30 -h $HOSTNAME"<br />
<br />
{{Note|1=If you are using {{Pkg|dhcpcd}} >= 4.0.2, the {{ic|-R}} flag has been deprecated. Please see the [[#Run DHCP at boot]] section for information on how to use a custom {{ic|/etc/resolv.conf}} file.}}<br />
<br />
Save and close the file; now open {{ic|/etc/resolv.conf}}. You should see a single nameserver (most likely 10.1.1.1). This is the gateway to your router, which we need to connect to in order to get the DNS servers of your ISP. Paste the IP address into your browser and log in to your router. Go to the DNS section, and you should see an IP address in the Primary DNS Server field; copy it and paste it as a nameserver '''ABOVE''' the current gateway one.<br />
<br />
For example, {{ic|/etc/resolv.conf}} should look something along the lines of:<br />
<br />
nameserver 10.1.1.1<br />
<br />
If my primary DNS server is 211.29.132.12, then change {{ic|/etc/resolv.conf}} to:<br />
<br />
nameserver 211.29.132.12<br />
nameserver 10.1.1.1<br />
<br />
Now restart the network daemon by running {{ic|systemctl restart dhcpcd@<interface>}} and do {{ic|pacman -Syy}}. If it syncs correctly with the server, then the problem is solved.<br />
<br />
==== More about it ====<br />
<br />
This is the whirlpool forum (Australian ISP community) which talks about and gives the same solution to the problem:<br />
<br />
http://forums.whirlpool.net.au/forum-replies-archive.cfm/461625.html<br />
<br />
=== Check DHCP problem by releasing IP first ===<br />
<br />
Problem may occur when DHCP get wrong IP assignment. For example when two routers are tied together through VPN. The router that is connected to me by VPN may assigning IP address. To fix it. On a console, as root, release IP address:<br />
<br />
# dhcpcd -k<br />
<br />
Then request a new one:<br />
<br />
# dhcpcd<br />
<br />
Maybe you had to run those two commands many times.<br />
<br />
=== No eth0 with Atheros AR8161 ===<br />
<br />
{{Note|With the 3.10.2-1-ARCH kernel update, the alx ethernet driver module is included in the package.}}<br />
<br />
With the Atheros AR8161 Gigabit Ethernet card, the ethernet connection is not working out-of-the-box (with the installation media of March 2013). The module "alx" needs to be loaded but is not present.<br />
<br />
The driver from [http://linuxwireless.org/en/users/Download/stable/#compat-wireless_stable_releases compat-wireless] (that has become [https://backports.wiki.kernel.org/index.php/Releases compat-drives] since linux 3.7) need to be installed. The "-u" postfix annotates that Qualcomm have applied a driver under a unified driver.<br />
<br />
$ wget https://www.kernel.org/pub/linux/kernel/projects/backports/2013/03/28/compat-drivers-2013-03-28-5-u.tar.bz2<br />
$ tar xjf compat*<br />
$ cd compat*<br />
$ ./scripts/driver-select alx<br />
$ make<br />
$ sudo make install<br />
$ sudo modprobe alx<br />
<br />
The alx driver has not been added to Linux kernel due to various problems. Compatibility between the different kernel versions has been spotty. For better support follow the [http://lists.infradead.org/mailman/listinfo/unified-drivers mailing list]and [http://www.linuxfoundation.org/collaborate/workgroups/networking/alx alx page]for latest working solution for alx.<br />
<br />
The driver must be built and installed after every kernel change.<br />
<br />
Alternatively you can use the AUR package for [https://aur.archlinux.org/packages/compat-drivers-patched/ compat drivers], which installs many other drivers.<br />
<br />
=== No eth0 with Atheros AR9485 ===<br />
<br />
The ethernet (eth0) for Atheros AR9485 are not working out-of-the-box (with installation media of March 2013). The working solution for this is to install the package [https://aur.archlinux.org/packages/compat-drivers-patched/ compat-drivers-patched] from AUR.<br />
<br />
=== No carrier / no connection after suspend ===<br />
After suspend to RAM no connection is found although the network cable is plugged in. <br />
This may be caused by PCI power management. What is the output of<br />
<br />
# ip link show eth0<br />
<br />
If the line contains "NO-CARRIER" even though there's a cable connected to your eth0 port, it is possible that the device was auto-suspended and the media sense feature doesn't work. To solve this, first you need to find your ethernet controllers PCI address by<br />
<br />
# lspci<br />
<br />
This should look similar to this:<br />
<br />
...<br />
00:19.0 Ethernet controller: Intel Corporation 82577LM Gigabit Network Connection (rev 06)<br />
...<br />
<br />
So the address is 00:19.0.<br />
Now check the PM status of the device by issuing<br />
<br />
# cat "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
substituting 00:19.0 with the address obtained from lspci.<br />
If the output reads "auto", you can try to bring the device out of suspend by<br />
<br />
# echo on > "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
Don't forget to substitute the address again.<br />
<br />
{{Note|1=This appears to be a bug in kernel 3.8.4.1- (3.8.8.1 is still affected): [https://bbs.archlinux.org/viewtopic.php?id=159837&p=2 Forum discussion.] It also appears a fix is [https://lkml.org/lkml/2013/1/18/147 on the way. (It will be likely fixed in 3.9.)] In the meantime, the above is a suitable workaround.}}<br />
<br />
=== Broadcom BCM57780 ===<br />
<br />
This Broadcom chipset sometimes does not behave well unless you specify the order of the modules to be loaded. The modules are {{ic|broadcom}} and {{ic|tg3}}, the former needing to be loaded first.<br />
<br />
These steps should help if your computer has this chipset:<br />
$ lspci | grep Ethernet<br />
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)<br />
<br />
If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following (as root):<br />
# modprobe -r tg3<br />
# modprobe broadcom<br />
# modprobe tg3<br />
<br />
Now plug you network cable in. If this solves your problems you can make this permanent by adding {{ic|broadcom}} and {{ic|tg3}} (in this order) to the {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}}:<br />
<br />
MODULES=".. broadcom tg3 .."<br />
<br />
Then rebuild the initramfs:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|These methods may work for other chipsets, such as BCM57760.}}</div>Binotahttps://wiki.archlinux.org/index.php?title=Network_configuration_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=293547Network configuration (正體中文)2014-01-19T09:47:56Z<p>Binota: /* 檢查連線 */ 修正筆誤</p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:Networking (正體中文)]]<br />
[[Category:Getting and installing Arch (正體中文)]]<br />
<br />
[[cs:Configuring Network]]<br />
[[el:Configuring Network]]<br />
[[es:Configuring Network]]<br />
[[fr:Connexions reseau]]<br />
[[it:Configuring Network]]<br />
[[ja:Network Configuration]]<br />
[[nl:Configuring Network]]<br />
[[pt:Configuring Network]]<br />
[[ro:Configurare retea]]<br />
[[ru:Configuring Network]]<br />
[[sk:Configuring Network]]<br />
[[tr:Ağ_Yapılandırması]]<br />
[[zh-CN:Network Configuration]]<br />
[[zh-TW:Network Configuration]]<br />
{{Related articles start}}<br />
{{Related|Jumbo Frames}}<br />
{{Related|Firewalls}}<br />
{{Related|Wireless Setup}}<br />
{{Related|List of Applications#Network Managers}}<br />
{{Related articles end}}<br />
{{TranslationStatus (正體中文)|Network_Configuration|2014-01-19|293523}}<br />
<br />
本頁將介紹如何設定 '''有線''' 網路連線。若您需要設定 '''無線''' 網路,請參考[[Wireless Setup|無線網路設定]]。<br />
<br />
== 檢查連線 ==<br />
<br />
{{註記|若您在執行 ping 時收到了類似 {{ic|ping: icmp open socket: Operation not permitted}} 這樣的錯誤訊息,請嘗試重新安裝 {{ic|iputils}} 軟體包。}} <br />
<br />
一般來說,基本的安裝過程都已經建立了可運作的網路設定。請執行下列指令以進行檢查:<br />
<br />
{{註記|{{ic|-c 3}} 選項表示將會呼叫三次。詳細請參閱 {{ic|man ping}} 。}}<br />
{{提示|您也可以嘗試使用其他的 Domain ,如 www.hinet.net 。}}<br />
<br />
{{hc|$ ping -c 3 www.google.com|<nowiki><br />
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.<br />
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms<br />
64 bytes from 74.125.224.146: icmp_req=2 ttl=50 time=385 ms<br />
64 bytes from 74.125.224.146: icmp_req=3 ttl=50 time=298 ms<br />
<br />
--- www.l.google.com ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 1999ms<br />
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms<br />
</nowiki>}}<br />
<br />
如果沒問題的話,您可能只是想以本文的下列部分來自定您的設定。<br />
<br />
若剛才的指令出現了 unknown hosts 之類的訊息,代表您的機器無法解析網域。這可能是因為您的網路服務提供商/閘道器造成的。您可以嘗試 ping 一個靜態 IP 以實驗您的機器可否存取網際網路。<br />
{{提示|您也可以嘗試使用其他的 IP ,如 168.95.1.1 。}}<br />
<br />
{{hc|$ ping -c 3 8.8.8.8|<nowiki><br />
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.<br />
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms<br />
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms<br />
64 bytes from 8.8.8.8: icmp_req=3 ttl=53 time=70.6 ms<br />
<br />
--- 8.8.8.8 ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 2002ms<br />
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms<br />
</nowiki>}}<br />
<br />
{{註記|{{ic|8.8.8.8}} 為一個好記的靜態 IP 位置。這是 Google 的主要 DNS 伺服器,這表示其有一定的可信度,並且通常不會被系統或代理伺服器擋下。}}<br />
<br />
若您可以 ping 通該位置,您可能需要試著在 {{ic|/etc/resolv.conf}} 檔案中加上網域名稱伺服器。<br />
<br />
== 設定主機名稱 ==<br />
<br />
[[Wikipedia:Hostname|主機名稱]]為網路中用於識別機器的唯一識別名稱:主機名稱可以通過 {{ic|/etc/hostname}} 檔案來進行設定。一般來說該檔案包含了系統的網域名稱。下面為設定主機名稱的方法:<br />
<br />
# hostnamectl set-hostname '''myhostname'''<br />
<br />
這樣會將 '''myhostname''' 寫入 {{ic|/etc/hostname}} 檔案中。<br />
<br />
詳細請參閱 {{ic|man 5 hostname}} 與 {{ic|man 1 hostnamectl}} 。<br />
<br />
{{註記|<br />
* {{ic|hostnamectl}} 支援 FQDN<br />
* 您不需要編輯 {{ic|/etc/hosts}} 檔案,{{pkg|systemd}} 會提供主機名稱解析且預設安裝於所有系統。<br />
}}<br />
<br />
使用來自 {{Pkg|inetutils}} 的 {{ic|hostname}} 指令以設定臨時主機名稱(直到重新啟動):<br />
<br />
# hostname ''myhostname''<br />
<br />
== 裝置驅動程式 ==<br />
<br />
=== 檢查驅動程式狀態 ===<br />
<br />
[[udev]] 應該會檢測您的網路介面卡([[Wikipedia:Network_interface_controller|NIC]])並自動於啟動時載入必要的模組。檢查 {{ic|lspci -v}} 輸出內容中的「Ethernet controller」 項目(或類似的)。這應該會告訴您哪些核心模組包含了網路設備的驅動程式。舉例來說:<br />
<br />
{{hc|$ lspci -v|<br />
02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)<br />
...<br />
Kernel driver in use: atl1<br />
Kernel modules: atl1<br />
}}<br />
<br />
接下來,確認該驅動程式已經通過 {{ic|dmesg <nowiki>|</nowiki> grep ''module_name''}} 載入了。舉例來說:<br />
<br />
$ dmesg | grep atl1<br />
...<br />
atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex<br />
<br />
若驅動程式已成功加載可以跳過接下來這段。否則,您會需要知道哪些模組時您的特定型號的裝置需要哪個模組。<br />
<br />
=== 載入裝置模組 ===<br />
<br />
以 Google 搜尋正確的晶片組模組/驅動程式。常見的驅動模組有 Realtek 晶片組網卡的 {{ic|8139too}} ,或是 SiS 晶片組網卡的 {{ic|sis900}}。當您知道要使用何種模組了之後,試著[[Kernel modules#Manual module handling|手動將其載入]]。若您的到了錯誤訊息告訴您找不到該模組,則該驅動可能未包含於 Arch 核心中。您可以在 [[AUR]] 中搜尋該模組名稱。<br />
<br />
若 udev 未在開機期間檢測與載入正確的模組,請參閱 [[Kernel modules#Loading]]。<br />
<br />
== 網路介面 ==<br />
<br />
=== 裝置名稱 ===<br />
<br />
對於多網路卡的電腦,固定裝置名稱非常重要。許多設定問題都是因為介面卡名稱的改動造成的。<br />
<br />
[[udev]] 負責命名裝置。Systemd v197 則有[http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames 可預測之網路介面名稱]並可自動支配靜態名稱給網路裝置。介面名稱以 {{ic|en}} (乙太網路)、 {{ic|wl}} (無線網路) 或是 {{ic|ww}} (WWAN)作為前置字串並附上一個自動產生的識別名稱,進而產生了類似 {{ic|enp0s25}} 這樣的名稱。 <br />
<br />
要禁用這種行為,可以加上一個連接:<br />
<br />
# ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules<br />
<br />
自早期版本升級 systemd 的使用者會有一自動建立的空規則檔案。因此,若您想使用一貫的裝置名稱,只需要刪除該檔案。<br />
<br />
{{提示|您可以執行 {{ic|ip link}} 或是 {{ic|ls /sys/class/net}} 以列出所有可用的介面。}}<br />
<br />
{{註記|當您更改了介面名稱規則後,別忘了更新所有跟網路有關的組態檔案與自定的 systemd unit 檔案以因應該更改。特別是當您啟用了 [[netctl#Basic method|netctl 靜態設定檔]] ,請執行 {{ic|netctl reenable ''profile''}} 以更新所有產生的服務檔案。}}<br />
<br />
==== 更改裝置名稱 ====<br />
<br />
您可以使用 udev-rule 來手動定義裝置名稱。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"<br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"<br />
</nowiki>}}<br />
<br />
請注意這兩點:<br />
<br />
* 使用這個指令以取得 MAC 位置:{{ic|cat /sys/class/net/''device_name''/address}}。<br />
* 請確定 udev 規則中使用的是小寫的十六進位數值而不是大寫。<br />
<br />
若您的網路卡為動態 MAC ,您可以使用 DEVPATH ,例如:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"<br />
</nowiki>}}<br />
<br />
{{註記|當使用了靜態的名稱時,'''應該要避免使用類似 "eth''X''" 與 "wlan''X''"''' 這樣的名稱,因為這可能會導致核心與 udev 在開機時發生衝突。而剛好相反地,最好使用核心預設不會使用的介面名稱,如 {{ic|net0}} 、 {{ic|net1}} 、 {{ic|wifi0}} 、 {{ic|wifi1}} 。詳細說明請參閱 [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames systemd] 文件。}}<br />
<br />
=== 設定裝置的 MTU 與佇列長度 ===<br />
<br />
您可以手動定義 udev 規則來更改裝置的 MTU 與佇列長度。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1480", ATTR{tx_queue_len}="2000"<br />
</nowiki>}}<br />
<br />
=== 取得目前的裝置名稱 ===<br />
<br />
目前的 NIC 名稱可以通過 sysfs 找到<br />
<br />
{{hc|$ ls /sys/class/net|<br />
lo eth0 eth1 firewire0<br />
}}<br />
<br />
=== 啟用與禁用網路介面 ===<br />
<br />
您可以使用下列指令來啟用或禁用網路介面:<br />
<br />
# ip link set eth0 up<br />
# ip link set eth0 down<br />
<br />
要確認結果,請執行:<br />
<br />
{{hc|$ ip link show dev eth0|<br />
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000<br />
...<br />
}}<br />
<br />
== 組態設定 IP 位址 ==<br />
<br />
您有兩個選擇:使用 [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]] 指派動態位址,或是使用「靜態」的位址。<br />
<br />
=== 動態 IP 位址 ===<br />
<br />
==== 手動執行 DHCP 用戶端 Daemon ====<br />
<br />
{{註記|請特別注意 {{ic|dhcpcd}} (DHCP ''Client'' Daemon,DHCP 用戶端 Daemon) 與 {{ic|dhcpd}} (DHCP ''(server)'' daemon,DHCP 伺服端 Daemon) 間的差異。}}<br />
<br />
{{hc|# dhcpcd eth0|<br />
dhcpcd: version 5.1.1 starting<br />
dhcpcd: eth0: broadcasting for a lease<br />
...<br />
dhcpcd: eth0: leased 192.168.1.70 for 86400 seconds<br />
}}<br />
<br />
緊接著, {{ic|ip addr show dev eth0}} 應該要顯示出您的 inet 位址。<br />
<br />
對部分的人而言,{{ic|dhcpcd}} 失敗時,可以使用 {{ic|dhclient}} (位於 {{Pkg|dhclient}} 軟體包中)<br />
<br />
==== 於啟動時執行 DHCP ====<br />
<br />
若您只是想使用 DHCP 來連線至您的乙太網路連線,您可以使用 {{ic|dhcpcd@.service}} (由 {{Pkg|dhcpcd}} 軟體包提供)。<br />
<br />
要啟動 {{ic|eth0}} 上的 DHCP ,只需要使用:<br />
<br />
# systemctl start dhcpcd@eth0.service<br />
<br />
您可以下列方法啟用該服務讓其於開機時自動啟動:<br />
<br />
# systemctl enable dhcpcd@eth0.service<br />
<br />
若您用了 DHCP 且您並 '''不想''' 讓您的 DNS 伺服器在每次啟動您的網路時自動指派,請將下列內容加到 {{ic|dhcpcd.conf}} 的最後一段中:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nohook resolv.conf<br />
}}<br />
<br />
另外,若您位於基於 MAC 位址的用戶端 IP 位址進行過濾的 DHCPv4 網路,您可能需要修改下列內容:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 Client ID as per RFC4361. <br />
duid<br />
}}<br />
<br />
為:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the hardware address of the interface for the Client ID (DHCPv4).<br />
clientid<br />
}}<br />
<br />
否則,您可能會因為 DHCP 伺服器無法正確讀取您的 [http://en.wikipedia.org/wiki/DHCPv6 DHCPv6-style] 用戶端 ID 而無法使用。詳細請參閱 [http://tools.ietf.org/html/rfc4361 RFC 4361] 。<br />
<br />
為防止 {{ic|dhcpcd}} 加入網域名稱伺服器至 {{ic|/etc/resolv.conf}} 中,請於其中使用 {{ic|nooption}} 選項:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nooption domain_name_servers<br />
}}<br />
<br />
接著加入您自己的 DNS 名稱伺服器至 {{ic|/etc/resolv.conf}} 中。<br />
<br />
若有多個不同的執行緒要控制 {{ic|/etc/resolv.conf}} (如 {{Pkg|dhcpcd}} 與 VPN 用戶端),您可能會想要使用 {{Pkg|openresolv}} 軟體包。使用 {{Pkg|openresolv}} 並不需要額外地設定 {{Pkg|dhcpcd}} 。<br />
<br />
==== DHCP 靜態路由 ====<br />
若您需要加入靜態路由用戶端,請於 {{ic|/usr/lib/dhcpcd/dhcpcd-hooks}} 中建立一個新的 dhcpcd hook-script 。下列範例展示了加入靜態路由至一個通過閘道器為 192.168.192.5 ,位於 10.11.12.0/24 的 VPN 子網路:<br />
{{hc|/usr/lib/dhcpcd/dhcpcd-hooks/40-vpnroute|<br />
ip route add 10.11.12.0/24 via 192.168.192.5<br />
}}<br />
前置字串''40''表示其於 dhcpcd 啟動時的最後執行 hook-script 。<br />
<br />
=== 靜態 IP 位址 ===<br />
<br />
您可能因為各種原因而希望在您的網路中指派靜態 IP 位址,例如靜態的位址可以獲得一定程度的可預測性,或是您沒有可用的 DHCP 伺服器。<br />
<br />
{{註記|若您共通過 Windows 機器共享您的網路而沒有路由器,請確保兩台電腦皆使用了靜態 IP 位址以避免區域網路問題。}}<br />
<br />
您需要:<br />
<br />
* 靜態 IP 位址<br />
* [[Wikipedia:Subnetwork|子網路遮罩]]<br />
* [[Wikipedia:Broadcast_address|廣播位址]]<br />
* [[Wikipedia:Default_gateway|預設閘道器]]的 IP 位址<br />
<br />
若您處在內部網路中,使用 192.168.*.* 這樣的 IP 位址較為安全,搭配其的子網路遮罩 255.255.255.0 ,廣播位址為 192.168.*.255 。而閘道器通常是 192.168.*.1 或是 192.168.*.254 。<br />
<br />
==== 手動指派 ====<br />
<br />
您可於控制台中指派一靜態 IP 位址:<br />
<br />
# ip addr add <IP 位址>/<子網路遮罩> broadcast <廣播> dev <介面><br />
<br />
舉例來說:<br />
<br />
# ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev eth0<br />
<br />
{{註記|子網路遮罩使用了 [[Wikipedia:CIDR_notation|CIDR 表示法]](CIDR,Classless Inter-Domain Routing,無類別網路間路由)。}}<br />
<br />
詳情請參閱 {{ic|man ip}} 。<br />
<br />
以類似下列方法加上您的閘道器:<br />
<br />
# ip route add default via <預設閘道器 IP 位址><br />
<br />
舉例來說:<br />
<br />
# ip route add default via 192.168.1.1<br />
<br />
若您得到了 "No such process" 這樣的錯誤訊息,這代表您必須以 root 執行 {{ic|ip link set dev eth0 up}} 。<br />
<br />
==== 於啟動時通過 systemd 手動連線 ====<br />
<br />
先確保 dhcpcd 已停止並禁用:<br />
<br />
# systemctl status dhcpcd.service<br />
<br />
接著為 [[systemd]] 服務建立一個檔案。以正確的網路介面名稱取代其中的 {{ic|<interface>}} :<br />
<br />
{{hc|/etc/conf.d/network@<interface>|<nowiki><br />
address=192.168.0.15<br />
netmask=24<br />
broadcast=192.168.0.255<br />
gateway=192.168.0.1<br />
</nowiki>}}<br />
<br />
建立 systemd unit 檔案:<br />
<br />
{{hc|/etc/systemd/system/network@.service|<nowiki><br />
[Unit]<br />
Description=Network connectivity (%i)<br />
Wants=network.target<br />
Before=network.target<br />
BindsTo=sys-subsystem-net-devices-%i.device<br />
After=sys-subsystem-net-devices-%i.device<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
EnvironmentFile=/etc/conf.d/network@%i<br />
<br />
ExecStart=/usr/bin/ip link set dev %i up<br />
ExecStart=/usr/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i<br />
ExecStart=/usr/bin/ip route add default via ${gateway}<br />
<br />
ExecStop=/usr/bin/ip addr flush dev %i<br />
ExecStop=/usr/bin/ip link set dev %i down<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
啟用該 unit 並將其啟動,傳入介面名稱,例如 eno1 :<br />
<br />
# systemctl enable network@eno1.service<br />
# systemctl start network@eno1.service<br />
<br />
若您需要手動設定 nameservers ,請編輯 {{ic|/etc/resolv.conf}} 檔案:<br />
<br />
{{hc|/etc/resolv.conf|<br />
nameserver 208.67.222.222<br />
nameserver 208.67.220.220}}<br />
<br />
若 {{ic|/etc/resolv.conf}} 被持續遭到複寫,請參考 [[Resolv.conf]] 以瞭解如何解決此問題。<br />
<br />
有幾個類似的方法來讓 systemd 啟動網路,其中的差異為檔案內容,並且其可以寫死 EnvironmentFile 定義的參考檔案中抓到的參數。因此可以作為一種替代的,將介面名稱放置於 /etc/conf.d/ 中的 EnvironmentFile 接著直接使用介面名稱而不是 %i 。如此一來,檔案名稱便不需要「@」。這也是一種有用的方法來閱讀 http://www.freedesktop.org/software/systemd/man/systemd.unit.html 上的 systemd 服務文件。<br />
<br />
==== 計算位址 ====<br />
<br />
您可以使用 {{Pkg|ipcalc}} 提供的 {{ic|ipcalc}} 來計算 IP 廣播、網域、子網路遮罩與主機範圍等進階設定舉例來說,我使用了位於防火牆後的乙太網路來連線 Windows 機器至 Arch。為了安全性與網路組織,我將他們放置於各自獨立的網路,接著組態設定子網路遮罩與廣播位址,如此一來網路中就只有兩台機器。為了找出子網路遮罩跟廣播位址,我使用了 ipcalc ,提供其 Arch firewire nic 的 IP 位址 10.66.66.1 ,並指定 ipcalc 要建立一個只有兩台主機的網路。<br />
<br />
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|<nowiki><br />
Address: 10.66.66.1<br />
<br />
Netmask: 255.255.255.252 = 30<br />
Network: 10.66.66.0/30<br />
HostMin: 10.66.66.1<br />
HostMax: 10.66.66.2<br />
Broadcast: 10.66.66.3<br />
Hosts/Net: 2 Class A, Private Internet<br />
</nowiki>}}<br />
<br />
== 載入組態設定 ==<br />
<br />
要測試您的設定,您可以重新啟動電腦或是重新載入相關的 systemd 服務:<br />
<br />
# systemctl restart dhcpcd@eth0<br />
<br />
您可以試著 ping 您的閘道器、 DNS 伺服器、 ISP 提供商或是其他網路上的站台。如此一來便可以確認您的網路連線問題為何,例如:<br />
<br />
$ ping -c 3 www.google.com<br />
<br />
== 附加設定 ==<br />
<br />
=== 筆記型電腦之 ifplugd ===<br />
<br />
{{Tip|{{Pkg|dhcpcd}} provides the same feature out of the box.}}<br />
<br />
{{Pkg|ifplugd}} in [[Official Repositories]] is a daemon which will automatically configure your Ethernet device when a cable is plugged in and automatically unconfigure it if the cable is pulled. This is useful on laptops with onboard network adapters, since it will only configure the interface when a cable is really connected. Another use is when you just need to restart the network but do not want to restart the computer or do it from the shell.<br />
<br />
By default it is configured to work for the {{ic|eth0}} device. This and other settings like delays can be configured in {{ic|/etc/ifplugd/ifplugd.conf}}.<br />
<br />
{{Note|[[Netctl]] package includes {{ic|netctl-ifplugd@.service}}, otherwise you can use {{ic|ifplugd@.service}} from {{Pkg|ifplugd}} package. Use for example {{ic|systemctl enable ifplugd@eth0.service}}.}}<br />
<br />
=== Bonding 或 LAG ===<br />
<br />
請參閱 [[netctl#Bonding]] 。<br />
<br />
=== IP 別名 ===<br />
<br />
{{Expansion|Manual method using [[Core Utilities#ip|ip]] should be added; then move current example using ''netctl'' into [[netctl]].}}<br />
<br />
IP 別名為讓同一個網路介面有多個 IP 位址。如此一來,單個節點的網路就能有多個網路連線,進而實現不同的作用。經典的使用方法為網頁與 FTP 伺服器的虛擬主機,或是重組伺服器而無需更新任何其他的機器(對於名稱伺服器來說特別有用)。<br />
<br />
==== 範例 ====<br />
<br />
您將需要來自[[Official Repositories|官方軟體套件庫]]的 {{Pkg|netctl}} 。<br />
<br />
準備組態設定檔:<br />
<br />
{{hc|/etc/netctl/mynetwork|<nowiki><br />
Connection='ethernet'<br />
Description='Five different addresses on the same NIC.'<br />
Interface='eth0'<br />
IP='static'<br />
Address=('192.168.1.10' '192.168.178.11' '192.168.1.12' '192.168.1.13' '192.168.1.14' '192.168.1.15')<br />
Gateway='192.168.1.1'<br />
DNS=('192.168.1.1')<br />
</nowiki>}}<br />
<br />
接著只需要將其執行:<br />
<br />
$ netctl start mynetwork<br />
<br />
=== 更改 MAC/硬體 位址 ===<br />
<br />
請參閱 [[MAC Address Spoofing]] 。<br />
<br />
=== Internet Sharing ===<br />
<br />
請參閱 [[Internet Sharing]] 。<br />
<br />
=== Router Configuration ===<br />
<br />
請參閱 [[Router]] 。<br />
<br />
=== 區域網路主機名稱解析 ===<br />
<br />
The pre-requisite is to [[#Set the hostname]] after which hostname resolution works on the local system itself {{hc|$ ping hostname|<br />
PING hostname <nowiki>(192.168.1.2) 56(84) bytes of data.<br />
64 bytes from hostname (192.168.1.2): icmp_seq=1 ttl=64 time=0.043 ms</nowiki>}}<br />
To enable other machines to address the host by name, either a manual configuration of the respective {{ic|/etc/hosts}} files or a service to propagate/resolve the name is required. <br />
<br />
When setting up a DNS server such as [[BIND]] or [[Unbound]] is overkill, manually editing your {{ic|/etc/hosts}} is too cumbersome, or when you want more flexibility with dynamic leaving and joining of hosts to the network, it is possible to handle hostname resolution on your local network using zero-configuration networking. There are two options available:<br />
<br />
*[[Samba]] provides hostname resolution via Microsoft's '''NetBIOS'''. It only requires installation of {{Pkg|samba}} and enabling of the {{ic|nmbd.service}} service. Computers running Windows, OS X, or Linux with {{ic|nmbd}} running, will be able to find your machine.<br />
<br />
*[[Avahi]] provides hostname resolution via '''zeroconf''', also known as Avahi or Bonjour. It requires slightly more complex configuration than Samba: see [[Avahi#Hostname resolution]] for details. Computers running OS X, or Linux with an Avahi daemon running, will be able to find your machine. Windows does not have an built-in Avahi client or daemon.<br />
<br />
== 診斷 ==<br />
<br />
=== Swapping computers on the cable modem ===<br />
<br />
Some cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.<br />
<br />
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].<br />
<br />
=== The TCP window scaling problem ===<br />
<br />
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.<br />
<br />
Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html RFC 1323] was written to improve the situation: Window Scaling. The "window" value, provided in all packets, will be modified by a Scale Factor defined once, at the very beginning of the connection.<br />
<br />
That 8-bit Scale Factor allows the Window to be up to 32 times higher than the initial 64Kb.<br />
<br />
It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts.<br />
<br />
The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.<br />
<br />
The resulting connection is at best very slow or broken.<br />
<br />
==== How to diagnose the problem ====<br />
<br />
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).<br />
<br />
When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|ip addr}} will report normal status... and actually everything appears normal.<br />
<br />
If you cannot browse any website, but you can ping some random hosts, chances are great that you're experiencing this problem: ping uses ICMP and is not affected by TCP problems.<br />
<br />
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).<br />
<br />
==== How to fix it (The bad way) ====<br />
<br />
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.<br />
<br />
# echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem<br />
<br />
==== How to fix it (The good way) ====<br />
<br />
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.d/99-disable_window_scaling.conf}} (see also [[sysctl]])<br />
<br />
net.ipv4.tcp_window_scaling = 0<br />
<br />
==== How to fix it (The best way) ====<br />
<br />
This problem is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.<br />
<br />
==== More about it ====<br />
<br />
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].<br />
<br />
There are also several relevant threads on the LKML.<br />
<br />
=== Realtek no link / WOL problem ===<br />
<br />
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice a problem where the NIC seems to be disabled on boot and has no Link light. This can usually be found on a dual boot system where Windows is also installed. It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause. These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots. You will be able to notice if this problem is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off. Normal operation should be that the link light is always on as long as the system is on, even during POST. This problem will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this problem:<br />
<br />
==== Method 1 - Rollback/change Windows driver ====<br />
<br />
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).<br />
<br />
==== Method 2 - Enable WOL in Windows driver ====<br />
<br />
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems). In Windows, under Device Manager, find your Realtek network adapter and double-click it. Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.<br />
<br />
In Windows XP (example)<br />
Right click my computer<br />
--> Hardware tab<br />
--> Device Manager<br />
--> Network Adapters<br />
--> "double click" Realtek ...<br />
--> Advanced tab<br />
--> Wake-On-Lan After Shutdown<br />
--> Enable<br />
<br />
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{ic|Disable}} has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.}}<br />
<br />
==== Method 3 - Newer Realtek Linux driver ====<br />
<br />
Any newer driver for these Realtek cards can be found for Linux on the realtek site. (untested but believed to also solve the problem).<br />
<br />
==== Method 4 - Enable ''LAN Boot ROM'' in BIOS/CMOS ====<br />
<br />
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.<br />
<br />
{{Note|This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.}}<br />
<br />
=== DLink G604T/DLink G502T DNS problem ===<br />
<br />
Users with a DLink G604T/DLink G502T router, using DHCP and have firmware v2.00+ (typically users with AUS firmware) may have problems with certain programs not resolving the DNS. One of these programs are unfortunatley pacman. The problem is basically the router in certain situations is not sending the DNS properly to DHCP, which causes programs to try and connect to servers with an IP address of 1.0.0.0 and fail with a connection timed out error<br />
<br />
==== How to diagnose the problem ====<br />
<br />
The best way to diagnose the problem is to use Firefox/Konqueror/links/seamonkey and to enable wget for pacman. If this is a fresh install of Arch Linux, then you may want to consider installing {{ic|links}} through the live CD.<br />
<br />
Firstly, enable wget for pacman (since it gives us info about pacman when it is downloading packages)<br />
Open {{ic|/etc/pacman.conf}} with your favourite editor and uncomment the following line (remove the # if it is there)<br />
<br />
XferCommand=/usr/bin/wget --passive-ftp -c -O %o %u<br />
<br />
While you are editing {{ic|/etc/pacman.conf}}, check the default mirror that pacman uses to download packages.<br />
<br />
Now open up the default mirror in an Internet browser to see if the mirror actually works. If it does work, then do {{ic|pacman -Syy}} (otherwise pick another working mirror and set it to the pacman default). If you get something similar to the following (notice the 1.0.0.0),<br />
<br />
<nowiki>ftp://mirror.pacific.net.au/linux/archlinux/extra/os/i686/extra.db.tar.gz</nowiki><br />
=> '/var/lib/pacman/community.db.tar.gz.part'<br />
Resolving mirror.pacific.net.au... 1.0.0.0<br />
<br />
then you most likely have this problem. The 1.0.0.0 means it is unable to resolve DNS, so we must add it to {{ic|/etc/resolv.conf}}.<br />
<br />
==== How to fix it ====<br />
<br />
{{Out of date|{{Pkg|dhcpcd}} does not use {{ic|/etc/conf.d/dhcpcd}} any more.}}<br />
<br />
Basically what we need to do is to manually add the DNS servers to our {{ic|/etc/resolv.conf}} file. The problem is that DHCP automatically deletes and replaces this file on boot, so we need to edit {{ic|/etc/conf.d/dhcpcd}} and change the flags to stop DHCP from doing this.<br />
<br />
When you open {{ic|/etc/conf.d/dhcpcd}}, you should see something close to the following:<br />
<br />
DHCPCD_ARGS="-t 30 -h $HOSTNAME"<br />
<br />
Add the {{ic|-R}} flag to the arguments, e.g.,<br />
<br />
DHCPCD_ARGS="-R -t 30 -h $HOSTNAME"<br />
<br />
{{Note|1=If you are using {{Pkg|dhcpcd}} >= 4.0.2, the {{ic|-R}} flag has been deprecated. Please see the [[#Run DHCP at boot]] section for information on how to use a custom {{ic|/etc/resolv.conf}} file.}}<br />
<br />
Save and close the file; now open {{ic|/etc/resolv.conf}}. You should see a single nameserver (most likely 10.1.1.1). This is the gateway to your router, which we need to connect to in order to get the DNS servers of your ISP. Paste the IP address into your browser and log in to your router. Go to the DNS section, and you should see an IP address in the Primary DNS Server field; copy it and paste it as a nameserver '''ABOVE''' the current gateway one.<br />
<br />
For example, {{ic|/etc/resolv.conf}} should look something along the lines of:<br />
<br />
nameserver 10.1.1.1<br />
<br />
If my primary DNS server is 211.29.132.12, then change {{ic|/etc/resolv.conf}} to:<br />
<br />
nameserver 211.29.132.12<br />
nameserver 10.1.1.1<br />
<br />
Now restart the network daemon by running {{ic|systemctl restart dhcpcd@<interface>}} and do {{ic|pacman -Syy}}. If it syncs correctly with the server, then the problem is solved.<br />
<br />
==== More about it ====<br />
<br />
This is the whirlpool forum (Australian ISP community) which talks about and gives the same solution to the problem:<br />
<br />
http://forums.whirlpool.net.au/forum-replies-archive.cfm/461625.html<br />
<br />
=== Check DHCP problem by releasing IP first ===<br />
<br />
Problem may occur when DHCP get wrong IP assignment. For example when two routers are tied together through VPN. The router that is connected to me by VPN may assigning IP address. To fix it. On a console, as root, release IP address:<br />
<br />
# dhcpcd -k<br />
<br />
Then request a new one:<br />
<br />
# dhcpcd<br />
<br />
Maybe you had to run those two commands many times.<br />
<br />
=== No eth0 with Atheros AR8161 ===<br />
<br />
{{Note|With the 3.10.2-1-ARCH kernel update, the alx ethernet driver module is included in the package.}}<br />
<br />
With the Atheros AR8161 Gigabit Ethernet card, the ethernet connection is not working out-of-the-box (with the installation media of March 2013). The module "alx" needs to be loaded but is not present.<br />
<br />
The driver from [http://linuxwireless.org/en/users/Download/stable/#compat-wireless_stable_releases compat-wireless] (that has become [https://backports.wiki.kernel.org/index.php/Releases compat-drives] since linux 3.7) need to be installed. The "-u" postfix annotates that Qualcomm have applied a driver under a unified driver.<br />
<br />
$ wget https://www.kernel.org/pub/linux/kernel/projects/backports/2013/03/28/compat-drivers-2013-03-28-5-u.tar.bz2<br />
$ tar xjf compat*<br />
$ cd compat*<br />
$ ./scripts/driver-select alx<br />
$ make<br />
$ sudo make install<br />
$ sudo modprobe alx<br />
<br />
The alx driver has not been added to Linux kernel due to various problems. Compatibility between the different kernel versions has been spotty. For better support follow the [http://lists.infradead.org/mailman/listinfo/unified-drivers mailing list]and [http://www.linuxfoundation.org/collaborate/workgroups/networking/alx alx page]for latest working solution for alx.<br />
<br />
The driver must be built and installed after every kernel change.<br />
<br />
Alternatively you can use the AUR package for [https://aur.archlinux.org/packages/compat-drivers-patched/ compat drivers], which installs many other drivers.<br />
<br />
=== No eth0 with Atheros AR9485 ===<br />
<br />
The ethernet (eth0) for Atheros AR9485 are not working out-of-the-box (with installation media of March 2013). The working solution for this is to install the package [https://aur.archlinux.org/packages/compat-drivers-patched/ compat-drivers-patched] from AUR.<br />
<br />
=== No carrier / no connection after suspend ===<br />
After suspend to RAM no connection is found although the network cable is plugged in. <br />
This may be caused by PCI power management. What is the output of<br />
<br />
# ip link show eth0<br />
<br />
If the line contains "NO-CARRIER" even though there's a cable connected to your eth0 port, it is possible that the device was auto-suspended and the media sense feature doesn't work. To solve this, first you need to find your ethernet controllers PCI address by<br />
<br />
# lspci<br />
<br />
This should look similar to this:<br />
<br />
...<br />
00:19.0 Ethernet controller: Intel Corporation 82577LM Gigabit Network Connection (rev 06)<br />
...<br />
<br />
So the address is 00:19.0.<br />
Now check the PM status of the device by issuing<br />
<br />
# cat "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
substituting 00:19.0 with the address obtained from lspci.<br />
If the output reads "auto", you can try to bring the device out of suspend by<br />
<br />
# echo on > "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
Don't forget to substitute the address again.<br />
<br />
{{Note|1=This appears to be a bug in kernel 3.8.4.1- (3.8.8.1 is still affected): [https://bbs.archlinux.org/viewtopic.php?id=159837&p=2 Forum discussion.] It also appears a fix is [https://lkml.org/lkml/2013/1/18/147 on the way. (It will be likely fixed in 3.9.)] In the meantime, the above is a suitable workaround.}}<br />
<br />
=== Broadcom BCM57780 ===<br />
<br />
This Broadcom chipset sometimes does not behave well unless you specify the order of the modules to be loaded. The modules are {{ic|broadcom}} and {{ic|tg3}}, the former needing to be loaded first.<br />
<br />
These steps should help if your computer has this chipset:<br />
$ lspci | grep Ethernet<br />
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)<br />
<br />
If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following (as root):<br />
# modprobe -r tg3<br />
# modprobe broadcom<br />
# modprobe tg3<br />
<br />
Now plug you network cable in. If this solves your problems you can make this permanent by adding {{ic|broadcom}} and {{ic|tg3}} (in this order) to the {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}}:<br />
<br />
MODULES=".. broadcom tg3 .."<br />
<br />
Then rebuild the initramfs:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|These methods may work for other chipsets, such as BCM57760.}}</div>Binotahttps://wiki.archlinux.org/index.php?title=Network_configuration_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=293546Network configuration (正體中文)2014-01-19T09:47:04Z<p>Binota: Add Translation Status</p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:Networking (正體中文)]]<br />
[[Category:Getting and installing Arch (正體中文)]]<br />
<br />
[[cs:Configuring Network]]<br />
[[el:Configuring Network]]<br />
[[es:Configuring Network]]<br />
[[fr:Connexions reseau]]<br />
[[it:Configuring Network]]<br />
[[ja:Network Configuration]]<br />
[[nl:Configuring Network]]<br />
[[pt:Configuring Network]]<br />
[[ro:Configurare retea]]<br />
[[ru:Configuring Network]]<br />
[[sk:Configuring Network]]<br />
[[tr:Ağ_Yapılandırması]]<br />
[[zh-CN:Network Configuration]]<br />
[[zh-TW:Network Configuration]]<br />
{{Related articles start}}<br />
{{Related|Jumbo Frames}}<br />
{{Related|Firewalls}}<br />
{{Related|Wireless Setup}}<br />
{{Related|List of Applications#Network Managers}}<br />
{{Related articles end}}<br />
{{TranslationStatus (正體中文)|Network_Configuration|2014-01-19|293523}}<br />
<br />
本頁將介紹如何設定 '''有線''' 網路連線。若您需要設定 '''無線''' 網路,請參考[[Wireless Setup|無線網路設定]]。<br />
<br />
== 檢查連線 ==<br />
<br />
{{註記|若您在執行 ping 時收到了類似 {{ic|ping: icmp open socket: Operation not permitted}} 這樣的錯誤訊息,請嘗試重新安裝 {{ic|iputils}} 軟體包。}} <br />
<br />
一般來說,基本的安裝過程都已經建立了可運作的網路設定。請執行下列指令以進行檢查:<br />
<br />
{{註記|{{ic|-c 3}} 選項表示將會呼叫三次。詳細請參閱 {{ic|man ping}} 。}}<br />
{{提示|您也可以嘗試使用其他的 Domain ,如 www.hinet.net 。}}<br />
<br />
{{hc|$ ping -c 3 www.google.com|<nowiki><br />
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.<br />
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms<br />
64 bytes from 74.125.224.146: icmp_req=2 ttl=50 time=385 ms<br />
64 bytes from 74.125.224.146: icmp_req=3 ttl=50 time=298 ms<br />
<br />
--- www.l.google.com ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 1999ms<br />
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms<br />
</nowiki>}}<br />
<br />
如果沒問題的話,您可能只是想以本文的下列部分來自定您的設定。<br />
<br />
若剛才的指令出現了 unknown hosts 之類的訊息,代表您的機器無法解析網域。這可能是因為您的網路服務提供商/網關造成的。您可以嘗試 ping 一個靜態 IP 以實驗您的機器可否存取網際網路。<br />
{{提示|您也可以嘗試使用其他的 IP ,如 168.95.1.1 。}}<br />
<br />
{{hc|$ ping -c 3 8.8.8.8|<nowiki><br />
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.<br />
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms<br />
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms<br />
64 bytes from 8.8.8.8: icmp_req=3 ttl=53 time=70.6 ms<br />
<br />
--- 8.8.8.8 ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 2002ms<br />
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms<br />
</nowiki>}}<br />
<br />
{{註記|{{ic|8.8.8.8}} 為一個好記的靜態 IP 位置。這是 Google 的主要 DNS 伺服器,這表示其有一定的可信度,並且通常不會被系統或代理伺服器擋下。}}<br />
<br />
若您可以 ping 通該位置,您可能需要試著在 {{ic|/etc/resolv.conf}} 檔案中加上網域名稱伺服器。<br />
<br />
== 設定主機名稱 ==<br />
<br />
[[Wikipedia:Hostname|主機名稱]]為網路中用於識別機器的唯一識別名稱:主機名稱可以通過 {{ic|/etc/hostname}} 檔案來進行設定。一般來說該檔案包含了系統的網域名稱。下面為設定主機名稱的方法:<br />
<br />
# hostnamectl set-hostname '''myhostname'''<br />
<br />
這樣會將 '''myhostname''' 寫入 {{ic|/etc/hostname}} 檔案中。<br />
<br />
詳細請參閱 {{ic|man 5 hostname}} 與 {{ic|man 1 hostnamectl}} 。<br />
<br />
{{註記|<br />
* {{ic|hostnamectl}} 支援 FQDN<br />
* 您不需要編輯 {{ic|/etc/hosts}} 檔案,{{pkg|systemd}} 會提供主機名稱解析且預設安裝於所有系統。<br />
}}<br />
<br />
使用來自 {{Pkg|inetutils}} 的 {{ic|hostname}} 指令以設定臨時主機名稱(直到重新啟動):<br />
<br />
# hostname ''myhostname''<br />
<br />
== 裝置驅動程式 ==<br />
<br />
=== 檢查驅動程式狀態 ===<br />
<br />
[[udev]] 應該會檢測您的網路介面卡([[Wikipedia:Network_interface_controller|NIC]])並自動於啟動時載入必要的模組。檢查 {{ic|lspci -v}} 輸出內容中的「Ethernet controller」 項目(或類似的)。這應該會告訴您哪些核心模組包含了網路設備的驅動程式。舉例來說:<br />
<br />
{{hc|$ lspci -v|<br />
02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)<br />
...<br />
Kernel driver in use: atl1<br />
Kernel modules: atl1<br />
}}<br />
<br />
接下來,確認該驅動程式已經通過 {{ic|dmesg <nowiki>|</nowiki> grep ''module_name''}} 載入了。舉例來說:<br />
<br />
$ dmesg | grep atl1<br />
...<br />
atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex<br />
<br />
若驅動程式已成功加載可以跳過接下來這段。否則,您會需要知道哪些模組時您的特定型號的裝置需要哪個模組。<br />
<br />
=== 載入裝置模組 ===<br />
<br />
以 Google 搜尋正確的晶片組模組/驅動程式。常見的驅動模組有 Realtek 晶片組網卡的 {{ic|8139too}} ,或是 SiS 晶片組網卡的 {{ic|sis900}}。當您知道要使用何種模組了之後,試著[[Kernel modules#Manual module handling|手動將其載入]]。若您的到了錯誤訊息告訴您找不到該模組,則該驅動可能未包含於 Arch 核心中。您可以在 [[AUR]] 中搜尋該模組名稱。<br />
<br />
若 udev 未在開機期間檢測與載入正確的模組,請參閱 [[Kernel modules#Loading]]。<br />
<br />
== 網路介面 ==<br />
<br />
=== 裝置名稱 ===<br />
<br />
對於多網路卡的電腦,固定裝置名稱非常重要。許多設定問題都是因為介面卡名稱的改動造成的。<br />
<br />
[[udev]] 負責命名裝置。Systemd v197 則有[http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames 可預測之網路介面名稱]並可自動支配靜態名稱給網路裝置。介面名稱以 {{ic|en}} (乙太網路)、 {{ic|wl}} (無線網路) 或是 {{ic|ww}} (WWAN)作為前置字串並附上一個自動產生的識別名稱,進而產生了類似 {{ic|enp0s25}} 這樣的名稱。 <br />
<br />
要禁用這種行為,可以加上一個連接:<br />
<br />
# ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules<br />
<br />
自早期版本升級 systemd 的使用者會有一自動建立的空規則檔案。因此,若您想使用一貫的裝置名稱,只需要刪除該檔案。<br />
<br />
{{提示|您可以執行 {{ic|ip link}} 或是 {{ic|ls /sys/class/net}} 以列出所有可用的介面。}}<br />
<br />
{{註記|當您更改了介面名稱規則後,別忘了更新所有跟網路有關的組態檔案與自定的 systemd unit 檔案以因應該更改。特別是當您啟用了 [[netctl#Basic method|netctl 靜態設定檔]] ,請執行 {{ic|netctl reenable ''profile''}} 以更新所有產生的服務檔案。}}<br />
<br />
==== 更改裝置名稱 ====<br />
<br />
您可以使用 udev-rule 來手動定義裝置名稱。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"<br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"<br />
</nowiki>}}<br />
<br />
請注意這兩點:<br />
<br />
* 使用這個指令以取得 MAC 位置:{{ic|cat /sys/class/net/''device_name''/address}}。<br />
* 請確定 udev 規則中使用的是小寫的十六進位數值而不是大寫。<br />
<br />
若您的網路卡為動態 MAC ,您可以使用 DEVPATH ,例如:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"<br />
</nowiki>}}<br />
<br />
{{註記|當使用了靜態的名稱時,'''應該要避免使用類似 "eth''X''" 與 "wlan''X''"''' 這樣的名稱,因為這可能會導致核心與 udev 在開機時發生衝突。而剛好相反地,最好使用核心預設不會使用的介面名稱,如 {{ic|net0}} 、 {{ic|net1}} 、 {{ic|wifi0}} 、 {{ic|wifi1}} 。詳細說明請參閱 [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames systemd] 文件。}}<br />
<br />
=== 設定裝置的 MTU 與佇列長度 ===<br />
<br />
您可以手動定義 udev 規則來更改裝置的 MTU 與佇列長度。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1480", ATTR{tx_queue_len}="2000"<br />
</nowiki>}}<br />
<br />
=== 取得目前的裝置名稱 ===<br />
<br />
目前的 NIC 名稱可以通過 sysfs 找到<br />
<br />
{{hc|$ ls /sys/class/net|<br />
lo eth0 eth1 firewire0<br />
}}<br />
<br />
=== 啟用與禁用網路介面 ===<br />
<br />
您可以使用下列指令來啟用或禁用網路介面:<br />
<br />
# ip link set eth0 up<br />
# ip link set eth0 down<br />
<br />
要確認結果,請執行:<br />
<br />
{{hc|$ ip link show dev eth0|<br />
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000<br />
...<br />
}}<br />
<br />
== 組態設定 IP 位址 ==<br />
<br />
您有兩個選擇:使用 [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]] 指派動態位址,或是使用「靜態」的位址。<br />
<br />
=== 動態 IP 位址 ===<br />
<br />
==== 手動執行 DHCP 用戶端 Daemon ====<br />
<br />
{{註記|請特別注意 {{ic|dhcpcd}} (DHCP ''Client'' Daemon,DHCP 用戶端 Daemon) 與 {{ic|dhcpd}} (DHCP ''(server)'' daemon,DHCP 伺服端 Daemon) 間的差異。}}<br />
<br />
{{hc|# dhcpcd eth0|<br />
dhcpcd: version 5.1.1 starting<br />
dhcpcd: eth0: broadcasting for a lease<br />
...<br />
dhcpcd: eth0: leased 192.168.1.70 for 86400 seconds<br />
}}<br />
<br />
緊接著, {{ic|ip addr show dev eth0}} 應該要顯示出您的 inet 位址。<br />
<br />
對部分的人而言,{{ic|dhcpcd}} 失敗時,可以使用 {{ic|dhclient}} (位於 {{Pkg|dhclient}} 軟體包中)<br />
<br />
==== 於啟動時執行 DHCP ====<br />
<br />
若您只是想使用 DHCP 來連線至您的乙太網路連線,您可以使用 {{ic|dhcpcd@.service}} (由 {{Pkg|dhcpcd}} 軟體包提供)。<br />
<br />
要啟動 {{ic|eth0}} 上的 DHCP ,只需要使用:<br />
<br />
# systemctl start dhcpcd@eth0.service<br />
<br />
您可以下列方法啟用該服務讓其於開機時自動啟動:<br />
<br />
# systemctl enable dhcpcd@eth0.service<br />
<br />
若您用了 DHCP 且您並 '''不想''' 讓您的 DNS 伺服器在每次啟動您的網路時自動指派,請將下列內容加到 {{ic|dhcpcd.conf}} 的最後一段中:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nohook resolv.conf<br />
}}<br />
<br />
另外,若您位於基於 MAC 位址的用戶端 IP 位址進行過濾的 DHCPv4 網路,您可能需要修改下列內容:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 Client ID as per RFC4361. <br />
duid<br />
}}<br />
<br />
為:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the hardware address of the interface for the Client ID (DHCPv4).<br />
clientid<br />
}}<br />
<br />
否則,您可能會因為 DHCP 伺服器無法正確讀取您的 [http://en.wikipedia.org/wiki/DHCPv6 DHCPv6-style] 用戶端 ID 而無法使用。詳細請參閱 [http://tools.ietf.org/html/rfc4361 RFC 4361] 。<br />
<br />
為防止 {{ic|dhcpcd}} 加入網域名稱伺服器至 {{ic|/etc/resolv.conf}} 中,請於其中使用 {{ic|nooption}} 選項:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nooption domain_name_servers<br />
}}<br />
<br />
接著加入您自己的 DNS 名稱伺服器至 {{ic|/etc/resolv.conf}} 中。<br />
<br />
若有多個不同的執行緒要控制 {{ic|/etc/resolv.conf}} (如 {{Pkg|dhcpcd}} 與 VPN 用戶端),您可能會想要使用 {{Pkg|openresolv}} 軟體包。使用 {{Pkg|openresolv}} 並不需要額外地設定 {{Pkg|dhcpcd}} 。<br />
<br />
==== DHCP 靜態路由 ====<br />
若您需要加入靜態路由用戶端,請於 {{ic|/usr/lib/dhcpcd/dhcpcd-hooks}} 中建立一個新的 dhcpcd hook-script 。下列範例展示了加入靜態路由至一個通過閘道器為 192.168.192.5 ,位於 10.11.12.0/24 的 VPN 子網路:<br />
{{hc|/usr/lib/dhcpcd/dhcpcd-hooks/40-vpnroute|<br />
ip route add 10.11.12.0/24 via 192.168.192.5<br />
}}<br />
前置字串''40''表示其於 dhcpcd 啟動時的最後執行 hook-script 。<br />
<br />
=== 靜態 IP 位址 ===<br />
<br />
您可能因為各種原因而希望在您的網路中指派靜態 IP 位址,例如靜態的位址可以獲得一定程度的可預測性,或是您沒有可用的 DHCP 伺服器。<br />
<br />
{{註記|若您共通過 Windows 機器共享您的網路而沒有路由器,請確保兩台電腦皆使用了靜態 IP 位址以避免區域網路問題。}}<br />
<br />
您需要:<br />
<br />
* 靜態 IP 位址<br />
* [[Wikipedia:Subnetwork|子網路遮罩]]<br />
* [[Wikipedia:Broadcast_address|廣播位址]]<br />
* [[Wikipedia:Default_gateway|預設閘道器]]的 IP 位址<br />
<br />
若您處在內部網路中,使用 192.168.*.* 這樣的 IP 位址較為安全,搭配其的子網路遮罩 255.255.255.0 ,廣播位址為 192.168.*.255 。而閘道器通常是 192.168.*.1 或是 192.168.*.254 。<br />
<br />
==== 手動指派 ====<br />
<br />
您可於控制台中指派一靜態 IP 位址:<br />
<br />
# ip addr add <IP 位址>/<子網路遮罩> broadcast <廣播> dev <介面><br />
<br />
舉例來說:<br />
<br />
# ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev eth0<br />
<br />
{{註記|子網路遮罩使用了 [[Wikipedia:CIDR_notation|CIDR 表示法]](CIDR,Classless Inter-Domain Routing,無類別網路間路由)。}}<br />
<br />
詳情請參閱 {{ic|man ip}} 。<br />
<br />
以類似下列方法加上您的閘道器:<br />
<br />
# ip route add default via <預設閘道器 IP 位址><br />
<br />
舉例來說:<br />
<br />
# ip route add default via 192.168.1.1<br />
<br />
若您得到了 "No such process" 這樣的錯誤訊息,這代表您必須以 root 執行 {{ic|ip link set dev eth0 up}} 。<br />
<br />
==== 於啟動時通過 systemd 手動連線 ====<br />
<br />
先確保 dhcpcd 已停止並禁用:<br />
<br />
# systemctl status dhcpcd.service<br />
<br />
接著為 [[systemd]] 服務建立一個檔案。以正確的網路介面名稱取代其中的 {{ic|<interface>}} :<br />
<br />
{{hc|/etc/conf.d/network@<interface>|<nowiki><br />
address=192.168.0.15<br />
netmask=24<br />
broadcast=192.168.0.255<br />
gateway=192.168.0.1<br />
</nowiki>}}<br />
<br />
建立 systemd unit 檔案:<br />
<br />
{{hc|/etc/systemd/system/network@.service|<nowiki><br />
[Unit]<br />
Description=Network connectivity (%i)<br />
Wants=network.target<br />
Before=network.target<br />
BindsTo=sys-subsystem-net-devices-%i.device<br />
After=sys-subsystem-net-devices-%i.device<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
EnvironmentFile=/etc/conf.d/network@%i<br />
<br />
ExecStart=/usr/bin/ip link set dev %i up<br />
ExecStart=/usr/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i<br />
ExecStart=/usr/bin/ip route add default via ${gateway}<br />
<br />
ExecStop=/usr/bin/ip addr flush dev %i<br />
ExecStop=/usr/bin/ip link set dev %i down<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
啟用該 unit 並將其啟動,傳入介面名稱,例如 eno1 :<br />
<br />
# systemctl enable network@eno1.service<br />
# systemctl start network@eno1.service<br />
<br />
若您需要手動設定 nameservers ,請編輯 {{ic|/etc/resolv.conf}} 檔案:<br />
<br />
{{hc|/etc/resolv.conf|<br />
nameserver 208.67.222.222<br />
nameserver 208.67.220.220}}<br />
<br />
若 {{ic|/etc/resolv.conf}} 被持續遭到複寫,請參考 [[Resolv.conf]] 以瞭解如何解決此問題。<br />
<br />
有幾個類似的方法來讓 systemd 啟動網路,其中的差異為檔案內容,並且其可以寫死 EnvironmentFile 定義的參考檔案中抓到的參數。因此可以作為一種替代的,將介面名稱放置於 /etc/conf.d/ 中的 EnvironmentFile 接著直接使用介面名稱而不是 %i 。如此一來,檔案名稱便不需要「@」。這也是一種有用的方法來閱讀 http://www.freedesktop.org/software/systemd/man/systemd.unit.html 上的 systemd 服務文件。<br />
<br />
==== 計算位址 ====<br />
<br />
您可以使用 {{Pkg|ipcalc}} 提供的 {{ic|ipcalc}} 來計算 IP 廣播、網域、子網路遮罩與主機範圍等進階設定舉例來說,我使用了位於防火牆後的乙太網路來連線 Windows 機器至 Arch。為了安全性與網路組織,我將他們放置於各自獨立的網路,接著組態設定子網路遮罩與廣播位址,如此一來網路中就只有兩台機器。為了找出子網路遮罩跟廣播位址,我使用了 ipcalc ,提供其 Arch firewire nic 的 IP 位址 10.66.66.1 ,並指定 ipcalc 要建立一個只有兩台主機的網路。<br />
<br />
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|<nowiki><br />
Address: 10.66.66.1<br />
<br />
Netmask: 255.255.255.252 = 30<br />
Network: 10.66.66.0/30<br />
HostMin: 10.66.66.1<br />
HostMax: 10.66.66.2<br />
Broadcast: 10.66.66.3<br />
Hosts/Net: 2 Class A, Private Internet<br />
</nowiki>}}<br />
<br />
== 載入組態設定 ==<br />
<br />
要測試您的設定,您可以重新啟動電腦或是重新載入相關的 systemd 服務:<br />
<br />
# systemctl restart dhcpcd@eth0<br />
<br />
您可以試著 ping 您的閘道器、 DNS 伺服器、 ISP 提供商或是其他網路上的站台。如此一來便可以確認您的網路連線問題為何,例如:<br />
<br />
$ ping -c 3 www.google.com<br />
<br />
== 附加設定 ==<br />
<br />
=== 筆記型電腦之 ifplugd ===<br />
<br />
{{Tip|{{Pkg|dhcpcd}} provides the same feature out of the box.}}<br />
<br />
{{Pkg|ifplugd}} in [[Official Repositories]] is a daemon which will automatically configure your Ethernet device when a cable is plugged in and automatically unconfigure it if the cable is pulled. This is useful on laptops with onboard network adapters, since it will only configure the interface when a cable is really connected. Another use is when you just need to restart the network but do not want to restart the computer or do it from the shell.<br />
<br />
By default it is configured to work for the {{ic|eth0}} device. This and other settings like delays can be configured in {{ic|/etc/ifplugd/ifplugd.conf}}.<br />
<br />
{{Note|[[Netctl]] package includes {{ic|netctl-ifplugd@.service}}, otherwise you can use {{ic|ifplugd@.service}} from {{Pkg|ifplugd}} package. Use for example {{ic|systemctl enable ifplugd@eth0.service}}.}}<br />
<br />
=== Bonding 或 LAG ===<br />
<br />
請參閱 [[netctl#Bonding]] 。<br />
<br />
=== IP 別名 ===<br />
<br />
{{Expansion|Manual method using [[Core Utilities#ip|ip]] should be added; then move current example using ''netctl'' into [[netctl]].}}<br />
<br />
IP 別名為讓同一個網路介面有多個 IP 位址。如此一來,單個節點的網路就能有多個網路連線,進而實現不同的作用。經典的使用方法為網頁與 FTP 伺服器的虛擬主機,或是重組伺服器而無需更新任何其他的機器(對於名稱伺服器來說特別有用)。<br />
<br />
==== 範例 ====<br />
<br />
您將需要來自[[Official Repositories|官方軟體套件庫]]的 {{Pkg|netctl}} 。<br />
<br />
準備組態設定檔:<br />
<br />
{{hc|/etc/netctl/mynetwork|<nowiki><br />
Connection='ethernet'<br />
Description='Five different addresses on the same NIC.'<br />
Interface='eth0'<br />
IP='static'<br />
Address=('192.168.1.10' '192.168.178.11' '192.168.1.12' '192.168.1.13' '192.168.1.14' '192.168.1.15')<br />
Gateway='192.168.1.1'<br />
DNS=('192.168.1.1')<br />
</nowiki>}}<br />
<br />
接著只需要將其執行:<br />
<br />
$ netctl start mynetwork<br />
<br />
=== 更改 MAC/硬體 位址 ===<br />
<br />
請參閱 [[MAC Address Spoofing]] 。<br />
<br />
=== Internet Sharing ===<br />
<br />
請參閱 [[Internet Sharing]] 。<br />
<br />
=== Router Configuration ===<br />
<br />
請參閱 [[Router]] 。<br />
<br />
=== 區域網路主機名稱解析 ===<br />
<br />
The pre-requisite is to [[#Set the hostname]] after which hostname resolution works on the local system itself {{hc|$ ping hostname|<br />
PING hostname <nowiki>(192.168.1.2) 56(84) bytes of data.<br />
64 bytes from hostname (192.168.1.2): icmp_seq=1 ttl=64 time=0.043 ms</nowiki>}}<br />
To enable other machines to address the host by name, either a manual configuration of the respective {{ic|/etc/hosts}} files or a service to propagate/resolve the name is required. <br />
<br />
When setting up a DNS server such as [[BIND]] or [[Unbound]] is overkill, manually editing your {{ic|/etc/hosts}} is too cumbersome, or when you want more flexibility with dynamic leaving and joining of hosts to the network, it is possible to handle hostname resolution on your local network using zero-configuration networking. There are two options available:<br />
<br />
*[[Samba]] provides hostname resolution via Microsoft's '''NetBIOS'''. It only requires installation of {{Pkg|samba}} and enabling of the {{ic|nmbd.service}} service. Computers running Windows, OS X, or Linux with {{ic|nmbd}} running, will be able to find your machine.<br />
<br />
*[[Avahi]] provides hostname resolution via '''zeroconf''', also known as Avahi or Bonjour. It requires slightly more complex configuration than Samba: see [[Avahi#Hostname resolution]] for details. Computers running OS X, or Linux with an Avahi daemon running, will be able to find your machine. Windows does not have an built-in Avahi client or daemon.<br />
<br />
== 診斷 ==<br />
<br />
=== Swapping computers on the cable modem ===<br />
<br />
Some cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.<br />
<br />
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].<br />
<br />
=== The TCP window scaling problem ===<br />
<br />
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.<br />
<br />
Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html RFC 1323] was written to improve the situation: Window Scaling. The "window" value, provided in all packets, will be modified by a Scale Factor defined once, at the very beginning of the connection.<br />
<br />
That 8-bit Scale Factor allows the Window to be up to 32 times higher than the initial 64Kb.<br />
<br />
It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts.<br />
<br />
The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.<br />
<br />
The resulting connection is at best very slow or broken.<br />
<br />
==== How to diagnose the problem ====<br />
<br />
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).<br />
<br />
When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|ip addr}} will report normal status... and actually everything appears normal.<br />
<br />
If you cannot browse any website, but you can ping some random hosts, chances are great that you're experiencing this problem: ping uses ICMP and is not affected by TCP problems.<br />
<br />
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).<br />
<br />
==== How to fix it (The bad way) ====<br />
<br />
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.<br />
<br />
# echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem<br />
<br />
==== How to fix it (The good way) ====<br />
<br />
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.d/99-disable_window_scaling.conf}} (see also [[sysctl]])<br />
<br />
net.ipv4.tcp_window_scaling = 0<br />
<br />
==== How to fix it (The best way) ====<br />
<br />
This problem is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.<br />
<br />
==== More about it ====<br />
<br />
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].<br />
<br />
There are also several relevant threads on the LKML.<br />
<br />
=== Realtek no link / WOL problem ===<br />
<br />
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice a problem where the NIC seems to be disabled on boot and has no Link light. This can usually be found on a dual boot system where Windows is also installed. It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause. These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots. You will be able to notice if this problem is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off. Normal operation should be that the link light is always on as long as the system is on, even during POST. This problem will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this problem:<br />
<br />
==== Method 1 - Rollback/change Windows driver ====<br />
<br />
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).<br />
<br />
==== Method 2 - Enable WOL in Windows driver ====<br />
<br />
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems). In Windows, under Device Manager, find your Realtek network adapter and double-click it. Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.<br />
<br />
In Windows XP (example)<br />
Right click my computer<br />
--> Hardware tab<br />
--> Device Manager<br />
--> Network Adapters<br />
--> "double click" Realtek ...<br />
--> Advanced tab<br />
--> Wake-On-Lan After Shutdown<br />
--> Enable<br />
<br />
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{ic|Disable}} has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.}}<br />
<br />
==== Method 3 - Newer Realtek Linux driver ====<br />
<br />
Any newer driver for these Realtek cards can be found for Linux on the realtek site. (untested but believed to also solve the problem).<br />
<br />
==== Method 4 - Enable ''LAN Boot ROM'' in BIOS/CMOS ====<br />
<br />
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.<br />
<br />
{{Note|This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.}}<br />
<br />
=== DLink G604T/DLink G502T DNS problem ===<br />
<br />
Users with a DLink G604T/DLink G502T router, using DHCP and have firmware v2.00+ (typically users with AUS firmware) may have problems with certain programs not resolving the DNS. One of these programs are unfortunatley pacman. The problem is basically the router in certain situations is not sending the DNS properly to DHCP, which causes programs to try and connect to servers with an IP address of 1.0.0.0 and fail with a connection timed out error<br />
<br />
==== How to diagnose the problem ====<br />
<br />
The best way to diagnose the problem is to use Firefox/Konqueror/links/seamonkey and to enable wget for pacman. If this is a fresh install of Arch Linux, then you may want to consider installing {{ic|links}} through the live CD.<br />
<br />
Firstly, enable wget for pacman (since it gives us info about pacman when it is downloading packages)<br />
Open {{ic|/etc/pacman.conf}} with your favourite editor and uncomment the following line (remove the # if it is there)<br />
<br />
XferCommand=/usr/bin/wget --passive-ftp -c -O %o %u<br />
<br />
While you are editing {{ic|/etc/pacman.conf}}, check the default mirror that pacman uses to download packages.<br />
<br />
Now open up the default mirror in an Internet browser to see if the mirror actually works. If it does work, then do {{ic|pacman -Syy}} (otherwise pick another working mirror and set it to the pacman default). If you get something similar to the following (notice the 1.0.0.0),<br />
<br />
<nowiki>ftp://mirror.pacific.net.au/linux/archlinux/extra/os/i686/extra.db.tar.gz</nowiki><br />
=> '/var/lib/pacman/community.db.tar.gz.part'<br />
Resolving mirror.pacific.net.au... 1.0.0.0<br />
<br />
then you most likely have this problem. The 1.0.0.0 means it is unable to resolve DNS, so we must add it to {{ic|/etc/resolv.conf}}.<br />
<br />
==== How to fix it ====<br />
<br />
{{Out of date|{{Pkg|dhcpcd}} does not use {{ic|/etc/conf.d/dhcpcd}} any more.}}<br />
<br />
Basically what we need to do is to manually add the DNS servers to our {{ic|/etc/resolv.conf}} file. The problem is that DHCP automatically deletes and replaces this file on boot, so we need to edit {{ic|/etc/conf.d/dhcpcd}} and change the flags to stop DHCP from doing this.<br />
<br />
When you open {{ic|/etc/conf.d/dhcpcd}}, you should see something close to the following:<br />
<br />
DHCPCD_ARGS="-t 30 -h $HOSTNAME"<br />
<br />
Add the {{ic|-R}} flag to the arguments, e.g.,<br />
<br />
DHCPCD_ARGS="-R -t 30 -h $HOSTNAME"<br />
<br />
{{Note|1=If you are using {{Pkg|dhcpcd}} >= 4.0.2, the {{ic|-R}} flag has been deprecated. Please see the [[#Run DHCP at boot]] section for information on how to use a custom {{ic|/etc/resolv.conf}} file.}}<br />
<br />
Save and close the file; now open {{ic|/etc/resolv.conf}}. You should see a single nameserver (most likely 10.1.1.1). This is the gateway to your router, which we need to connect to in order to get the DNS servers of your ISP. Paste the IP address into your browser and log in to your router. Go to the DNS section, and you should see an IP address in the Primary DNS Server field; copy it and paste it as a nameserver '''ABOVE''' the current gateway one.<br />
<br />
For example, {{ic|/etc/resolv.conf}} should look something along the lines of:<br />
<br />
nameserver 10.1.1.1<br />
<br />
If my primary DNS server is 211.29.132.12, then change {{ic|/etc/resolv.conf}} to:<br />
<br />
nameserver 211.29.132.12<br />
nameserver 10.1.1.1<br />
<br />
Now restart the network daemon by running {{ic|systemctl restart dhcpcd@<interface>}} and do {{ic|pacman -Syy}}. If it syncs correctly with the server, then the problem is solved.<br />
<br />
==== More about it ====<br />
<br />
This is the whirlpool forum (Australian ISP community) which talks about and gives the same solution to the problem:<br />
<br />
http://forums.whirlpool.net.au/forum-replies-archive.cfm/461625.html<br />
<br />
=== Check DHCP problem by releasing IP first ===<br />
<br />
Problem may occur when DHCP get wrong IP assignment. For example when two routers are tied together through VPN. The router that is connected to me by VPN may assigning IP address. To fix it. On a console, as root, release IP address:<br />
<br />
# dhcpcd -k<br />
<br />
Then request a new one:<br />
<br />
# dhcpcd<br />
<br />
Maybe you had to run those two commands many times.<br />
<br />
=== No eth0 with Atheros AR8161 ===<br />
<br />
{{Note|With the 3.10.2-1-ARCH kernel update, the alx ethernet driver module is included in the package.}}<br />
<br />
With the Atheros AR8161 Gigabit Ethernet card, the ethernet connection is not working out-of-the-box (with the installation media of March 2013). The module "alx" needs to be loaded but is not present.<br />
<br />
The driver from [http://linuxwireless.org/en/users/Download/stable/#compat-wireless_stable_releases compat-wireless] (that has become [https://backports.wiki.kernel.org/index.php/Releases compat-drives] since linux 3.7) need to be installed. The "-u" postfix annotates that Qualcomm have applied a driver under a unified driver.<br />
<br />
$ wget https://www.kernel.org/pub/linux/kernel/projects/backports/2013/03/28/compat-drivers-2013-03-28-5-u.tar.bz2<br />
$ tar xjf compat*<br />
$ cd compat*<br />
$ ./scripts/driver-select alx<br />
$ make<br />
$ sudo make install<br />
$ sudo modprobe alx<br />
<br />
The alx driver has not been added to Linux kernel due to various problems. Compatibility between the different kernel versions has been spotty. For better support follow the [http://lists.infradead.org/mailman/listinfo/unified-drivers mailing list]and [http://www.linuxfoundation.org/collaborate/workgroups/networking/alx alx page]for latest working solution for alx.<br />
<br />
The driver must be built and installed after every kernel change.<br />
<br />
Alternatively you can use the AUR package for [https://aur.archlinux.org/packages/compat-drivers-patched/ compat drivers], which installs many other drivers.<br />
<br />
=== No eth0 with Atheros AR9485 ===<br />
<br />
The ethernet (eth0) for Atheros AR9485 are not working out-of-the-box (with installation media of March 2013). The working solution for this is to install the package [https://aur.archlinux.org/packages/compat-drivers-patched/ compat-drivers-patched] from AUR.<br />
<br />
=== No carrier / no connection after suspend ===<br />
After suspend to RAM no connection is found although the network cable is plugged in. <br />
This may be caused by PCI power management. What is the output of<br />
<br />
# ip link show eth0<br />
<br />
If the line contains "NO-CARRIER" even though there's a cable connected to your eth0 port, it is possible that the device was auto-suspended and the media sense feature doesn't work. To solve this, first you need to find your ethernet controllers PCI address by<br />
<br />
# lspci<br />
<br />
This should look similar to this:<br />
<br />
...<br />
00:19.0 Ethernet controller: Intel Corporation 82577LM Gigabit Network Connection (rev 06)<br />
...<br />
<br />
So the address is 00:19.0.<br />
Now check the PM status of the device by issuing<br />
<br />
# cat "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
substituting 00:19.0 with the address obtained from lspci.<br />
If the output reads "auto", you can try to bring the device out of suspend by<br />
<br />
# echo on > "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
Don't forget to substitute the address again.<br />
<br />
{{Note|1=This appears to be a bug in kernel 3.8.4.1- (3.8.8.1 is still affected): [https://bbs.archlinux.org/viewtopic.php?id=159837&p=2 Forum discussion.] It also appears a fix is [https://lkml.org/lkml/2013/1/18/147 on the way. (It will be likely fixed in 3.9.)] In the meantime, the above is a suitable workaround.}}<br />
<br />
=== Broadcom BCM57780 ===<br />
<br />
This Broadcom chipset sometimes does not behave well unless you specify the order of the modules to be loaded. The modules are {{ic|broadcom}} and {{ic|tg3}}, the former needing to be loaded first.<br />
<br />
These steps should help if your computer has this chipset:<br />
$ lspci | grep Ethernet<br />
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)<br />
<br />
If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following (as root):<br />
# modprobe -r tg3<br />
# modprobe broadcom<br />
# modprobe tg3<br />
<br />
Now plug you network cable in. If this solves your problems you can make this permanent by adding {{ic|broadcom}} and {{ic|tg3}} (in this order) to the {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}}:<br />
<br />
MODULES=".. broadcom tg3 .."<br />
<br />
Then rebuild the initramfs:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|These methods may work for other chipsets, such as BCM57760.}}</div>Binotahttps://wiki.archlinux.org/index.php?title=Network_configuration_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=293545Network configuration (正體中文)2014-01-19T09:45:22Z<p>Binota: </p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:Networking (正體中文)]]<br />
[[Category:Getting and installing Arch (正體中文)]]<br />
<br />
[[cs:Configuring Network]]<br />
[[el:Configuring Network]]<br />
[[es:Configuring Network]]<br />
[[fr:Connexions reseau]]<br />
[[it:Configuring Network]]<br />
[[ja:Network Configuration]]<br />
[[nl:Configuring Network]]<br />
[[pt:Configuring Network]]<br />
[[ro:Configurare retea]]<br />
[[ru:Configuring Network]]<br />
[[sk:Configuring Network]]<br />
[[tr:Ağ_Yapılandırması]]<br />
[[zh-CN:Network Configuration]]<br />
[[zh-TW:Network Configuration]]<br />
{{Related articles start}}<br />
{{Related|Jumbo Frames}}<br />
{{Related|Firewalls}}<br />
{{Related|Wireless Setup}}<br />
{{Related|List of Applications#Network Managers}}<br />
{{Related articles end}}<br />
<br />
本頁將介紹如何設定 '''有線''' 網路連線。若您需要設定 '''無線''' 網路,請參考[[Wireless Setup|無線網路設定]]。<br />
<br />
== 檢查連線 ==<br />
<br />
{{註記|若您在執行 ping 時收到了類似 {{ic|ping: icmp open socket: Operation not permitted}} 這樣的錯誤訊息,請嘗試重新安裝 {{ic|iputils}} 軟體包。}} <br />
<br />
一般來說,基本的安裝過程都已經建立了可運作的網路設定。請執行下列指令以進行檢查:<br />
<br />
{{註記|{{ic|-c 3}} 選項表示將會呼叫三次。詳細請參閱 {{ic|man ping}} 。}}<br />
{{提示|您也可以嘗試使用其他的 Domain ,如 www.hinet.net 。}}<br />
<br />
{{hc|$ ping -c 3 www.google.com|<nowiki><br />
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.<br />
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms<br />
64 bytes from 74.125.224.146: icmp_req=2 ttl=50 time=385 ms<br />
64 bytes from 74.125.224.146: icmp_req=3 ttl=50 time=298 ms<br />
<br />
--- www.l.google.com ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 1999ms<br />
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms<br />
</nowiki>}}<br />
<br />
如果沒問題的話,您可能只是想以本文的下列部分來自定您的設定。<br />
<br />
若剛才的指令出現了 unknown hosts 之類的訊息,代表您的機器無法解析網域。這可能是因為您的網路服務提供商/網關造成的。您可以嘗試 ping 一個靜態 IP 以實驗您的機器可否存取網際網路。<br />
{{提示|您也可以嘗試使用其他的 IP ,如 168.95.1.1 。}}<br />
<br />
{{hc|$ ping -c 3 8.8.8.8|<nowiki><br />
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.<br />
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms<br />
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms<br />
64 bytes from 8.8.8.8: icmp_req=3 ttl=53 time=70.6 ms<br />
<br />
--- 8.8.8.8 ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 2002ms<br />
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms<br />
</nowiki>}}<br />
<br />
{{註記|{{ic|8.8.8.8}} 為一個好記的靜態 IP 位置。這是 Google 的主要 DNS 伺服器,這表示其有一定的可信度,並且通常不會被系統或代理伺服器擋下。}}<br />
<br />
若您可以 ping 通該位置,您可能需要試著在 {{ic|/etc/resolv.conf}} 檔案中加上網域名稱伺服器。<br />
<br />
== 設定主機名稱 ==<br />
<br />
[[Wikipedia:Hostname|主機名稱]]為網路中用於識別機器的唯一識別名稱:主機名稱可以通過 {{ic|/etc/hostname}} 檔案來進行設定。一般來說該檔案包含了系統的網域名稱。下面為設定主機名稱的方法:<br />
<br />
# hostnamectl set-hostname '''myhostname'''<br />
<br />
這樣會將 '''myhostname''' 寫入 {{ic|/etc/hostname}} 檔案中。<br />
<br />
詳細請參閱 {{ic|man 5 hostname}} 與 {{ic|man 1 hostnamectl}} 。<br />
<br />
{{註記|<br />
* {{ic|hostnamectl}} 支援 FQDN<br />
* 您不需要編輯 {{ic|/etc/hosts}} 檔案,{{pkg|systemd}} 會提供主機名稱解析且預設安裝於所有系統。<br />
}}<br />
<br />
使用來自 {{Pkg|inetutils}} 的 {{ic|hostname}} 指令以設定臨時主機名稱(直到重新啟動):<br />
<br />
# hostname ''myhostname''<br />
<br />
== 裝置驅動程式 ==<br />
<br />
=== 檢查驅動程式狀態 ===<br />
<br />
[[udev]] 應該會檢測您的網路介面卡([[Wikipedia:Network_interface_controller|NIC]])並自動於啟動時載入必要的模組。檢查 {{ic|lspci -v}} 輸出內容中的「Ethernet controller」 項目(或類似的)。這應該會告訴您哪些核心模組包含了網路設備的驅動程式。舉例來說:<br />
<br />
{{hc|$ lspci -v|<br />
02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)<br />
...<br />
Kernel driver in use: atl1<br />
Kernel modules: atl1<br />
}}<br />
<br />
接下來,確認該驅動程式已經通過 {{ic|dmesg <nowiki>|</nowiki> grep ''module_name''}} 載入了。舉例來說:<br />
<br />
$ dmesg | grep atl1<br />
...<br />
atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex<br />
<br />
若驅動程式已成功加載可以跳過接下來這段。否則,您會需要知道哪些模組時您的特定型號的裝置需要哪個模組。<br />
<br />
=== 載入裝置模組 ===<br />
<br />
以 Google 搜尋正確的晶片組模組/驅動程式。常見的驅動模組有 Realtek 晶片組網卡的 {{ic|8139too}} ,或是 SiS 晶片組網卡的 {{ic|sis900}}。當您知道要使用何種模組了之後,試著[[Kernel modules#Manual module handling|手動將其載入]]。若您的到了錯誤訊息告訴您找不到該模組,則該驅動可能未包含於 Arch 核心中。您可以在 [[AUR]] 中搜尋該模組名稱。<br />
<br />
若 udev 未在開機期間檢測與載入正確的模組,請參閱 [[Kernel modules#Loading]]。<br />
<br />
== 網路介面 ==<br />
<br />
=== 裝置名稱 ===<br />
<br />
對於多網路卡的電腦,固定裝置名稱非常重要。許多設定問題都是因為介面卡名稱的改動造成的。<br />
<br />
[[udev]] 負責命名裝置。Systemd v197 則有[http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames 可預測之網路介面名稱]並可自動支配靜態名稱給網路裝置。介面名稱以 {{ic|en}} (乙太網路)、 {{ic|wl}} (無線網路) 或是 {{ic|ww}} (WWAN)作為前置字串並附上一個自動產生的識別名稱,進而產生了類似 {{ic|enp0s25}} 這樣的名稱。 <br />
<br />
要禁用這種行為,可以加上一個連接:<br />
<br />
# ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules<br />
<br />
自早期版本升級 systemd 的使用者會有一自動建立的空規則檔案。因此,若您想使用一貫的裝置名稱,只需要刪除該檔案。<br />
<br />
{{提示|您可以執行 {{ic|ip link}} 或是 {{ic|ls /sys/class/net}} 以列出所有可用的介面。}}<br />
<br />
{{註記|當您更改了介面名稱規則後,別忘了更新所有跟網路有關的組態檔案與自定的 systemd unit 檔案以因應該更改。特別是當您啟用了 [[netctl#Basic method|netctl 靜態設定檔]] ,請執行 {{ic|netctl reenable ''profile''}} 以更新所有產生的服務檔案。}}<br />
<br />
==== 更改裝置名稱 ====<br />
<br />
您可以使用 udev-rule 來手動定義裝置名稱。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"<br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"<br />
</nowiki>}}<br />
<br />
請注意這兩點:<br />
<br />
* 使用這個指令以取得 MAC 位置:{{ic|cat /sys/class/net/''device_name''/address}}。<br />
* 請確定 udev 規則中使用的是小寫的十六進位數值而不是大寫。<br />
<br />
若您的網路卡為動態 MAC ,您可以使用 DEVPATH ,例如:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"<br />
</nowiki>}}<br />
<br />
{{註記|當使用了靜態的名稱時,'''應該要避免使用類似 "eth''X''" 與 "wlan''X''"''' 這樣的名稱,因為這可能會導致核心與 udev 在開機時發生衝突。而剛好相反地,最好使用核心預設不會使用的介面名稱,如 {{ic|net0}} 、 {{ic|net1}} 、 {{ic|wifi0}} 、 {{ic|wifi1}} 。詳細說明請參閱 [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames systemd] 文件。}}<br />
<br />
=== 設定裝置的 MTU 與佇列長度 ===<br />
<br />
您可以手動定義 udev 規則來更改裝置的 MTU 與佇列長度。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1480", ATTR{tx_queue_len}="2000"<br />
</nowiki>}}<br />
<br />
=== 取得目前的裝置名稱 ===<br />
<br />
目前的 NIC 名稱可以通過 sysfs 找到<br />
<br />
{{hc|$ ls /sys/class/net|<br />
lo eth0 eth1 firewire0<br />
}}<br />
<br />
=== 啟用與禁用網路介面 ===<br />
<br />
您可以使用下列指令來啟用或禁用網路介面:<br />
<br />
# ip link set eth0 up<br />
# ip link set eth0 down<br />
<br />
要確認結果,請執行:<br />
<br />
{{hc|$ ip link show dev eth0|<br />
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000<br />
...<br />
}}<br />
<br />
== 組態設定 IP 位址 ==<br />
<br />
您有兩個選擇:使用 [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]] 指派動態位址,或是使用「靜態」的位址。<br />
<br />
=== 動態 IP 位址 ===<br />
<br />
==== 手動執行 DHCP 用戶端 Daemon ====<br />
<br />
{{註記|請特別注意 {{ic|dhcpcd}} (DHCP ''Client'' Daemon,DHCP 用戶端 Daemon) 與 {{ic|dhcpd}} (DHCP ''(server)'' daemon,DHCP 伺服端 Daemon) 間的差異。}}<br />
<br />
{{hc|# dhcpcd eth0|<br />
dhcpcd: version 5.1.1 starting<br />
dhcpcd: eth0: broadcasting for a lease<br />
...<br />
dhcpcd: eth0: leased 192.168.1.70 for 86400 seconds<br />
}}<br />
<br />
緊接著, {{ic|ip addr show dev eth0}} 應該要顯示出您的 inet 位址。<br />
<br />
對部分的人而言,{{ic|dhcpcd}} 失敗時,可以使用 {{ic|dhclient}} (位於 {{Pkg|dhclient}} 軟體包中)<br />
<br />
==== 於啟動時執行 DHCP ====<br />
<br />
若您只是想使用 DHCP 來連線至您的乙太網路連線,您可以使用 {{ic|dhcpcd@.service}} (由 {{Pkg|dhcpcd}} 軟體包提供)。<br />
<br />
要啟動 {{ic|eth0}} 上的 DHCP ,只需要使用:<br />
<br />
# systemctl start dhcpcd@eth0.service<br />
<br />
您可以下列方法啟用該服務讓其於開機時自動啟動:<br />
<br />
# systemctl enable dhcpcd@eth0.service<br />
<br />
若您用了 DHCP 且您並 '''不想''' 讓您的 DNS 伺服器在每次啟動您的網路時自動指派,請將下列內容加到 {{ic|dhcpcd.conf}} 的最後一段中:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nohook resolv.conf<br />
}}<br />
<br />
另外,若您位於基於 MAC 位址的用戶端 IP 位址進行過濾的 DHCPv4 網路,您可能需要修改下列內容:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 Client ID as per RFC4361. <br />
duid<br />
}}<br />
<br />
為:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the hardware address of the interface for the Client ID (DHCPv4).<br />
clientid<br />
}}<br />
<br />
否則,您可能會因為 DHCP 伺服器無法正確讀取您的 [http://en.wikipedia.org/wiki/DHCPv6 DHCPv6-style] 用戶端 ID 而無法使用。詳細請參閱 [http://tools.ietf.org/html/rfc4361 RFC 4361] 。<br />
<br />
為防止 {{ic|dhcpcd}} 加入網域名稱伺服器至 {{ic|/etc/resolv.conf}} 中,請於其中使用 {{ic|nooption}} 選項:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nooption domain_name_servers<br />
}}<br />
<br />
接著加入您自己的 DNS 名稱伺服器至 {{ic|/etc/resolv.conf}} 中。<br />
<br />
若有多個不同的執行緒要控制 {{ic|/etc/resolv.conf}} (如 {{Pkg|dhcpcd}} 與 VPN 用戶端),您可能會想要使用 {{Pkg|openresolv}} 軟體包。使用 {{Pkg|openresolv}} 並不需要額外地設定 {{Pkg|dhcpcd}} 。<br />
<br />
==== DHCP 靜態路由 ====<br />
若您需要加入靜態路由用戶端,請於 {{ic|/usr/lib/dhcpcd/dhcpcd-hooks}} 中建立一個新的 dhcpcd hook-script 。下列範例展示了加入靜態路由至一個通過閘道器為 192.168.192.5 ,位於 10.11.12.0/24 的 VPN 子網路:<br />
{{hc|/usr/lib/dhcpcd/dhcpcd-hooks/40-vpnroute|<br />
ip route add 10.11.12.0/24 via 192.168.192.5<br />
}}<br />
前置字串''40''表示其於 dhcpcd 啟動時的最後執行 hook-script 。<br />
<br />
=== 靜態 IP 位址 ===<br />
<br />
您可能因為各種原因而希望在您的網路中指派靜態 IP 位址,例如靜態的位址可以獲得一定程度的可預測性,或是您沒有可用的 DHCP 伺服器。<br />
<br />
{{註記|若您共通過 Windows 機器共享您的網路而沒有路由器,請確保兩台電腦皆使用了靜態 IP 位址以避免區域網路問題。}}<br />
<br />
您需要:<br />
<br />
* 靜態 IP 位址<br />
* [[Wikipedia:Subnetwork|子網路遮罩]]<br />
* [[Wikipedia:Broadcast_address|廣播位址]]<br />
* [[Wikipedia:Default_gateway|預設閘道器]]的 IP 位址<br />
<br />
若您處在內部網路中,使用 192.168.*.* 這樣的 IP 位址較為安全,搭配其的子網路遮罩 255.255.255.0 ,廣播位址為 192.168.*.255 。而閘道器通常是 192.168.*.1 或是 192.168.*.254 。<br />
<br />
==== 手動指派 ====<br />
<br />
您可於控制台中指派一靜態 IP 位址:<br />
<br />
# ip addr add <IP 位址>/<子網路遮罩> broadcast <廣播> dev <介面><br />
<br />
舉例來說:<br />
<br />
# ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev eth0<br />
<br />
{{註記|子網路遮罩使用了 [[Wikipedia:CIDR_notation|CIDR 表示法]](CIDR,Classless Inter-Domain Routing,無類別網路間路由)。}}<br />
<br />
詳情請參閱 {{ic|man ip}} 。<br />
<br />
以類似下列方法加上您的閘道器:<br />
<br />
# ip route add default via <預設閘道器 IP 位址><br />
<br />
舉例來說:<br />
<br />
# ip route add default via 192.168.1.1<br />
<br />
若您得到了 "No such process" 這樣的錯誤訊息,這代表您必須以 root 執行 {{ic|ip link set dev eth0 up}} 。<br />
<br />
==== 於啟動時通過 systemd 手動連線 ====<br />
<br />
先確保 dhcpcd 已停止並禁用:<br />
<br />
# systemctl status dhcpcd.service<br />
<br />
接著為 [[systemd]] 服務建立一個檔案。以正確的網路介面名稱取代其中的 {{ic|<interface>}} :<br />
<br />
{{hc|/etc/conf.d/network@<interface>|<nowiki><br />
address=192.168.0.15<br />
netmask=24<br />
broadcast=192.168.0.255<br />
gateway=192.168.0.1<br />
</nowiki>}}<br />
<br />
建立 systemd unit 檔案:<br />
<br />
{{hc|/etc/systemd/system/network@.service|<nowiki><br />
[Unit]<br />
Description=Network connectivity (%i)<br />
Wants=network.target<br />
Before=network.target<br />
BindsTo=sys-subsystem-net-devices-%i.device<br />
After=sys-subsystem-net-devices-%i.device<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
EnvironmentFile=/etc/conf.d/network@%i<br />
<br />
ExecStart=/usr/bin/ip link set dev %i up<br />
ExecStart=/usr/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i<br />
ExecStart=/usr/bin/ip route add default via ${gateway}<br />
<br />
ExecStop=/usr/bin/ip addr flush dev %i<br />
ExecStop=/usr/bin/ip link set dev %i down<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
啟用該 unit 並將其啟動,傳入介面名稱,例如 eno1 :<br />
<br />
# systemctl enable network@eno1.service<br />
# systemctl start network@eno1.service<br />
<br />
若您需要手動設定 nameservers ,請編輯 {{ic|/etc/resolv.conf}} 檔案:<br />
<br />
{{hc|/etc/resolv.conf|<br />
nameserver 208.67.222.222<br />
nameserver 208.67.220.220}}<br />
<br />
若 {{ic|/etc/resolv.conf}} 被持續遭到複寫,請參考 [[Resolv.conf]] 以瞭解如何解決此問題。<br />
<br />
有幾個類似的方法來讓 systemd 啟動網路,其中的差異為檔案內容,並且其可以寫死 EnvironmentFile 定義的參考檔案中抓到的參數。因此可以作為一種替代的,將介面名稱放置於 /etc/conf.d/ 中的 EnvironmentFile 接著直接使用介面名稱而不是 %i 。如此一來,檔案名稱便不需要「@」。這也是一種有用的方法來閱讀 http://www.freedesktop.org/software/systemd/man/systemd.unit.html 上的 systemd 服務文件。<br />
<br />
==== 計算位址 ====<br />
<br />
您可以使用 {{Pkg|ipcalc}} 提供的 {{ic|ipcalc}} 來計算 IP 廣播、網域、子網路遮罩與主機範圍等進階設定舉例來說,我使用了位於防火牆後的乙太網路來連線 Windows 機器至 Arch。為了安全性與網路組織,我將他們放置於各自獨立的網路,接著組態設定子網路遮罩與廣播位址,如此一來網路中就只有兩台機器。為了找出子網路遮罩跟廣播位址,我使用了 ipcalc ,提供其 Arch firewire nic 的 IP 位址 10.66.66.1 ,並指定 ipcalc 要建立一個只有兩台主機的網路。<br />
<br />
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|<nowiki><br />
Address: 10.66.66.1<br />
<br />
Netmask: 255.255.255.252 = 30<br />
Network: 10.66.66.0/30<br />
HostMin: 10.66.66.1<br />
HostMax: 10.66.66.2<br />
Broadcast: 10.66.66.3<br />
Hosts/Net: 2 Class A, Private Internet<br />
</nowiki>}}<br />
<br />
== 載入組態設定 ==<br />
<br />
要測試您的設定,您可以重新啟動電腦或是重新載入相關的 systemd 服務:<br />
<br />
# systemctl restart dhcpcd@eth0<br />
<br />
您可以試著 ping 您的閘道器、 DNS 伺服器、 ISP 提供商或是其他網路上的站台。如此一來便可以確認您的網路連線問題為何,例如:<br />
<br />
$ ping -c 3 www.google.com<br />
<br />
== 附加設定 ==<br />
<br />
=== 筆記型電腦之 ifplugd ===<br />
<br />
{{Tip|{{Pkg|dhcpcd}} provides the same feature out of the box.}}<br />
<br />
{{Pkg|ifplugd}} in [[Official Repositories]] is a daemon which will automatically configure your Ethernet device when a cable is plugged in and automatically unconfigure it if the cable is pulled. This is useful on laptops with onboard network adapters, since it will only configure the interface when a cable is really connected. Another use is when you just need to restart the network but do not want to restart the computer or do it from the shell.<br />
<br />
By default it is configured to work for the {{ic|eth0}} device. This and other settings like delays can be configured in {{ic|/etc/ifplugd/ifplugd.conf}}.<br />
<br />
{{Note|[[Netctl]] package includes {{ic|netctl-ifplugd@.service}}, otherwise you can use {{ic|ifplugd@.service}} from {{Pkg|ifplugd}} package. Use for example {{ic|systemctl enable ifplugd@eth0.service}}.}}<br />
<br />
=== Bonding 或 LAG ===<br />
<br />
請參閱 [[netctl#Bonding]] 。<br />
<br />
=== IP 別名 ===<br />
<br />
{{Expansion|Manual method using [[Core Utilities#ip|ip]] should be added; then move current example using ''netctl'' into [[netctl]].}}<br />
<br />
IP 別名為讓同一個網路介面有多個 IP 位址。如此一來,單個節點的網路就能有多個網路連線,進而實現不同的作用。經典的使用方法為網頁與 FTP 伺服器的虛擬主機,或是重組伺服器而無需更新任何其他的機器(對於名稱伺服器來說特別有用)。<br />
<br />
==== 範例 ====<br />
<br />
您將需要來自[[Official Repositories|官方軟體套件庫]]的 {{Pkg|netctl}} 。<br />
<br />
準備組態設定檔:<br />
<br />
{{hc|/etc/netctl/mynetwork|<nowiki><br />
Connection='ethernet'<br />
Description='Five different addresses on the same NIC.'<br />
Interface='eth0'<br />
IP='static'<br />
Address=('192.168.1.10' '192.168.178.11' '192.168.1.12' '192.168.1.13' '192.168.1.14' '192.168.1.15')<br />
Gateway='192.168.1.1'<br />
DNS=('192.168.1.1')<br />
</nowiki>}}<br />
<br />
接著只需要將其執行:<br />
<br />
$ netctl start mynetwork<br />
<br />
=== 更改 MAC/硬體 位址 ===<br />
<br />
請參閱 [[MAC Address Spoofing]] 。<br />
<br />
=== Internet Sharing ===<br />
<br />
請參閱 [[Internet Sharing]] 。<br />
<br />
=== Router Configuration ===<br />
<br />
請參閱 [[Router]] 。<br />
<br />
=== 區域網路主機名稱解析 ===<br />
<br />
The pre-requisite is to [[#Set the hostname]] after which hostname resolution works on the local system itself {{hc|$ ping hostname|<br />
PING hostname <nowiki>(192.168.1.2) 56(84) bytes of data.<br />
64 bytes from hostname (192.168.1.2): icmp_seq=1 ttl=64 time=0.043 ms</nowiki>}}<br />
To enable other machines to address the host by name, either a manual configuration of the respective {{ic|/etc/hosts}} files or a service to propagate/resolve the name is required. <br />
<br />
When setting up a DNS server such as [[BIND]] or [[Unbound]] is overkill, manually editing your {{ic|/etc/hosts}} is too cumbersome, or when you want more flexibility with dynamic leaving and joining of hosts to the network, it is possible to handle hostname resolution on your local network using zero-configuration networking. There are two options available:<br />
<br />
*[[Samba]] provides hostname resolution via Microsoft's '''NetBIOS'''. It only requires installation of {{Pkg|samba}} and enabling of the {{ic|nmbd.service}} service. Computers running Windows, OS X, or Linux with {{ic|nmbd}} running, will be able to find your machine.<br />
<br />
*[[Avahi]] provides hostname resolution via '''zeroconf''', also known as Avahi or Bonjour. It requires slightly more complex configuration than Samba: see [[Avahi#Hostname resolution]] for details. Computers running OS X, or Linux with an Avahi daemon running, will be able to find your machine. Windows does not have an built-in Avahi client or daemon.<br />
<br />
== 診斷 ==<br />
<br />
=== Swapping computers on the cable modem ===<br />
<br />
Some cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.<br />
<br />
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].<br />
<br />
=== The TCP window scaling problem ===<br />
<br />
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.<br />
<br />
Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html RFC 1323] was written to improve the situation: Window Scaling. The "window" value, provided in all packets, will be modified by a Scale Factor defined once, at the very beginning of the connection.<br />
<br />
That 8-bit Scale Factor allows the Window to be up to 32 times higher than the initial 64Kb.<br />
<br />
It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts.<br />
<br />
The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.<br />
<br />
The resulting connection is at best very slow or broken.<br />
<br />
==== How to diagnose the problem ====<br />
<br />
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).<br />
<br />
When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|ip addr}} will report normal status... and actually everything appears normal.<br />
<br />
If you cannot browse any website, but you can ping some random hosts, chances are great that you're experiencing this problem: ping uses ICMP and is not affected by TCP problems.<br />
<br />
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).<br />
<br />
==== How to fix it (The bad way) ====<br />
<br />
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.<br />
<br />
# echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem<br />
<br />
==== How to fix it (The good way) ====<br />
<br />
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.d/99-disable_window_scaling.conf}} (see also [[sysctl]])<br />
<br />
net.ipv4.tcp_window_scaling = 0<br />
<br />
==== How to fix it (The best way) ====<br />
<br />
This problem is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.<br />
<br />
==== More about it ====<br />
<br />
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].<br />
<br />
There are also several relevant threads on the LKML.<br />
<br />
=== Realtek no link / WOL problem ===<br />
<br />
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice a problem where the NIC seems to be disabled on boot and has no Link light. This can usually be found on a dual boot system where Windows is also installed. It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause. These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots. You will be able to notice if this problem is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off. Normal operation should be that the link light is always on as long as the system is on, even during POST. This problem will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this problem:<br />
<br />
==== Method 1 - Rollback/change Windows driver ====<br />
<br />
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).<br />
<br />
==== Method 2 - Enable WOL in Windows driver ====<br />
<br />
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems). In Windows, under Device Manager, find your Realtek network adapter and double-click it. Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.<br />
<br />
In Windows XP (example)<br />
Right click my computer<br />
--> Hardware tab<br />
--> Device Manager<br />
--> Network Adapters<br />
--> "double click" Realtek ...<br />
--> Advanced tab<br />
--> Wake-On-Lan After Shutdown<br />
--> Enable<br />
<br />
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{ic|Disable}} has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.}}<br />
<br />
==== Method 3 - Newer Realtek Linux driver ====<br />
<br />
Any newer driver for these Realtek cards can be found for Linux on the realtek site. (untested but believed to also solve the problem).<br />
<br />
==== Method 4 - Enable ''LAN Boot ROM'' in BIOS/CMOS ====<br />
<br />
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.<br />
<br />
{{Note|This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.}}<br />
<br />
=== DLink G604T/DLink G502T DNS problem ===<br />
<br />
Users with a DLink G604T/DLink G502T router, using DHCP and have firmware v2.00+ (typically users with AUS firmware) may have problems with certain programs not resolving the DNS. One of these programs are unfortunatley pacman. The problem is basically the router in certain situations is not sending the DNS properly to DHCP, which causes programs to try and connect to servers with an IP address of 1.0.0.0 and fail with a connection timed out error<br />
<br />
==== How to diagnose the problem ====<br />
<br />
The best way to diagnose the problem is to use Firefox/Konqueror/links/seamonkey and to enable wget for pacman. If this is a fresh install of Arch Linux, then you may want to consider installing {{ic|links}} through the live CD.<br />
<br />
Firstly, enable wget for pacman (since it gives us info about pacman when it is downloading packages)<br />
Open {{ic|/etc/pacman.conf}} with your favourite editor and uncomment the following line (remove the # if it is there)<br />
<br />
XferCommand=/usr/bin/wget --passive-ftp -c -O %o %u<br />
<br />
While you are editing {{ic|/etc/pacman.conf}}, check the default mirror that pacman uses to download packages.<br />
<br />
Now open up the default mirror in an Internet browser to see if the mirror actually works. If it does work, then do {{ic|pacman -Syy}} (otherwise pick another working mirror and set it to the pacman default). If you get something similar to the following (notice the 1.0.0.0),<br />
<br />
<nowiki>ftp://mirror.pacific.net.au/linux/archlinux/extra/os/i686/extra.db.tar.gz</nowiki><br />
=> '/var/lib/pacman/community.db.tar.gz.part'<br />
Resolving mirror.pacific.net.au... 1.0.0.0<br />
<br />
then you most likely have this problem. The 1.0.0.0 means it is unable to resolve DNS, so we must add it to {{ic|/etc/resolv.conf}}.<br />
<br />
==== How to fix it ====<br />
<br />
{{Out of date|{{Pkg|dhcpcd}} does not use {{ic|/etc/conf.d/dhcpcd}} any more.}}<br />
<br />
Basically what we need to do is to manually add the DNS servers to our {{ic|/etc/resolv.conf}} file. The problem is that DHCP automatically deletes and replaces this file on boot, so we need to edit {{ic|/etc/conf.d/dhcpcd}} and change the flags to stop DHCP from doing this.<br />
<br />
When you open {{ic|/etc/conf.d/dhcpcd}}, you should see something close to the following:<br />
<br />
DHCPCD_ARGS="-t 30 -h $HOSTNAME"<br />
<br />
Add the {{ic|-R}} flag to the arguments, e.g.,<br />
<br />
DHCPCD_ARGS="-R -t 30 -h $HOSTNAME"<br />
<br />
{{Note|1=If you are using {{Pkg|dhcpcd}} >= 4.0.2, the {{ic|-R}} flag has been deprecated. Please see the [[#Run DHCP at boot]] section for information on how to use a custom {{ic|/etc/resolv.conf}} file.}}<br />
<br />
Save and close the file; now open {{ic|/etc/resolv.conf}}. You should see a single nameserver (most likely 10.1.1.1). This is the gateway to your router, which we need to connect to in order to get the DNS servers of your ISP. Paste the IP address into your browser and log in to your router. Go to the DNS section, and you should see an IP address in the Primary DNS Server field; copy it and paste it as a nameserver '''ABOVE''' the current gateway one.<br />
<br />
For example, {{ic|/etc/resolv.conf}} should look something along the lines of:<br />
<br />
nameserver 10.1.1.1<br />
<br />
If my primary DNS server is 211.29.132.12, then change {{ic|/etc/resolv.conf}} to:<br />
<br />
nameserver 211.29.132.12<br />
nameserver 10.1.1.1<br />
<br />
Now restart the network daemon by running {{ic|systemctl restart dhcpcd@<interface>}} and do {{ic|pacman -Syy}}. If it syncs correctly with the server, then the problem is solved.<br />
<br />
==== More about it ====<br />
<br />
This is the whirlpool forum (Australian ISP community) which talks about and gives the same solution to the problem:<br />
<br />
http://forums.whirlpool.net.au/forum-replies-archive.cfm/461625.html<br />
<br />
=== Check DHCP problem by releasing IP first ===<br />
<br />
Problem may occur when DHCP get wrong IP assignment. For example when two routers are tied together through VPN. The router that is connected to me by VPN may assigning IP address. To fix it. On a console, as root, release IP address:<br />
<br />
# dhcpcd -k<br />
<br />
Then request a new one:<br />
<br />
# dhcpcd<br />
<br />
Maybe you had to run those two commands many times.<br />
<br />
=== No eth0 with Atheros AR8161 ===<br />
<br />
{{Note|With the 3.10.2-1-ARCH kernel update, the alx ethernet driver module is included in the package.}}<br />
<br />
With the Atheros AR8161 Gigabit Ethernet card, the ethernet connection is not working out-of-the-box (with the installation media of March 2013). The module "alx" needs to be loaded but is not present.<br />
<br />
The driver from [http://linuxwireless.org/en/users/Download/stable/#compat-wireless_stable_releases compat-wireless] (that has become [https://backports.wiki.kernel.org/index.php/Releases compat-drives] since linux 3.7) need to be installed. The "-u" postfix annotates that Qualcomm have applied a driver under a unified driver.<br />
<br />
$ wget https://www.kernel.org/pub/linux/kernel/projects/backports/2013/03/28/compat-drivers-2013-03-28-5-u.tar.bz2<br />
$ tar xjf compat*<br />
$ cd compat*<br />
$ ./scripts/driver-select alx<br />
$ make<br />
$ sudo make install<br />
$ sudo modprobe alx<br />
<br />
The alx driver has not been added to Linux kernel due to various problems. Compatibility between the different kernel versions has been spotty. For better support follow the [http://lists.infradead.org/mailman/listinfo/unified-drivers mailing list]and [http://www.linuxfoundation.org/collaborate/workgroups/networking/alx alx page]for latest working solution for alx.<br />
<br />
The driver must be built and installed after every kernel change.<br />
<br />
Alternatively you can use the AUR package for [https://aur.archlinux.org/packages/compat-drivers-patched/ compat drivers], which installs many other drivers.<br />
<br />
=== No eth0 with Atheros AR9485 ===<br />
<br />
The ethernet (eth0) for Atheros AR9485 are not working out-of-the-box (with installation media of March 2013). The working solution for this is to install the package [https://aur.archlinux.org/packages/compat-drivers-patched/ compat-drivers-patched] from AUR.<br />
<br />
=== No carrier / no connection after suspend ===<br />
After suspend to RAM no connection is found although the network cable is plugged in. <br />
This may be caused by PCI power management. What is the output of<br />
<br />
# ip link show eth0<br />
<br />
If the line contains "NO-CARRIER" even though there's a cable connected to your eth0 port, it is possible that the device was auto-suspended and the media sense feature doesn't work. To solve this, first you need to find your ethernet controllers PCI address by<br />
<br />
# lspci<br />
<br />
This should look similar to this:<br />
<br />
...<br />
00:19.0 Ethernet controller: Intel Corporation 82577LM Gigabit Network Connection (rev 06)<br />
...<br />
<br />
So the address is 00:19.0.<br />
Now check the PM status of the device by issuing<br />
<br />
# cat "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
substituting 00:19.0 with the address obtained from lspci.<br />
If the output reads "auto", you can try to bring the device out of suspend by<br />
<br />
# echo on > "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
Don't forget to substitute the address again.<br />
<br />
{{Note|1=This appears to be a bug in kernel 3.8.4.1- (3.8.8.1 is still affected): [https://bbs.archlinux.org/viewtopic.php?id=159837&p=2 Forum discussion.] It also appears a fix is [https://lkml.org/lkml/2013/1/18/147 on the way. (It will be likely fixed in 3.9.)] In the meantime, the above is a suitable workaround.}}<br />
<br />
=== Broadcom BCM57780 ===<br />
<br />
This Broadcom chipset sometimes does not behave well unless you specify the order of the modules to be loaded. The modules are {{ic|broadcom}} and {{ic|tg3}}, the former needing to be loaded first.<br />
<br />
These steps should help if your computer has this chipset:<br />
$ lspci | grep Ethernet<br />
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)<br />
<br />
If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following (as root):<br />
# modprobe -r tg3<br />
# modprobe broadcom<br />
# modprobe tg3<br />
<br />
Now plug you network cable in. If this solves your problems you can make this permanent by adding {{ic|broadcom}} and {{ic|tg3}} (in this order) to the {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}}:<br />
<br />
MODULES=".. broadcom tg3 .."<br />
<br />
Then rebuild the initramfs:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|These methods may work for other chipsets, such as BCM57760.}}</div>Binotahttps://wiki.archlinux.org/index.php?title=Network_configuration_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=293543Network configuration (正體中文)2014-01-19T09:42:24Z<p>Binota: /* 靜態 IP 位址 */</p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:Networking (正體中文)]]<br />
[[Category:Getting and installing Arch (正體中文)]]<br />
<br />
[[cs:Configuring Network]]<br />
[[el:Configuring Network]]<br />
[[es:Configuring Network]]<br />
[[fr:Connexions reseau]]<br />
[[it:Configuring Network]]<br />
[[ja:Network Configuration]]<br />
[[nl:Configuring Network]]<br />
[[pt:Configuring Network]]<br />
[[ro:Configurare retea]]<br />
[[ru:Configuring Network]]<br />
[[sk:Configuring Network]]<br />
[[tr:Ağ_Yapılandırması]]<br />
[[zh-CN:Network Configuration]]<br />
[[zh-TW:Network Configuration]]<br />
{{Related articles start}}<br />
{{Related|Jumbo Frames}}<br />
{{Related|Firewalls}}<br />
{{Related|Wireless Setup}}<br />
{{Related|List of Applications#Network Managers}}<br />
{{Related articles end}}<br />
<br />
本頁將介紹如何設定 '''有線''' 網路連線。若您需要設定 '''無線''' 網路,請參考[[Wireless Setup|無線網路設定]]。<br />
<br />
== 檢查連線 ==<br />
<br />
{{注意|若您在執行 ping 時收到了類似 {{ic|ping: icmp open socket: Operation not permitted}} 這樣的錯誤訊息,請嘗試重新安裝 {{ic|iputils}} 軟體包。}} <br />
<br />
一般來說,基本的安裝過程都已經建立了可運作的網路設定。請執行下列指令以進行檢查:<br />
<br />
{{注意|{{ic|-c 3}} 選項表示將會呼叫三次。詳細請參閱 {{ic|man ping}} 。}}<br />
{{提示|您也可以嘗試使用其他的 Domain ,如 www.hinet.net 。}}<br />
<br />
{{hc|$ ping -c 3 www.google.com|<nowiki><br />
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.<br />
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms<br />
64 bytes from 74.125.224.146: icmp_req=2 ttl=50 time=385 ms<br />
64 bytes from 74.125.224.146: icmp_req=3 ttl=50 time=298 ms<br />
<br />
--- www.l.google.com ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 1999ms<br />
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms<br />
</nowiki>}}<br />
<br />
如果沒問題的話,您可能只是想以本文的下列部分來自定您的設定。<br />
<br />
若剛才的指令出現了 unknown hosts 之類的訊息,代表您的機器無法解析網域。這可能是因為您的網路服務提供商/網關造成的。您可以嘗試 ping 一個靜態 IP 以實驗您的機器可否存取網際網路。<br />
{{提示|您也可以嘗試使用其他的 IP ,如 168.95.1.1 。}}<br />
<br />
{{hc|$ ping -c 3 8.8.8.8|<nowiki><br />
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.<br />
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms<br />
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms<br />
64 bytes from 8.8.8.8: icmp_req=3 ttl=53 time=70.6 ms<br />
<br />
--- 8.8.8.8 ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 2002ms<br />
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms<br />
</nowiki>}}<br />
<br />
{{注意|{{ic|8.8.8.8}} 為一個好記的靜態 IP 位置。這是 Google 的主要 DNS 伺服器,這表示其有一定的可信度,並且通常不會被系統或代理伺服器擋下。}}<br />
<br />
若您可以 ping 通該位置,您可能需要試著在 {{ic|/etc/resolv.conf}} 檔案中加上網域名稱伺服器。<br />
<br />
== 設定主機名稱 ==<br />
<br />
[[Wikipedia:Hostname|主機名稱]]為網路中用於識別機器的唯一識別名稱:主機名稱可以通過 {{ic|/etc/hostname}} 檔案來進行設定。一般來說該檔案包含了系統的網域名稱。下面為設定主機名稱的方法:<br />
<br />
# hostnamectl set-hostname '''myhostname'''<br />
<br />
這樣會將 '''myhostname''' 寫入 {{ic|/etc/hostname}} 檔案中。<br />
<br />
詳細請參閱 {{ic|man 5 hostname}} 與 {{ic|man 1 hostnamectl}} 。<br />
<br />
{{注意|<br />
* {{ic|hostnamectl}} 支援 FQDN<br />
* 您不需要編輯 {{ic|/etc/hosts}} 檔案,{{pkg|systemd}} 會提供主機名稱解析且預設安裝於所有系統。<br />
}}<br />
<br />
使用來自 {{Pkg|inetutils}} 的 {{ic|hostname}} 指令以設定臨時主機名稱(直到重新啟動):<br />
<br />
# hostname ''myhostname''<br />
<br />
== 裝置驅動程式 ==<br />
<br />
=== 檢查驅動程式狀態 ===<br />
<br />
[[udev]] 應該會檢測您的網路介面卡([[Wikipedia:Network_interface_controller|NIC]])並自動於啟動時載入必要的模組。檢查 {{ic|lspci -v}} 輸出內容中的「Ethernet controller」 項目(或類似的)。這應該會告訴您哪些核心模組包含了網路設備的驅動程式。舉例來說:<br />
<br />
{{hc|$ lspci -v|<br />
02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)<br />
...<br />
Kernel driver in use: atl1<br />
Kernel modules: atl1<br />
}}<br />
<br />
接下來,確認該驅動程式已經通過 {{ic|dmesg <nowiki>|</nowiki> grep ''module_name''}} 載入了。舉例來說:<br />
<br />
$ dmesg | grep atl1<br />
...<br />
atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex<br />
<br />
若驅動程式已成功加載可以跳過接下來這段。否則,您會需要知道哪些模組時您的特定型號的裝置需要哪個模組。<br />
<br />
=== 載入裝置模組 ===<br />
<br />
以 Google 搜尋正確的晶片組模組/驅動程式。常見的驅動模組有 Realtek 晶片組網卡的 {{ic|8139too}} ,或是 SiS 晶片組網卡的 {{ic|sis900}}。當您知道要使用何種模組了之後,試著[[Kernel modules#Manual module handling|手動將其載入]]。若您的到了錯誤訊息告訴您找不到該模組,則該驅動可能未包含於 Arch 核心中。您可以在 [[AUR]] 中搜尋該模組名稱。<br />
<br />
若 udev 未在開機期間檢測與載入正確的模組,請參閱 [[Kernel modules#Loading]]。<br />
<br />
== 網路介面 ==<br />
<br />
=== 裝置名稱 ===<br />
<br />
對於多網路卡的電腦,固定裝置名稱非常重要。許多設定問題都是因為介面卡名稱的改動造成的。<br />
<br />
[[udev]] 負責命名裝置。Systemd v197 則有[http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames 可預測之網路介面名稱]並可自動支配靜態名稱給網路裝置。介面名稱以 {{ic|en}} (乙太網路)、 {{ic|wl}} (無線網路) 或是 {{ic|ww}} (WWAN)作為前置字串並附上一個自動產生的識別名稱,進而產生了類似 {{ic|enp0s25}} 這樣的名稱。 <br />
<br />
要禁用這種行為,可以加上一個連接:<br />
<br />
# ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules<br />
<br />
自早期版本升級 systemd 的使用者會有一自動建立的空規則檔案。因此,若您想使用一貫的裝置名稱,只需要刪除該檔案。<br />
<br />
{{提示|您可以執行 {{ic|ip link}} 或是 {{ic|ls /sys/class/net}} 以列出所有可用的介面。}}<br />
<br />
{{注意|當您更改了介面名稱規則後,別忘了更新所有跟網路有關的組態檔案與自定的 systemd unit 檔案以因應該更改。特別是當您啟用了 [[netctl#Basic method|netctl 靜態設定檔]] ,請執行 {{ic|netctl reenable ''profile''}} 以更新所有產生的服務檔案。}}<br />
<br />
==== 更改裝置名稱 ====<br />
<br />
您可以使用 udev-rule 來手動定義裝置名稱。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"<br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"<br />
</nowiki>}}<br />
<br />
請注意這兩點:<br />
<br />
* 使用這個指令以取得 MAC 位置:{{ic|cat /sys/class/net/''device_name''/address}}。<br />
* 請確定 udev 規則中使用的是小寫的十六進位數值而不是大寫。<br />
<br />
若您的網路卡為動態 MAC ,您可以使用 DEVPATH ,例如:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"<br />
</nowiki>}}<br />
<br />
{{注意|當使用了靜態的名稱時,'''應該要避免使用類似 "eth''X''" 與 "wlan''X''"''' 這樣的名稱,因為這可能會導致核心與 udev 在開機時發生衝突。而剛好相反地,最好使用核心預設不會使用的介面名稱,如 {{ic|net0}} 、 {{ic|net1}} 、 {{ic|wifi0}} 、 {{ic|wifi1}} 。詳細說明請參閱 [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames systemd] 文件。}}<br />
<br />
=== 設定裝置的 MTU 與佇列長度 ===<br />
<br />
您可以手動定義 udev 規則來更改裝置的 MTU 與佇列長度。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1480", ATTR{tx_queue_len}="2000"<br />
</nowiki>}}<br />
<br />
=== 取得目前的裝置名稱 ===<br />
<br />
目前的 NIC 名稱可以通過 sysfs 找到<br />
<br />
{{hc|$ ls /sys/class/net|<br />
lo eth0 eth1 firewire0<br />
}}<br />
<br />
=== 啟用與禁用網路介面 ===<br />
<br />
您可以使用下列指令來啟用或禁用網路介面:<br />
<br />
# ip link set eth0 up<br />
# ip link set eth0 down<br />
<br />
要確認結果,請執行:<br />
<br />
{{hc|$ ip link show dev eth0|<br />
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000<br />
...<br />
}}<br />
<br />
== 組態設定 IP 位址 ==<br />
<br />
您有兩個選擇:使用 [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]] 指派動態位址,或是使用「靜態」的位址。<br />
<br />
=== 動態 IP 位址 ===<br />
<br />
==== 手動執行 DHCP 用戶端 Daemon ====<br />
<br />
{{注意|請特別注意 {{ic|dhcpcd}} (DHCP ''Client'' Daemon,DHCP 用戶端 Daemon) 與 {{ic|dhcpd}} (DHCP ''(server)'' daemon,DHCP 伺服端 Daemon) 間的差異。}}<br />
<br />
{{hc|# dhcpcd eth0|<br />
dhcpcd: version 5.1.1 starting<br />
dhcpcd: eth0: broadcasting for a lease<br />
...<br />
dhcpcd: eth0: leased 192.168.1.70 for 86400 seconds<br />
}}<br />
<br />
緊接著, {{ic|ip addr show dev eth0}} 應該要顯示出您的 inet 位址。<br />
<br />
對部分的人而言,{{ic|dhcpcd}} 失敗時,可以使用 {{ic|dhclient}} (位於 {{Pkg|dhclient}} 軟體包中)<br />
<br />
==== 於啟動時執行 DHCP ====<br />
<br />
若您只是想使用 DHCP 來連線至您的乙太網路連線,您可以使用 {{ic|dhcpcd@.service}} (由 {{Pkg|dhcpcd}} 軟體包提供)。<br />
<br />
要啟動 {{ic|eth0}} 上的 DHCP ,只需要使用:<br />
<br />
# systemctl start dhcpcd@eth0.service<br />
<br />
您可以下列方法啟用該服務讓其於開機時自動啟動:<br />
<br />
# systemctl enable dhcpcd@eth0.service<br />
<br />
若您用了 DHCP 且您並 '''不想''' 讓您的 DNS 伺服器在每次啟動您的網路時自動指派,請將下列內容加到 {{ic|dhcpcd.conf}} 的最後一段中:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nohook resolv.conf<br />
}}<br />
<br />
另外,若您位於基於 MAC 位址的用戶端 IP 位址進行過濾的 DHCPv4 網路,您可能需要修改下列內容:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 Client ID as per RFC4361. <br />
duid<br />
}}<br />
<br />
為:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the hardware address of the interface for the Client ID (DHCPv4).<br />
clientid<br />
}}<br />
<br />
否則,您可能會因為 DHCP 伺服器無法正確讀取您的 [http://en.wikipedia.org/wiki/DHCPv6 DHCPv6-style] 用戶端 ID 而無法使用。詳細請參閱 [http://tools.ietf.org/html/rfc4361 RFC 4361] 。<br />
<br />
為防止 {{ic|dhcpcd}} 加入網域名稱伺服器至 {{ic|/etc/resolv.conf}} 中,請於其中使用 {{ic|nooption}} 選項:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nooption domain_name_servers<br />
}}<br />
<br />
接著加入您自己的 DNS 名稱伺服器至 {{ic|/etc/resolv.conf}} 中。<br />
<br />
若有多個不同的執行緒要控制 {{ic|/etc/resolv.conf}} (如 {{Pkg|dhcpcd}} 與 VPN 用戶端),您可能會想要使用 {{Pkg|openresolv}} 軟體包。使用 {{Pkg|openresolv}} 並不需要額外地設定 {{Pkg|dhcpcd}} 。<br />
<br />
==== DHCP 靜態路由 ====<br />
若您需要加入靜態路由用戶端,請於 {{ic|/usr/lib/dhcpcd/dhcpcd-hooks}} 中建立一個新的 dhcpcd hook-script 。下列範例展示了加入靜態路由至一個通過閘道器為 192.168.192.5 ,位於 10.11.12.0/24 的 VPN 子網路:<br />
{{hc|/usr/lib/dhcpcd/dhcpcd-hooks/40-vpnroute|<br />
ip route add 10.11.12.0/24 via 192.168.192.5<br />
}}<br />
前置字串''40''表示其於 dhcpcd 啟動時的最後執行 hook-script 。<br />
<br />
=== 靜態 IP 位址 ===<br />
<br />
您可能因為各種原因而希望在您的網路中指派靜態 IP 位址,例如靜態的位址可以獲得一定程度的可預測性,或是您沒有可用的 DHCP 伺服器。<br />
<br />
{{注意|若您共通過 Windows 機器共享您的網路而沒有路由器,請確保兩台電腦皆使用了靜態 IP 位址以避免區域網路問題。}}<br />
<br />
您需要:<br />
<br />
* 靜態 IP 位址<br />
* [[Wikipedia:Subnetwork|子網路遮罩]]<br />
* [[Wikipedia:Broadcast_address|廣播位址]]<br />
* [[Wikipedia:Default_gateway|預設閘道器]]的 IP 位址<br />
<br />
若您處在內部網路中,使用 192.168.*.* 這樣的 IP 位址較為安全,搭配其的子網路遮罩 255.255.255.0 ,廣播位址為 192.168.*.255 。而閘道器通常是 192.168.*.1 或是 192.168.*.254 。<br />
<br />
==== 手動指派 ====<br />
<br />
您可於控制台中指派一靜態 IP 位址:<br />
<br />
# ip addr add <IP 位址>/<子網路遮罩> broadcast <廣播> dev <介面><br />
<br />
舉例來說:<br />
<br />
# ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev eth0<br />
<br />
{{注意|子網路遮罩使用了 [[Wikipedia:CIDR_notation|CIDR 表示法]](CIDR,Classless Inter-Domain Routing,無類別網路間路由)。}}<br />
<br />
詳情請參閱 {{ic|man ip}} 。<br />
<br />
以類似下列方法加上您的閘道器:<br />
<br />
# ip route add default via <預設閘道器 IP 位址><br />
<br />
舉例來說:<br />
<br />
# ip route add default via 192.168.1.1<br />
<br />
若您得到了 "No such process" 這樣的錯誤訊息,這代表您必須以 root 執行 {{ic|ip link set dev eth0 up}} 。<br />
<br />
==== 於啟動時通過 systemd 手動連線 ====<br />
<br />
先確保 dhcpcd 已停止並禁用:<br />
<br />
# systemctl status dhcpcd.service<br />
<br />
接著為 [[systemd]] 服務建立一個檔案。以正確的網路介面名稱取代其中的 {{ic|<interface>}} :<br />
<br />
{{hc|/etc/conf.d/network@<interface>|<nowiki><br />
address=192.168.0.15<br />
netmask=24<br />
broadcast=192.168.0.255<br />
gateway=192.168.0.1<br />
</nowiki>}}<br />
<br />
建立 systemd unit 檔案:<br />
<br />
{{hc|/etc/systemd/system/network@.service|<nowiki><br />
[Unit]<br />
Description=Network connectivity (%i)<br />
Wants=network.target<br />
Before=network.target<br />
BindsTo=sys-subsystem-net-devices-%i.device<br />
After=sys-subsystem-net-devices-%i.device<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
EnvironmentFile=/etc/conf.d/network@%i<br />
<br />
ExecStart=/usr/bin/ip link set dev %i up<br />
ExecStart=/usr/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i<br />
ExecStart=/usr/bin/ip route add default via ${gateway}<br />
<br />
ExecStop=/usr/bin/ip addr flush dev %i<br />
ExecStop=/usr/bin/ip link set dev %i down<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
啟用該 unit 並將其啟動,傳入介面名稱,例如 eno1 :<br />
<br />
# systemctl enable network@eno1.service<br />
# systemctl start network@eno1.service<br />
<br />
若您需要手動設定 nameservers ,請編輯 {{ic|/etc/resolv.conf}} 檔案:<br />
<br />
{{hc|/etc/resolv.conf|<br />
nameserver 208.67.222.222<br />
nameserver 208.67.220.220}}<br />
<br />
若 {{ic|/etc/resolv.conf}} 被持續遭到複寫,請參考 [[Resolv.conf]] 以瞭解如何解決此問題。<br />
<br />
有幾個類似的方法來讓 systemd 啟動網路,其中的差異為檔案內容,並且其可以寫死 EnvironmentFile 定義的參考檔案中抓到的參數。因此可以作為一種替代的,將介面名稱放置於 /etc/conf.d/ 中的 EnvironmentFile 接著直接使用介面名稱而不是 %i 。如此一來,檔案名稱便不需要「@」。這也是一種有用的方法來閱讀 http://www.freedesktop.org/software/systemd/man/systemd.unit.html 上的 systemd 服務文件。<br />
<br />
==== 計算位址 ====<br />
<br />
您可以使用 {{Pkg|ipcalc}} 提供的 {{ic|ipcalc}} 來計算 IP 廣播、網域、子網路遮罩與主機範圍等進階設定舉例來說,我使用了位於防火牆後的乙太網路來連線 Windows 機器至 Arch。為了安全性與網路組織,我將他們放置於各自獨立的網路,接著組態設定子網路遮罩與廣播位址,如此一來網路中就只有兩台機器。為了找出子網路遮罩跟廣播位址,我使用了 ipcalc ,提供其 Arch firewire nic 的 IP 位址 10.66.66.1 ,並指定 ipcalc 要建立一個只有兩台主機的網路。<br />
<br />
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|<nowiki><br />
Address: 10.66.66.1<br />
<br />
Netmask: 255.255.255.252 = 30<br />
Network: 10.66.66.0/30<br />
HostMin: 10.66.66.1<br />
HostMax: 10.66.66.2<br />
Broadcast: 10.66.66.3<br />
Hosts/Net: 2 Class A, Private Internet<br />
</nowiki>}}<br />
<br />
== 載入組態設定 ==<br />
<br />
要測試您的設定,您可以重新啟動電腦或是重新載入相關的 systemd 服務:<br />
<br />
# systemctl restart dhcpcd@eth0<br />
<br />
您可以試著 ping 您的閘道器、 DNS 伺服器、 ISP 提供商或是其他網路上的站台。如此一來便可以確認您的網路連線問題為何,例如:<br />
<br />
$ ping -c 3 www.google.com<br />
<br />
== 附加設定 ==<br />
<br />
=== 筆記型電腦之 ifplugd ===<br />
<br />
{{Tip|{{Pkg|dhcpcd}} provides the same feature out of the box.}}<br />
<br />
{{Pkg|ifplugd}} in [[Official Repositories]] is a daemon which will automatically configure your Ethernet device when a cable is plugged in and automatically unconfigure it if the cable is pulled. This is useful on laptops with onboard network adapters, since it will only configure the interface when a cable is really connected. Another use is when you just need to restart the network but do not want to restart the computer or do it from the shell.<br />
<br />
By default it is configured to work for the {{ic|eth0}} device. This and other settings like delays can be configured in {{ic|/etc/ifplugd/ifplugd.conf}}.<br />
<br />
{{Note|[[Netctl]] package includes {{ic|netctl-ifplugd@.service}}, otherwise you can use {{ic|ifplugd@.service}} from {{Pkg|ifplugd}} package. Use for example {{ic|systemctl enable ifplugd@eth0.service}}.}}<br />
<br />
=== Bonding 或 LAG ===<br />
<br />
請參閱 [[netctl#Bonding]] 。<br />
<br />
=== IP 別名 ===<br />
<br />
{{Expansion|Manual method using [[Core Utilities#ip|ip]] should be added; then move current example using ''netctl'' into [[netctl]].}}<br />
<br />
IP 別名為讓同一個網路介面有多個 IP 位址。如此一來,單個節點的網路就能有多個網路連線,進而實現不同的作用。經典的使用方法為網頁與 FTP 伺服器的虛擬主機,或是重組伺服器而無需更新任何其他的機器(對於名稱伺服器來說特別有用)。<br />
<br />
==== 範例 ====<br />
<br />
您將需要來自[[Official Repositories|官方軟體套件庫]]的 {{Pkg|netctl}} 。<br />
<br />
準備組態設定檔:<br />
<br />
{{hc|/etc/netctl/mynetwork|<nowiki><br />
Connection='ethernet'<br />
Description='Five different addresses on the same NIC.'<br />
Interface='eth0'<br />
IP='static'<br />
Address=('192.168.1.10' '192.168.178.11' '192.168.1.12' '192.168.1.13' '192.168.1.14' '192.168.1.15')<br />
Gateway='192.168.1.1'<br />
DNS=('192.168.1.1')<br />
</nowiki>}}<br />
<br />
接著只需要將其執行:<br />
<br />
$ netctl start mynetwork<br />
<br />
=== 更改 MAC/硬體 位址 ===<br />
<br />
請參閱 [[MAC Address Spoofing]] 。<br />
<br />
=== Internet Sharing ===<br />
<br />
請參閱 [[Internet Sharing]] 。<br />
<br />
=== Router Configuration ===<br />
<br />
請參閱 [[Router]] 。<br />
<br />
=== 區域網路主機名稱解析 ===<br />
<br />
The pre-requisite is to [[#Set the hostname]] after which hostname resolution works on the local system itself {{hc|$ ping hostname|<br />
PING hostname <nowiki>(192.168.1.2) 56(84) bytes of data.<br />
64 bytes from hostname (192.168.1.2): icmp_seq=1 ttl=64 time=0.043 ms</nowiki>}}<br />
To enable other machines to address the host by name, either a manual configuration of the respective {{ic|/etc/hosts}} files or a service to propagate/resolve the name is required. <br />
<br />
When setting up a DNS server such as [[BIND]] or [[Unbound]] is overkill, manually editing your {{ic|/etc/hosts}} is too cumbersome, or when you want more flexibility with dynamic leaving and joining of hosts to the network, it is possible to handle hostname resolution on your local network using zero-configuration networking. There are two options available:<br />
<br />
*[[Samba]] provides hostname resolution via Microsoft's '''NetBIOS'''. It only requires installation of {{Pkg|samba}} and enabling of the {{ic|nmbd.service}} service. Computers running Windows, OS X, or Linux with {{ic|nmbd}} running, will be able to find your machine.<br />
<br />
*[[Avahi]] provides hostname resolution via '''zeroconf''', also known as Avahi or Bonjour. It requires slightly more complex configuration than Samba: see [[Avahi#Hostname resolution]] for details. Computers running OS X, or Linux with an Avahi daemon running, will be able to find your machine. Windows does not have an built-in Avahi client or daemon.<br />
<br />
== 診斷 ==<br />
<br />
=== Swapping computers on the cable modem ===<br />
<br />
Some cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.<br />
<br />
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].<br />
<br />
=== The TCP window scaling problem ===<br />
<br />
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.<br />
<br />
Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html RFC 1323] was written to improve the situation: Window Scaling. The "window" value, provided in all packets, will be modified by a Scale Factor defined once, at the very beginning of the connection.<br />
<br />
That 8-bit Scale Factor allows the Window to be up to 32 times higher than the initial 64Kb.<br />
<br />
It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts.<br />
<br />
The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.<br />
<br />
The resulting connection is at best very slow or broken.<br />
<br />
==== How to diagnose the problem ====<br />
<br />
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).<br />
<br />
When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|ip addr}} will report normal status... and actually everything appears normal.<br />
<br />
If you cannot browse any website, but you can ping some random hosts, chances are great that you're experiencing this problem: ping uses ICMP and is not affected by TCP problems.<br />
<br />
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).<br />
<br />
==== How to fix it (The bad way) ====<br />
<br />
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.<br />
<br />
# echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem<br />
<br />
==== How to fix it (The good way) ====<br />
<br />
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.d/99-disable_window_scaling.conf}} (see also [[sysctl]])<br />
<br />
net.ipv4.tcp_window_scaling = 0<br />
<br />
==== How to fix it (The best way) ====<br />
<br />
This problem is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.<br />
<br />
==== More about it ====<br />
<br />
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].<br />
<br />
There are also several relevant threads on the LKML.<br />
<br />
=== Realtek no link / WOL problem ===<br />
<br />
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice a problem where the NIC seems to be disabled on boot and has no Link light. This can usually be found on a dual boot system where Windows is also installed. It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause. These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots. You will be able to notice if this problem is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off. Normal operation should be that the link light is always on as long as the system is on, even during POST. This problem will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this problem:<br />
<br />
==== Method 1 - Rollback/change Windows driver ====<br />
<br />
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).<br />
<br />
==== Method 2 - Enable WOL in Windows driver ====<br />
<br />
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems). In Windows, under Device Manager, find your Realtek network adapter and double-click it. Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.<br />
<br />
In Windows XP (example)<br />
Right click my computer<br />
--> Hardware tab<br />
--> Device Manager<br />
--> Network Adapters<br />
--> "double click" Realtek ...<br />
--> Advanced tab<br />
--> Wake-On-Lan After Shutdown<br />
--> Enable<br />
<br />
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{ic|Disable}} has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.}}<br />
<br />
==== Method 3 - Newer Realtek Linux driver ====<br />
<br />
Any newer driver for these Realtek cards can be found for Linux on the realtek site. (untested but believed to also solve the problem).<br />
<br />
==== Method 4 - Enable ''LAN Boot ROM'' in BIOS/CMOS ====<br />
<br />
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.<br />
<br />
{{Note|This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.}}<br />
<br />
=== DLink G604T/DLink G502T DNS problem ===<br />
<br />
Users with a DLink G604T/DLink G502T router, using DHCP and have firmware v2.00+ (typically users with AUS firmware) may have problems with certain programs not resolving the DNS. One of these programs are unfortunatley pacman. The problem is basically the router in certain situations is not sending the DNS properly to DHCP, which causes programs to try and connect to servers with an IP address of 1.0.0.0 and fail with a connection timed out error<br />
<br />
==== How to diagnose the problem ====<br />
<br />
The best way to diagnose the problem is to use Firefox/Konqueror/links/seamonkey and to enable wget for pacman. If this is a fresh install of Arch Linux, then you may want to consider installing {{ic|links}} through the live CD.<br />
<br />
Firstly, enable wget for pacman (since it gives us info about pacman when it is downloading packages)<br />
Open {{ic|/etc/pacman.conf}} with your favourite editor and uncomment the following line (remove the # if it is there)<br />
<br />
XferCommand=/usr/bin/wget --passive-ftp -c -O %o %u<br />
<br />
While you are editing {{ic|/etc/pacman.conf}}, check the default mirror that pacman uses to download packages.<br />
<br />
Now open up the default mirror in an Internet browser to see if the mirror actually works. If it does work, then do {{ic|pacman -Syy}} (otherwise pick another working mirror and set it to the pacman default). If you get something similar to the following (notice the 1.0.0.0),<br />
<br />
<nowiki>ftp://mirror.pacific.net.au/linux/archlinux/extra/os/i686/extra.db.tar.gz</nowiki><br />
=> '/var/lib/pacman/community.db.tar.gz.part'<br />
Resolving mirror.pacific.net.au... 1.0.0.0<br />
<br />
then you most likely have this problem. The 1.0.0.0 means it is unable to resolve DNS, so we must add it to {{ic|/etc/resolv.conf}}.<br />
<br />
==== How to fix it ====<br />
<br />
{{Out of date|{{Pkg|dhcpcd}} does not use {{ic|/etc/conf.d/dhcpcd}} any more.}}<br />
<br />
Basically what we need to do is to manually add the DNS servers to our {{ic|/etc/resolv.conf}} file. The problem is that DHCP automatically deletes and replaces this file on boot, so we need to edit {{ic|/etc/conf.d/dhcpcd}} and change the flags to stop DHCP from doing this.<br />
<br />
When you open {{ic|/etc/conf.d/dhcpcd}}, you should see something close to the following:<br />
<br />
DHCPCD_ARGS="-t 30 -h $HOSTNAME"<br />
<br />
Add the {{ic|-R}} flag to the arguments, e.g.,<br />
<br />
DHCPCD_ARGS="-R -t 30 -h $HOSTNAME"<br />
<br />
{{Note|1=If you are using {{Pkg|dhcpcd}} >= 4.0.2, the {{ic|-R}} flag has been deprecated. Please see the [[#Run DHCP at boot]] section for information on how to use a custom {{ic|/etc/resolv.conf}} file.}}<br />
<br />
Save and close the file; now open {{ic|/etc/resolv.conf}}. You should see a single nameserver (most likely 10.1.1.1). This is the gateway to your router, which we need to connect to in order to get the DNS servers of your ISP. Paste the IP address into your browser and log in to your router. Go to the DNS section, and you should see an IP address in the Primary DNS Server field; copy it and paste it as a nameserver '''ABOVE''' the current gateway one.<br />
<br />
For example, {{ic|/etc/resolv.conf}} should look something along the lines of:<br />
<br />
nameserver 10.1.1.1<br />
<br />
If my primary DNS server is 211.29.132.12, then change {{ic|/etc/resolv.conf}} to:<br />
<br />
nameserver 211.29.132.12<br />
nameserver 10.1.1.1<br />
<br />
Now restart the network daemon by running {{ic|systemctl restart dhcpcd@<interface>}} and do {{ic|pacman -Syy}}. If it syncs correctly with the server, then the problem is solved.<br />
<br />
==== More about it ====<br />
<br />
This is the whirlpool forum (Australian ISP community) which talks about and gives the same solution to the problem:<br />
<br />
http://forums.whirlpool.net.au/forum-replies-archive.cfm/461625.html<br />
<br />
=== Check DHCP problem by releasing IP first ===<br />
<br />
Problem may occur when DHCP get wrong IP assignment. For example when two routers are tied together through VPN. The router that is connected to me by VPN may assigning IP address. To fix it. On a console, as root, release IP address:<br />
<br />
# dhcpcd -k<br />
<br />
Then request a new one:<br />
<br />
# dhcpcd<br />
<br />
Maybe you had to run those two commands many times.<br />
<br />
=== No eth0 with Atheros AR8161 ===<br />
<br />
{{Note|With the 3.10.2-1-ARCH kernel update, the alx ethernet driver module is included in the package.}}<br />
<br />
With the Atheros AR8161 Gigabit Ethernet card, the ethernet connection is not working out-of-the-box (with the installation media of March 2013). The module "alx" needs to be loaded but is not present.<br />
<br />
The driver from [http://linuxwireless.org/en/users/Download/stable/#compat-wireless_stable_releases compat-wireless] (that has become [https://backports.wiki.kernel.org/index.php/Releases compat-drives] since linux 3.7) need to be installed. The "-u" postfix annotates that Qualcomm have applied a driver under a unified driver.<br />
<br />
$ wget https://www.kernel.org/pub/linux/kernel/projects/backports/2013/03/28/compat-drivers-2013-03-28-5-u.tar.bz2<br />
$ tar xjf compat*<br />
$ cd compat*<br />
$ ./scripts/driver-select alx<br />
$ make<br />
$ sudo make install<br />
$ sudo modprobe alx<br />
<br />
The alx driver has not been added to Linux kernel due to various problems. Compatibility between the different kernel versions has been spotty. For better support follow the [http://lists.infradead.org/mailman/listinfo/unified-drivers mailing list]and [http://www.linuxfoundation.org/collaborate/workgroups/networking/alx alx page]for latest working solution for alx.<br />
<br />
The driver must be built and installed after every kernel change.<br />
<br />
Alternatively you can use the AUR package for [https://aur.archlinux.org/packages/compat-drivers-patched/ compat drivers], which installs many other drivers.<br />
<br />
=== No eth0 with Atheros AR9485 ===<br />
<br />
The ethernet (eth0) for Atheros AR9485 are not working out-of-the-box (with installation media of March 2013). The working solution for this is to install the package [https://aur.archlinux.org/packages/compat-drivers-patched/ compat-drivers-patched] from AUR.<br />
<br />
=== No carrier / no connection after suspend ===<br />
After suspend to RAM no connection is found although the network cable is plugged in. <br />
This may be caused by PCI power management. What is the output of<br />
<br />
# ip link show eth0<br />
<br />
If the line contains "NO-CARRIER" even though there's a cable connected to your eth0 port, it is possible that the device was auto-suspended and the media sense feature doesn't work. To solve this, first you need to find your ethernet controllers PCI address by<br />
<br />
# lspci<br />
<br />
This should look similar to this:<br />
<br />
...<br />
00:19.0 Ethernet controller: Intel Corporation 82577LM Gigabit Network Connection (rev 06)<br />
...<br />
<br />
So the address is 00:19.0.<br />
Now check the PM status of the device by issuing<br />
<br />
# cat "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
substituting 00:19.0 with the address obtained from lspci.<br />
If the output reads "auto", you can try to bring the device out of suspend by<br />
<br />
# echo on > "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
Don't forget to substitute the address again.<br />
<br />
{{Note|1=This appears to be a bug in kernel 3.8.4.1- (3.8.8.1 is still affected): [https://bbs.archlinux.org/viewtopic.php?id=159837&p=2 Forum discussion.] It also appears a fix is [https://lkml.org/lkml/2013/1/18/147 on the way. (It will be likely fixed in 3.9.)] In the meantime, the above is a suitable workaround.}}<br />
<br />
=== Broadcom BCM57780 ===<br />
<br />
This Broadcom chipset sometimes does not behave well unless you specify the order of the modules to be loaded. The modules are {{ic|broadcom}} and {{ic|tg3}}, the former needing to be loaded first.<br />
<br />
These steps should help if your computer has this chipset:<br />
$ lspci | grep Ethernet<br />
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)<br />
<br />
If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following (as root):<br />
# modprobe -r tg3<br />
# modprobe broadcom<br />
# modprobe tg3<br />
<br />
Now plug you network cable in. If this solves your problems you can make this permanent by adding {{ic|broadcom}} and {{ic|tg3}} (in this order) to the {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}}:<br />
<br />
MODULES=".. broadcom tg3 .."<br />
<br />
Then rebuild the initramfs:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|These methods may work for other chipsets, such as BCM57760.}}</div>Binotahttps://wiki.archlinux.org/index.php?title=Network_configuration_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=293542Network configuration (正體中文)2014-01-19T09:41:54Z<p>Binota: /* 檢查連線 */</p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:Networking (正體中文)]]<br />
[[Category:Getting and installing Arch (正體中文)]]<br />
<br />
[[cs:Configuring Network]]<br />
[[el:Configuring Network]]<br />
[[es:Configuring Network]]<br />
[[fr:Connexions reseau]]<br />
[[it:Configuring Network]]<br />
[[ja:Network Configuration]]<br />
[[nl:Configuring Network]]<br />
[[pt:Configuring Network]]<br />
[[ro:Configurare retea]]<br />
[[ru:Configuring Network]]<br />
[[sk:Configuring Network]]<br />
[[tr:Ağ_Yapılandırması]]<br />
[[zh-CN:Network Configuration]]<br />
[[zh-TW:Network Configuration]]<br />
{{Related articles start}}<br />
{{Related|Jumbo Frames}}<br />
{{Related|Firewalls}}<br />
{{Related|Wireless Setup}}<br />
{{Related|List of Applications#Network Managers}}<br />
{{Related articles end}}<br />
<br />
本頁將介紹如何設定 '''有線''' 網路連線。若您需要設定 '''無線''' 網路,請參考[[Wireless Setup|無線網路設定]]。<br />
<br />
== 檢查連線 ==<br />
<br />
{{注意|若您在執行 ping 時收到了類似 {{ic|ping: icmp open socket: Operation not permitted}} 這樣的錯誤訊息,請嘗試重新安裝 {{ic|iputils}} 軟體包。}} <br />
<br />
一般來說,基本的安裝過程都已經建立了可運作的網路設定。請執行下列指令以進行檢查:<br />
<br />
{{注意|{{ic|-c 3}} 選項表示將會呼叫三次。詳細請參閱 {{ic|man ping}} 。}}<br />
{{提示|您也可以嘗試使用其他的 Domain ,如 www.hinet.net 。}}<br />
<br />
{{hc|$ ping -c 3 www.google.com|<nowiki><br />
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.<br />
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms<br />
64 bytes from 74.125.224.146: icmp_req=2 ttl=50 time=385 ms<br />
64 bytes from 74.125.224.146: icmp_req=3 ttl=50 time=298 ms<br />
<br />
--- www.l.google.com ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 1999ms<br />
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms<br />
</nowiki>}}<br />
<br />
如果沒問題的話,您可能只是想以本文的下列部分來自定您的設定。<br />
<br />
若剛才的指令出現了 unknown hosts 之類的訊息,代表您的機器無法解析網域。這可能是因為您的網路服務提供商/網關造成的。您可以嘗試 ping 一個靜態 IP 以實驗您的機器可否存取網際網路。<br />
{{提示|您也可以嘗試使用其他的 IP ,如 168.95.1.1 。}}<br />
<br />
{{hc|$ ping -c 3 8.8.8.8|<nowiki><br />
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.<br />
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms<br />
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms<br />
64 bytes from 8.8.8.8: icmp_req=3 ttl=53 time=70.6 ms<br />
<br />
--- 8.8.8.8 ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 2002ms<br />
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms<br />
</nowiki>}}<br />
<br />
{{注意|{{ic|8.8.8.8}} 為一個好記的靜態 IP 位置。這是 Google 的主要 DNS 伺服器,這表示其有一定的可信度,並且通常不會被系統或代理伺服器擋下。}}<br />
<br />
若您可以 ping 通該位置,您可能需要試著在 {{ic|/etc/resolv.conf}} 檔案中加上網域名稱伺服器。<br />
<br />
== 設定主機名稱 ==<br />
<br />
[[Wikipedia:Hostname|主機名稱]]為網路中用於識別機器的唯一識別名稱:主機名稱可以通過 {{ic|/etc/hostname}} 檔案來進行設定。一般來說該檔案包含了系統的網域名稱。下面為設定主機名稱的方法:<br />
<br />
# hostnamectl set-hostname '''myhostname'''<br />
<br />
這樣會將 '''myhostname''' 寫入 {{ic|/etc/hostname}} 檔案中。<br />
<br />
詳細請參閱 {{ic|man 5 hostname}} 與 {{ic|man 1 hostnamectl}} 。<br />
<br />
{{注意|<br />
* {{ic|hostnamectl}} 支援 FQDN<br />
* 您不需要編輯 {{ic|/etc/hosts}} 檔案,{{pkg|systemd}} 會提供主機名稱解析且預設安裝於所有系統。<br />
}}<br />
<br />
使用來自 {{Pkg|inetutils}} 的 {{ic|hostname}} 指令以設定臨時主機名稱(直到重新啟動):<br />
<br />
# hostname ''myhostname''<br />
<br />
== 裝置驅動程式 ==<br />
<br />
=== 檢查驅動程式狀態 ===<br />
<br />
[[udev]] 應該會檢測您的網路介面卡([[Wikipedia:Network_interface_controller|NIC]])並自動於啟動時載入必要的模組。檢查 {{ic|lspci -v}} 輸出內容中的「Ethernet controller」 項目(或類似的)。這應該會告訴您哪些核心模組包含了網路設備的驅動程式。舉例來說:<br />
<br />
{{hc|$ lspci -v|<br />
02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)<br />
...<br />
Kernel driver in use: atl1<br />
Kernel modules: atl1<br />
}}<br />
<br />
接下來,確認該驅動程式已經通過 {{ic|dmesg <nowiki>|</nowiki> grep ''module_name''}} 載入了。舉例來說:<br />
<br />
$ dmesg | grep atl1<br />
...<br />
atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex<br />
<br />
若驅動程式已成功加載可以跳過接下來這段。否則,您會需要知道哪些模組時您的特定型號的裝置需要哪個模組。<br />
<br />
=== 載入裝置模組 ===<br />
<br />
以 Google 搜尋正確的晶片組模組/驅動程式。常見的驅動模組有 Realtek 晶片組網卡的 {{ic|8139too}} ,或是 SiS 晶片組網卡的 {{ic|sis900}}。當您知道要使用何種模組了之後,試著[[Kernel modules#Manual module handling|手動將其載入]]。若您的到了錯誤訊息告訴您找不到該模組,則該驅動可能未包含於 Arch 核心中。您可以在 [[AUR]] 中搜尋該模組名稱。<br />
<br />
若 udev 未在開機期間檢測與載入正確的模組,請參閱 [[Kernel modules#Loading]]。<br />
<br />
== 網路介面 ==<br />
<br />
=== 裝置名稱 ===<br />
<br />
對於多網路卡的電腦,固定裝置名稱非常重要。許多設定問題都是因為介面卡名稱的改動造成的。<br />
<br />
[[udev]] 負責命名裝置。Systemd v197 則有[http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames 可預測之網路介面名稱]並可自動支配靜態名稱給網路裝置。介面名稱以 {{ic|en}} (乙太網路)、 {{ic|wl}} (無線網路) 或是 {{ic|ww}} (WWAN)作為前置字串並附上一個自動產生的識別名稱,進而產生了類似 {{ic|enp0s25}} 這樣的名稱。 <br />
<br />
要禁用這種行為,可以加上一個連接:<br />
<br />
# ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules<br />
<br />
自早期版本升級 systemd 的使用者會有一自動建立的空規則檔案。因此,若您想使用一貫的裝置名稱,只需要刪除該檔案。<br />
<br />
{{提示|您可以執行 {{ic|ip link}} 或是 {{ic|ls /sys/class/net}} 以列出所有可用的介面。}}<br />
<br />
{{注意|當您更改了介面名稱規則後,別忘了更新所有跟網路有關的組態檔案與自定的 systemd unit 檔案以因應該更改。特別是當您啟用了 [[netctl#Basic method|netctl 靜態設定檔]] ,請執行 {{ic|netctl reenable ''profile''}} 以更新所有產生的服務檔案。}}<br />
<br />
==== 更改裝置名稱 ====<br />
<br />
您可以使用 udev-rule 來手動定義裝置名稱。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"<br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"<br />
</nowiki>}}<br />
<br />
請注意這兩點:<br />
<br />
* 使用這個指令以取得 MAC 位置:{{ic|cat /sys/class/net/''device_name''/address}}。<br />
* 請確定 udev 規則中使用的是小寫的十六進位數值而不是大寫。<br />
<br />
若您的網路卡為動態 MAC ,您可以使用 DEVPATH ,例如:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"<br />
</nowiki>}}<br />
<br />
{{注意|當使用了靜態的名稱時,'''應該要避免使用類似 "eth''X''" 與 "wlan''X''"''' 這樣的名稱,因為這可能會導致核心與 udev 在開機時發生衝突。而剛好相反地,最好使用核心預設不會使用的介面名稱,如 {{ic|net0}} 、 {{ic|net1}} 、 {{ic|wifi0}} 、 {{ic|wifi1}} 。詳細說明請參閱 [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames systemd] 文件。}}<br />
<br />
=== 設定裝置的 MTU 與佇列長度 ===<br />
<br />
您可以手動定義 udev 規則來更改裝置的 MTU 與佇列長度。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1480", ATTR{tx_queue_len}="2000"<br />
</nowiki>}}<br />
<br />
=== 取得目前的裝置名稱 ===<br />
<br />
目前的 NIC 名稱可以通過 sysfs 找到<br />
<br />
{{hc|$ ls /sys/class/net|<br />
lo eth0 eth1 firewire0<br />
}}<br />
<br />
=== 啟用與禁用網路介面 ===<br />
<br />
您可以使用下列指令來啟用或禁用網路介面:<br />
<br />
# ip link set eth0 up<br />
# ip link set eth0 down<br />
<br />
要確認結果,請執行:<br />
<br />
{{hc|$ ip link show dev eth0|<br />
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000<br />
...<br />
}}<br />
<br />
== 組態設定 IP 位址 ==<br />
<br />
您有兩個選擇:使用 [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]] 指派動態位址,或是使用「靜態」的位址。<br />
<br />
=== 動態 IP 位址 ===<br />
<br />
==== 手動執行 DHCP 用戶端 Daemon ====<br />
<br />
{{注意|請特別注意 {{ic|dhcpcd}} (DHCP ''Client'' Daemon,DHCP 用戶端 Daemon) 與 {{ic|dhcpd}} (DHCP ''(server)'' daemon,DHCP 伺服端 Daemon) 間的差異。}}<br />
<br />
{{hc|# dhcpcd eth0|<br />
dhcpcd: version 5.1.1 starting<br />
dhcpcd: eth0: broadcasting for a lease<br />
...<br />
dhcpcd: eth0: leased 192.168.1.70 for 86400 seconds<br />
}}<br />
<br />
緊接著, {{ic|ip addr show dev eth0}} 應該要顯示出您的 inet 位址。<br />
<br />
對部分的人而言,{{ic|dhcpcd}} 失敗時,可以使用 {{ic|dhclient}} (位於 {{Pkg|dhclient}} 軟體包中)<br />
<br />
==== 於啟動時執行 DHCP ====<br />
<br />
若您只是想使用 DHCP 來連線至您的乙太網路連線,您可以使用 {{ic|dhcpcd@.service}} (由 {{Pkg|dhcpcd}} 軟體包提供)。<br />
<br />
要啟動 {{ic|eth0}} 上的 DHCP ,只需要使用:<br />
<br />
# systemctl start dhcpcd@eth0.service<br />
<br />
您可以下列方法啟用該服務讓其於開機時自動啟動:<br />
<br />
# systemctl enable dhcpcd@eth0.service<br />
<br />
若您用了 DHCP 且您並 '''不想''' 讓您的 DNS 伺服器在每次啟動您的網路時自動指派,請將下列內容加到 {{ic|dhcpcd.conf}} 的最後一段中:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nohook resolv.conf<br />
}}<br />
<br />
另外,若您位於基於 MAC 位址的用戶端 IP 位址進行過濾的 DHCPv4 網路,您可能需要修改下列內容:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 Client ID as per RFC4361. <br />
duid<br />
}}<br />
<br />
為:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the hardware address of the interface for the Client ID (DHCPv4).<br />
clientid<br />
}}<br />
<br />
否則,您可能會因為 DHCP 伺服器無法正確讀取您的 [http://en.wikipedia.org/wiki/DHCPv6 DHCPv6-style] 用戶端 ID 而無法使用。詳細請參閱 [http://tools.ietf.org/html/rfc4361 RFC 4361] 。<br />
<br />
為防止 {{ic|dhcpcd}} 加入網域名稱伺服器至 {{ic|/etc/resolv.conf}} 中,請於其中使用 {{ic|nooption}} 選項:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nooption domain_name_servers<br />
}}<br />
<br />
接著加入您自己的 DNS 名稱伺服器至 {{ic|/etc/resolv.conf}} 中。<br />
<br />
若有多個不同的執行緒要控制 {{ic|/etc/resolv.conf}} (如 {{Pkg|dhcpcd}} 與 VPN 用戶端),您可能會想要使用 {{Pkg|openresolv}} 軟體包。使用 {{Pkg|openresolv}} 並不需要額外地設定 {{Pkg|dhcpcd}} 。<br />
<br />
==== DHCP 靜態路由 ====<br />
若您需要加入靜態路由用戶端,請於 {{ic|/usr/lib/dhcpcd/dhcpcd-hooks}} 中建立一個新的 dhcpcd hook-script 。下列範例展示了加入靜態路由至一個通過閘道器為 192.168.192.5 ,位於 10.11.12.0/24 的 VPN 子網路:<br />
{{hc|/usr/lib/dhcpcd/dhcpcd-hooks/40-vpnroute|<br />
ip route add 10.11.12.0/24 via 192.168.192.5<br />
}}<br />
前置字串''40''表示其於 dhcpcd 啟動時的最後執行 hook-script 。<br />
<br />
=== 靜態 IP 位址 ===<br />
<br />
您可能因為各種原因而希望在您的網路中指派靜態 IP 位址,例如靜態的位址可以獲得一定程度的可預測性,或是您沒有可用的 DHCP 伺服器。<br />
<br />
{{注意|若您共通過 Windows 機器共享您的網路而沒有路由器,請確保兩台電腦皆使用了靜態 IP 位址以避免區域網路問題。}}<br />
<br />
您需要:<br />
<br />
* 靜態 IP 位址<br />
* [[Wikipedia:Subnetwork|子網路遮罩]]<br />
* [[Wikipedia:Broadcast_address|廣播位址]]<br />
* [[Wikipedia:Default_gateway|閘道器]]的 IP 位址<br />
<br />
若您處在內部網路中,使用 192.168.*.* 這樣的 IP 位址較為安全,搭配其的子網路遮罩 255.255.255.0 ,廣播位址為 192.168.*.255 。而閘道器通常是 192.168.*.1 或是 192.168.*.254 。<br />
<br />
==== 手動指派 ====<br />
<br />
您可於控制台中指派一靜態 IP 位址:<br />
<br />
# ip addr add <IP 位址>/<子網路遮罩> broadcast <廣播> dev <介面><br />
<br />
舉例來說:<br />
<br />
# ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev eth0<br />
<br />
{{注意|子網路遮罩使用了 [[Wikipedia:CIDR_notation|CIDR 表示法]](CIDR,Classless Inter-Domain Routing,無類別網路間路由)。}}<br />
<br />
詳情請參閱 {{ic|man ip}} 。<br />
<br />
以類似下列方法加上您的閘道器:<br />
<br />
# ip route add default via <預設閘道器 IP 位址><br />
<br />
舉例來說:<br />
<br />
# ip route add default via 192.168.1.1<br />
<br />
若您得到了 "No such process" 這樣的錯誤訊息,這代表您必須以 root 執行 {{ic|ip link set dev eth0 up}} 。<br />
<br />
==== 於啟動時通過 systemd 手動連線 ====<br />
<br />
先確保 dhcpcd 已停止並禁用:<br />
<br />
# systemctl status dhcpcd.service<br />
<br />
接著為 [[systemd]] 服務建立一個檔案。以正確的網路介面名稱取代其中的 {{ic|<interface>}} :<br />
<br />
{{hc|/etc/conf.d/network@<interface>|<nowiki><br />
address=192.168.0.15<br />
netmask=24<br />
broadcast=192.168.0.255<br />
gateway=192.168.0.1<br />
</nowiki>}}<br />
<br />
建立 systemd unit 檔案:<br />
<br />
{{hc|/etc/systemd/system/network@.service|<nowiki><br />
[Unit]<br />
Description=Network connectivity (%i)<br />
Wants=network.target<br />
Before=network.target<br />
BindsTo=sys-subsystem-net-devices-%i.device<br />
After=sys-subsystem-net-devices-%i.device<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
EnvironmentFile=/etc/conf.d/network@%i<br />
<br />
ExecStart=/usr/bin/ip link set dev %i up<br />
ExecStart=/usr/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i<br />
ExecStart=/usr/bin/ip route add default via ${gateway}<br />
<br />
ExecStop=/usr/bin/ip addr flush dev %i<br />
ExecStop=/usr/bin/ip link set dev %i down<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
啟用該 unit 並將其啟動,傳入介面名稱,例如 eno1 :<br />
<br />
# systemctl enable network@eno1.service<br />
# systemctl start network@eno1.service<br />
<br />
若您需要手動設定 nameservers ,請編輯 {{ic|/etc/resolv.conf}} 檔案:<br />
<br />
{{hc|/etc/resolv.conf|<br />
nameserver 208.67.222.222<br />
nameserver 208.67.220.220}}<br />
<br />
若 {{ic|/etc/resolv.conf}} 被持續遭到複寫,請參考 [[Resolv.conf]] 以瞭解如何解決此問題。<br />
<br />
有幾個類似的方法來讓 systemd 啟動網路,其中的差異為檔案內容,並且其可以寫死 EnvironmentFile 定義的參考檔案中抓到的參數。因此可以作為一種替代的,將介面名稱放置於 /etc/conf.d/ 中的 EnvironmentFile 接著直接使用介面名稱而不是 %i 。如此一來,檔案名稱便不需要「@」。這也是一種有用的方法來閱讀 http://www.freedesktop.org/software/systemd/man/systemd.unit.html 上的 systemd 服務文件。<br />
<br />
==== 計算位址 ====<br />
<br />
您可以使用 {{Pkg|ipcalc}} 提供的 {{ic|ipcalc}} 來計算 IP 廣播、網域、子網路遮罩與主機範圍等進階設定舉例來說,我使用了位於防火牆後的乙太網路來連線 Windows 機器至 Arch。為了安全性與網路組織,我將他們放置於各自獨立的網路,接著組態設定子網路遮罩與廣播位址,如此一來網路中就只有兩台機器。為了找出子網路遮罩跟廣播位址,我使用了 ipcalc ,提供其 Arch firewire nic 的 IP 位址 10.66.66.1 ,並指定 ipcalc 要建立一個只有兩台主機的網路。<br />
<br />
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|<nowiki><br />
Address: 10.66.66.1<br />
<br />
Netmask: 255.255.255.252 = 30<br />
Network: 10.66.66.0/30<br />
HostMin: 10.66.66.1<br />
HostMax: 10.66.66.2<br />
Broadcast: 10.66.66.3<br />
Hosts/Net: 2 Class A, Private Internet<br />
</nowiki>}}<br />
<br />
== 載入組態設定 ==<br />
<br />
要測試您的設定,您可以重新啟動電腦或是重新載入相關的 systemd 服務:<br />
<br />
# systemctl restart dhcpcd@eth0<br />
<br />
您可以試著 ping 您的閘道器、 DNS 伺服器、 ISP 提供商或是其他網路上的站台。如此一來便可以確認您的網路連線問題為何,例如:<br />
<br />
$ ping -c 3 www.google.com<br />
<br />
== 附加設定 ==<br />
<br />
=== 筆記型電腦之 ifplugd ===<br />
<br />
{{Tip|{{Pkg|dhcpcd}} provides the same feature out of the box.}}<br />
<br />
{{Pkg|ifplugd}} in [[Official Repositories]] is a daemon which will automatically configure your Ethernet device when a cable is plugged in and automatically unconfigure it if the cable is pulled. This is useful on laptops with onboard network adapters, since it will only configure the interface when a cable is really connected. Another use is when you just need to restart the network but do not want to restart the computer or do it from the shell.<br />
<br />
By default it is configured to work for the {{ic|eth0}} device. This and other settings like delays can be configured in {{ic|/etc/ifplugd/ifplugd.conf}}.<br />
<br />
{{Note|[[Netctl]] package includes {{ic|netctl-ifplugd@.service}}, otherwise you can use {{ic|ifplugd@.service}} from {{Pkg|ifplugd}} package. Use for example {{ic|systemctl enable ifplugd@eth0.service}}.}}<br />
<br />
=== Bonding 或 LAG ===<br />
<br />
請參閱 [[netctl#Bonding]] 。<br />
<br />
=== IP 別名 ===<br />
<br />
{{Expansion|Manual method using [[Core Utilities#ip|ip]] should be added; then move current example using ''netctl'' into [[netctl]].}}<br />
<br />
IP 別名為讓同一個網路介面有多個 IP 位址。如此一來,單個節點的網路就能有多個網路連線,進而實現不同的作用。經典的使用方法為網頁與 FTP 伺服器的虛擬主機,或是重組伺服器而無需更新任何其他的機器(對於名稱伺服器來說特別有用)。<br />
<br />
==== 範例 ====<br />
<br />
您將需要來自[[Official Repositories|官方軟體套件庫]]的 {{Pkg|netctl}} 。<br />
<br />
準備組態設定檔:<br />
<br />
{{hc|/etc/netctl/mynetwork|<nowiki><br />
Connection='ethernet'<br />
Description='Five different addresses on the same NIC.'<br />
Interface='eth0'<br />
IP='static'<br />
Address=('192.168.1.10' '192.168.178.11' '192.168.1.12' '192.168.1.13' '192.168.1.14' '192.168.1.15')<br />
Gateway='192.168.1.1'<br />
DNS=('192.168.1.1')<br />
</nowiki>}}<br />
<br />
接著只需要將其執行:<br />
<br />
$ netctl start mynetwork<br />
<br />
=== 更改 MAC/硬體 位址 ===<br />
<br />
請參閱 [[MAC Address Spoofing]] 。<br />
<br />
=== Internet Sharing ===<br />
<br />
請參閱 [[Internet Sharing]] 。<br />
<br />
=== Router Configuration ===<br />
<br />
請參閱 [[Router]] 。<br />
<br />
=== 區域網路主機名稱解析 ===<br />
<br />
The pre-requisite is to [[#Set the hostname]] after which hostname resolution works on the local system itself {{hc|$ ping hostname|<br />
PING hostname <nowiki>(192.168.1.2) 56(84) bytes of data.<br />
64 bytes from hostname (192.168.1.2): icmp_seq=1 ttl=64 time=0.043 ms</nowiki>}}<br />
To enable other machines to address the host by name, either a manual configuration of the respective {{ic|/etc/hosts}} files or a service to propagate/resolve the name is required. <br />
<br />
When setting up a DNS server such as [[BIND]] or [[Unbound]] is overkill, manually editing your {{ic|/etc/hosts}} is too cumbersome, or when you want more flexibility with dynamic leaving and joining of hosts to the network, it is possible to handle hostname resolution on your local network using zero-configuration networking. There are two options available:<br />
<br />
*[[Samba]] provides hostname resolution via Microsoft's '''NetBIOS'''. It only requires installation of {{Pkg|samba}} and enabling of the {{ic|nmbd.service}} service. Computers running Windows, OS X, or Linux with {{ic|nmbd}} running, will be able to find your machine.<br />
<br />
*[[Avahi]] provides hostname resolution via '''zeroconf''', also known as Avahi or Bonjour. It requires slightly more complex configuration than Samba: see [[Avahi#Hostname resolution]] for details. Computers running OS X, or Linux with an Avahi daemon running, will be able to find your machine. Windows does not have an built-in Avahi client or daemon.<br />
<br />
== 診斷 ==<br />
<br />
=== Swapping computers on the cable modem ===<br />
<br />
Some cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.<br />
<br />
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].<br />
<br />
=== The TCP window scaling problem ===<br />
<br />
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.<br />
<br />
Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html RFC 1323] was written to improve the situation: Window Scaling. The "window" value, provided in all packets, will be modified by a Scale Factor defined once, at the very beginning of the connection.<br />
<br />
That 8-bit Scale Factor allows the Window to be up to 32 times higher than the initial 64Kb.<br />
<br />
It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts.<br />
<br />
The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.<br />
<br />
The resulting connection is at best very slow or broken.<br />
<br />
==== How to diagnose the problem ====<br />
<br />
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).<br />
<br />
When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|ip addr}} will report normal status... and actually everything appears normal.<br />
<br />
If you cannot browse any website, but you can ping some random hosts, chances are great that you're experiencing this problem: ping uses ICMP and is not affected by TCP problems.<br />
<br />
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).<br />
<br />
==== How to fix it (The bad way) ====<br />
<br />
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.<br />
<br />
# echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem<br />
<br />
==== How to fix it (The good way) ====<br />
<br />
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.d/99-disable_window_scaling.conf}} (see also [[sysctl]])<br />
<br />
net.ipv4.tcp_window_scaling = 0<br />
<br />
==== How to fix it (The best way) ====<br />
<br />
This problem is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.<br />
<br />
==== More about it ====<br />
<br />
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].<br />
<br />
There are also several relevant threads on the LKML.<br />
<br />
=== Realtek no link / WOL problem ===<br />
<br />
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice a problem where the NIC seems to be disabled on boot and has no Link light. This can usually be found on a dual boot system where Windows is also installed. It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause. These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots. You will be able to notice if this problem is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off. Normal operation should be that the link light is always on as long as the system is on, even during POST. This problem will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this problem:<br />
<br />
==== Method 1 - Rollback/change Windows driver ====<br />
<br />
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).<br />
<br />
==== Method 2 - Enable WOL in Windows driver ====<br />
<br />
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems). In Windows, under Device Manager, find your Realtek network adapter and double-click it. Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.<br />
<br />
In Windows XP (example)<br />
Right click my computer<br />
--> Hardware tab<br />
--> Device Manager<br />
--> Network Adapters<br />
--> "double click" Realtek ...<br />
--> Advanced tab<br />
--> Wake-On-Lan After Shutdown<br />
--> Enable<br />
<br />
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{ic|Disable}} has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.}}<br />
<br />
==== Method 3 - Newer Realtek Linux driver ====<br />
<br />
Any newer driver for these Realtek cards can be found for Linux on the realtek site. (untested but believed to also solve the problem).<br />
<br />
==== Method 4 - Enable ''LAN Boot ROM'' in BIOS/CMOS ====<br />
<br />
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.<br />
<br />
{{Note|This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.}}<br />
<br />
=== DLink G604T/DLink G502T DNS problem ===<br />
<br />
Users with a DLink G604T/DLink G502T router, using DHCP and have firmware v2.00+ (typically users with AUS firmware) may have problems with certain programs not resolving the DNS. One of these programs are unfortunatley pacman. The problem is basically the router in certain situations is not sending the DNS properly to DHCP, which causes programs to try and connect to servers with an IP address of 1.0.0.0 and fail with a connection timed out error<br />
<br />
==== How to diagnose the problem ====<br />
<br />
The best way to diagnose the problem is to use Firefox/Konqueror/links/seamonkey and to enable wget for pacman. If this is a fresh install of Arch Linux, then you may want to consider installing {{ic|links}} through the live CD.<br />
<br />
Firstly, enable wget for pacman (since it gives us info about pacman when it is downloading packages)<br />
Open {{ic|/etc/pacman.conf}} with your favourite editor and uncomment the following line (remove the # if it is there)<br />
<br />
XferCommand=/usr/bin/wget --passive-ftp -c -O %o %u<br />
<br />
While you are editing {{ic|/etc/pacman.conf}}, check the default mirror that pacman uses to download packages.<br />
<br />
Now open up the default mirror in an Internet browser to see if the mirror actually works. If it does work, then do {{ic|pacman -Syy}} (otherwise pick another working mirror and set it to the pacman default). If you get something similar to the following (notice the 1.0.0.0),<br />
<br />
<nowiki>ftp://mirror.pacific.net.au/linux/archlinux/extra/os/i686/extra.db.tar.gz</nowiki><br />
=> '/var/lib/pacman/community.db.tar.gz.part'<br />
Resolving mirror.pacific.net.au... 1.0.0.0<br />
<br />
then you most likely have this problem. The 1.0.0.0 means it is unable to resolve DNS, so we must add it to {{ic|/etc/resolv.conf}}.<br />
<br />
==== How to fix it ====<br />
<br />
{{Out of date|{{Pkg|dhcpcd}} does not use {{ic|/etc/conf.d/dhcpcd}} any more.}}<br />
<br />
Basically what we need to do is to manually add the DNS servers to our {{ic|/etc/resolv.conf}} file. The problem is that DHCP automatically deletes and replaces this file on boot, so we need to edit {{ic|/etc/conf.d/dhcpcd}} and change the flags to stop DHCP from doing this.<br />
<br />
When you open {{ic|/etc/conf.d/dhcpcd}}, you should see something close to the following:<br />
<br />
DHCPCD_ARGS="-t 30 -h $HOSTNAME"<br />
<br />
Add the {{ic|-R}} flag to the arguments, e.g.,<br />
<br />
DHCPCD_ARGS="-R -t 30 -h $HOSTNAME"<br />
<br />
{{Note|1=If you are using {{Pkg|dhcpcd}} >= 4.0.2, the {{ic|-R}} flag has been deprecated. Please see the [[#Run DHCP at boot]] section for information on how to use a custom {{ic|/etc/resolv.conf}} file.}}<br />
<br />
Save and close the file; now open {{ic|/etc/resolv.conf}}. You should see a single nameserver (most likely 10.1.1.1). This is the gateway to your router, which we need to connect to in order to get the DNS servers of your ISP. Paste the IP address into your browser and log in to your router. Go to the DNS section, and you should see an IP address in the Primary DNS Server field; copy it and paste it as a nameserver '''ABOVE''' the current gateway one.<br />
<br />
For example, {{ic|/etc/resolv.conf}} should look something along the lines of:<br />
<br />
nameserver 10.1.1.1<br />
<br />
If my primary DNS server is 211.29.132.12, then change {{ic|/etc/resolv.conf}} to:<br />
<br />
nameserver 211.29.132.12<br />
nameserver 10.1.1.1<br />
<br />
Now restart the network daemon by running {{ic|systemctl restart dhcpcd@<interface>}} and do {{ic|pacman -Syy}}. If it syncs correctly with the server, then the problem is solved.<br />
<br />
==== More about it ====<br />
<br />
This is the whirlpool forum (Australian ISP community) which talks about and gives the same solution to the problem:<br />
<br />
http://forums.whirlpool.net.au/forum-replies-archive.cfm/461625.html<br />
<br />
=== Check DHCP problem by releasing IP first ===<br />
<br />
Problem may occur when DHCP get wrong IP assignment. For example when two routers are tied together through VPN. The router that is connected to me by VPN may assigning IP address. To fix it. On a console, as root, release IP address:<br />
<br />
# dhcpcd -k<br />
<br />
Then request a new one:<br />
<br />
# dhcpcd<br />
<br />
Maybe you had to run those two commands many times.<br />
<br />
=== No eth0 with Atheros AR8161 ===<br />
<br />
{{Note|With the 3.10.2-1-ARCH kernel update, the alx ethernet driver module is included in the package.}}<br />
<br />
With the Atheros AR8161 Gigabit Ethernet card, the ethernet connection is not working out-of-the-box (with the installation media of March 2013). The module "alx" needs to be loaded but is not present.<br />
<br />
The driver from [http://linuxwireless.org/en/users/Download/stable/#compat-wireless_stable_releases compat-wireless] (that has become [https://backports.wiki.kernel.org/index.php/Releases compat-drives] since linux 3.7) need to be installed. The "-u" postfix annotates that Qualcomm have applied a driver under a unified driver.<br />
<br />
$ wget https://www.kernel.org/pub/linux/kernel/projects/backports/2013/03/28/compat-drivers-2013-03-28-5-u.tar.bz2<br />
$ tar xjf compat*<br />
$ cd compat*<br />
$ ./scripts/driver-select alx<br />
$ make<br />
$ sudo make install<br />
$ sudo modprobe alx<br />
<br />
The alx driver has not been added to Linux kernel due to various problems. Compatibility between the different kernel versions has been spotty. For better support follow the [http://lists.infradead.org/mailman/listinfo/unified-drivers mailing list]and [http://www.linuxfoundation.org/collaborate/workgroups/networking/alx alx page]for latest working solution for alx.<br />
<br />
The driver must be built and installed after every kernel change.<br />
<br />
Alternatively you can use the AUR package for [https://aur.archlinux.org/packages/compat-drivers-patched/ compat drivers], which installs many other drivers.<br />
<br />
=== No eth0 with Atheros AR9485 ===<br />
<br />
The ethernet (eth0) for Atheros AR9485 are not working out-of-the-box (with installation media of March 2013). The working solution for this is to install the package [https://aur.archlinux.org/packages/compat-drivers-patched/ compat-drivers-patched] from AUR.<br />
<br />
=== No carrier / no connection after suspend ===<br />
After suspend to RAM no connection is found although the network cable is plugged in. <br />
This may be caused by PCI power management. What is the output of<br />
<br />
# ip link show eth0<br />
<br />
If the line contains "NO-CARRIER" even though there's a cable connected to your eth0 port, it is possible that the device was auto-suspended and the media sense feature doesn't work. To solve this, first you need to find your ethernet controllers PCI address by<br />
<br />
# lspci<br />
<br />
This should look similar to this:<br />
<br />
...<br />
00:19.0 Ethernet controller: Intel Corporation 82577LM Gigabit Network Connection (rev 06)<br />
...<br />
<br />
So the address is 00:19.0.<br />
Now check the PM status of the device by issuing<br />
<br />
# cat "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
substituting 00:19.0 with the address obtained from lspci.<br />
If the output reads "auto", you can try to bring the device out of suspend by<br />
<br />
# echo on > "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
Don't forget to substitute the address again.<br />
<br />
{{Note|1=This appears to be a bug in kernel 3.8.4.1- (3.8.8.1 is still affected): [https://bbs.archlinux.org/viewtopic.php?id=159837&p=2 Forum discussion.] It also appears a fix is [https://lkml.org/lkml/2013/1/18/147 on the way. (It will be likely fixed in 3.9.)] In the meantime, the above is a suitable workaround.}}<br />
<br />
=== Broadcom BCM57780 ===<br />
<br />
This Broadcom chipset sometimes does not behave well unless you specify the order of the modules to be loaded. The modules are {{ic|broadcom}} and {{ic|tg3}}, the former needing to be loaded first.<br />
<br />
These steps should help if your computer has this chipset:<br />
$ lspci | grep Ethernet<br />
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)<br />
<br />
If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following (as root):<br />
# modprobe -r tg3<br />
# modprobe broadcom<br />
# modprobe tg3<br />
<br />
Now plug you network cable in. If this solves your problems you can make this permanent by adding {{ic|broadcom}} and {{ic|tg3}} (in this order) to the {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}}:<br />
<br />
MODULES=".. broadcom tg3 .."<br />
<br />
Then rebuild the initramfs:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|These methods may work for other chipsets, such as BCM57760.}}</div>Binotahttps://wiki.archlinux.org/index.php?title=Network_configuration_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=293541Network configuration (正體中文)2014-01-19T09:40:21Z<p>Binota: /* IP 別名 */ Translated</p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:Networking (正體中文)]]<br />
[[Category:Getting and installing Arch (正體中文)]]<br />
<br />
[[cs:Configuring Network]]<br />
[[el:Configuring Network]]<br />
[[es:Configuring Network]]<br />
[[fr:Connexions reseau]]<br />
[[it:Configuring Network]]<br />
[[ja:Network Configuration]]<br />
[[nl:Configuring Network]]<br />
[[pt:Configuring Network]]<br />
[[ro:Configurare retea]]<br />
[[ru:Configuring Network]]<br />
[[sk:Configuring Network]]<br />
[[tr:Ağ_Yapılandırması]]<br />
[[zh-CN:Network Configuration]]<br />
[[zh-TW:Network Configuration]]<br />
{{Related articles start}}<br />
{{Related|Jumbo Frames}}<br />
{{Related|Firewalls}}<br />
{{Related|Wireless Setup}}<br />
{{Related|List of Applications#Network Managers}}<br />
{{Related articles end}}<br />
<br />
本頁將介紹如何設定 '''有線''' 網路連線。若您需要設定 '''無線''' 網路,請參考[[Wireless Setup|無線網路設定]]。<br />
<br />
== 檢查連線 ==<br />
<br />
{{注意|若您在執行 ping 時收到了類似 {{ic|ping: icmp open socket: Operation not permitted}} 這樣的錯誤訊息,請嘗試重新安裝 {{ic|iputils}} 軟體包。}} <br />
<br />
一般來說,基本的安裝過程都已經建立了可運作的網路設定。請執行下列指令以進行檢查:<br />
<br />
{{注意|{{ic|-c 3}} 選項表示將會呼叫三次。詳細請參閱 {{ic|man ping}} 。}}<br />
{{注意|您也可以嘗試使用其他的 Domain ,如 www.hinet.net 。}}<br />
<br />
{{hc|$ ping -c 3 www.google.com|<nowiki><br />
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.<br />
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms<br />
64 bytes from 74.125.224.146: icmp_req=2 ttl=50 time=385 ms<br />
64 bytes from 74.125.224.146: icmp_req=3 ttl=50 time=298 ms<br />
<br />
--- www.l.google.com ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 1999ms<br />
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms<br />
</nowiki>}}<br />
<br />
如果沒問題的話,您可能只是想以本文的下列部分來自定您的設定。<br />
<br />
若剛才的指令出現了 unknown hosts 之類的訊息,代表您的機器無法解析網域。這可能是因為您的網路服務提供商/網關造成的。您可以嘗試 ping 一個靜態 IP 以實驗您的機器可否存取網際網路。<br />
{{注意|您也可以嘗試使用其他的 IP ,如 168.95.1.1 。}}<br />
<br />
{{hc|$ ping -c 3 8.8.8.8|<nowiki><br />
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.<br />
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms<br />
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms<br />
64 bytes from 8.8.8.8: icmp_req=3 ttl=53 time=70.6 ms<br />
<br />
--- 8.8.8.8 ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 2002ms<br />
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms<br />
</nowiki>}}<br />
<br />
{{注意|{{ic|8.8.8.8}} 為一個好記的靜態 IP 位置。這是 Google 的主要 DNS 伺服器,這表示其有一定的可信度,並且通常不會被系統或代理伺服器擋下。}}<br />
<br />
若您可以 ping 通該位置,您可能需要試著在 {{ic|/etc/resolv.conf}} 檔案中加上網域名稱伺服器。<br />
<br />
== 設定主機名稱 ==<br />
<br />
[[Wikipedia:Hostname|主機名稱]]為網路中用於識別機器的唯一識別名稱:主機名稱可以通過 {{ic|/etc/hostname}} 檔案來進行設定。一般來說該檔案包含了系統的網域名稱。下面為設定主機名稱的方法:<br />
<br />
# hostnamectl set-hostname '''myhostname'''<br />
<br />
這樣會將 '''myhostname''' 寫入 {{ic|/etc/hostname}} 檔案中。<br />
<br />
詳細請參閱 {{ic|man 5 hostname}} 與 {{ic|man 1 hostnamectl}} 。<br />
<br />
{{注意|<br />
* {{ic|hostnamectl}} 支援 FQDN<br />
* 您不需要編輯 {{ic|/etc/hosts}} 檔案,{{pkg|systemd}} 會提供主機名稱解析且預設安裝於所有系統。<br />
}}<br />
<br />
使用來自 {{Pkg|inetutils}} 的 {{ic|hostname}} 指令以設定臨時主機名稱(直到重新啟動):<br />
<br />
# hostname ''myhostname''<br />
<br />
== 裝置驅動程式 ==<br />
<br />
=== 檢查驅動程式狀態 ===<br />
<br />
[[udev]] 應該會檢測您的網路介面卡([[Wikipedia:Network_interface_controller|NIC]])並自動於啟動時載入必要的模組。檢查 {{ic|lspci -v}} 輸出內容中的「Ethernet controller」 項目(或類似的)。這應該會告訴您哪些核心模組包含了網路設備的驅動程式。舉例來說:<br />
<br />
{{hc|$ lspci -v|<br />
02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)<br />
...<br />
Kernel driver in use: atl1<br />
Kernel modules: atl1<br />
}}<br />
<br />
接下來,確認該驅動程式已經通過 {{ic|dmesg <nowiki>|</nowiki> grep ''module_name''}} 載入了。舉例來說:<br />
<br />
$ dmesg | grep atl1<br />
...<br />
atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex<br />
<br />
若驅動程式已成功加載可以跳過接下來這段。否則,您會需要知道哪些模組時您的特定型號的裝置需要哪個模組。<br />
<br />
=== 載入裝置模組 ===<br />
<br />
以 Google 搜尋正確的晶片組模組/驅動程式。常見的驅動模組有 Realtek 晶片組網卡的 {{ic|8139too}} ,或是 SiS 晶片組網卡的 {{ic|sis900}}。當您知道要使用何種模組了之後,試著[[Kernel modules#Manual module handling|手動將其載入]]。若您的到了錯誤訊息告訴您找不到該模組,則該驅動可能未包含於 Arch 核心中。您可以在 [[AUR]] 中搜尋該模組名稱。<br />
<br />
若 udev 未在開機期間檢測與載入正確的模組,請參閱 [[Kernel modules#Loading]]。<br />
<br />
== 網路介面 ==<br />
<br />
=== 裝置名稱 ===<br />
<br />
對於多網路卡的電腦,固定裝置名稱非常重要。許多設定問題都是因為介面卡名稱的改動造成的。<br />
<br />
[[udev]] 負責命名裝置。Systemd v197 則有[http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames 可預測之網路介面名稱]並可自動支配靜態名稱給網路裝置。介面名稱以 {{ic|en}} (乙太網路)、 {{ic|wl}} (無線網路) 或是 {{ic|ww}} (WWAN)作為前置字串並附上一個自動產生的識別名稱,進而產生了類似 {{ic|enp0s25}} 這樣的名稱。 <br />
<br />
要禁用這種行為,可以加上一個連接:<br />
<br />
# ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules<br />
<br />
自早期版本升級 systemd 的使用者會有一自動建立的空規則檔案。因此,若您想使用一貫的裝置名稱,只需要刪除該檔案。<br />
<br />
{{提示|您可以執行 {{ic|ip link}} 或是 {{ic|ls /sys/class/net}} 以列出所有可用的介面。}}<br />
<br />
{{注意|當您更改了介面名稱規則後,別忘了更新所有跟網路有關的組態檔案與自定的 systemd unit 檔案以因應該更改。特別是當您啟用了 [[netctl#Basic method|netctl 靜態設定檔]] ,請執行 {{ic|netctl reenable ''profile''}} 以更新所有產生的服務檔案。}}<br />
<br />
==== 更改裝置名稱 ====<br />
<br />
您可以使用 udev-rule 來手動定義裝置名稱。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"<br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"<br />
</nowiki>}}<br />
<br />
請注意這兩點:<br />
<br />
* 使用這個指令以取得 MAC 位置:{{ic|cat /sys/class/net/''device_name''/address}}。<br />
* 請確定 udev 規則中使用的是小寫的十六進位數值而不是大寫。<br />
<br />
若您的網路卡為動態 MAC ,您可以使用 DEVPATH ,例如:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"<br />
</nowiki>}}<br />
<br />
{{注意|當使用了靜態的名稱時,'''應該要避免使用類似 "eth''X''" 與 "wlan''X''"''' 這樣的名稱,因為這可能會導致核心與 udev 在開機時發生衝突。而剛好相反地,最好使用核心預設不會使用的介面名稱,如 {{ic|net0}} 、 {{ic|net1}} 、 {{ic|wifi0}} 、 {{ic|wifi1}} 。詳細說明請參閱 [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames systemd] 文件。}}<br />
<br />
=== 設定裝置的 MTU 與佇列長度 ===<br />
<br />
您可以手動定義 udev 規則來更改裝置的 MTU 與佇列長度。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1480", ATTR{tx_queue_len}="2000"<br />
</nowiki>}}<br />
<br />
=== 取得目前的裝置名稱 ===<br />
<br />
目前的 NIC 名稱可以通過 sysfs 找到<br />
<br />
{{hc|$ ls /sys/class/net|<br />
lo eth0 eth1 firewire0<br />
}}<br />
<br />
=== 啟用與禁用網路介面 ===<br />
<br />
您可以使用下列指令來啟用或禁用網路介面:<br />
<br />
# ip link set eth0 up<br />
# ip link set eth0 down<br />
<br />
要確認結果,請執行:<br />
<br />
{{hc|$ ip link show dev eth0|<br />
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000<br />
...<br />
}}<br />
<br />
== 組態設定 IP 位址 ==<br />
<br />
您有兩個選擇:使用 [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]] 指派動態位址,或是使用「靜態」的位址。<br />
<br />
=== 動態 IP 位址 ===<br />
<br />
==== 手動執行 DHCP 用戶端 Daemon ====<br />
<br />
{{注意|請特別注意 {{ic|dhcpcd}} (DHCP ''Client'' Daemon,DHCP 用戶端 Daemon) 與 {{ic|dhcpd}} (DHCP ''(server)'' daemon,DHCP 伺服端 Daemon) 間的差異。}}<br />
<br />
{{hc|# dhcpcd eth0|<br />
dhcpcd: version 5.1.1 starting<br />
dhcpcd: eth0: broadcasting for a lease<br />
...<br />
dhcpcd: eth0: leased 192.168.1.70 for 86400 seconds<br />
}}<br />
<br />
緊接著, {{ic|ip addr show dev eth0}} 應該要顯示出您的 inet 位址。<br />
<br />
對部分的人而言,{{ic|dhcpcd}} 失敗時,可以使用 {{ic|dhclient}} (位於 {{Pkg|dhclient}} 軟體包中)<br />
<br />
==== 於啟動時執行 DHCP ====<br />
<br />
若您只是想使用 DHCP 來連線至您的乙太網路連線,您可以使用 {{ic|dhcpcd@.service}} (由 {{Pkg|dhcpcd}} 軟體包提供)。<br />
<br />
要啟動 {{ic|eth0}} 上的 DHCP ,只需要使用:<br />
<br />
# systemctl start dhcpcd@eth0.service<br />
<br />
您可以下列方法啟用該服務讓其於開機時自動啟動:<br />
<br />
# systemctl enable dhcpcd@eth0.service<br />
<br />
若您用了 DHCP 且您並 '''不想''' 讓您的 DNS 伺服器在每次啟動您的網路時自動指派,請將下列內容加到 {{ic|dhcpcd.conf}} 的最後一段中:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nohook resolv.conf<br />
}}<br />
<br />
另外,若您位於基於 MAC 位址的用戶端 IP 位址進行過濾的 DHCPv4 網路,您可能需要修改下列內容:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 Client ID as per RFC4361. <br />
duid<br />
}}<br />
<br />
為:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the hardware address of the interface for the Client ID (DHCPv4).<br />
clientid<br />
}}<br />
<br />
否則,您可能會因為 DHCP 伺服器無法正確讀取您的 [http://en.wikipedia.org/wiki/DHCPv6 DHCPv6-style] 用戶端 ID 而無法使用。詳細請參閱 [http://tools.ietf.org/html/rfc4361 RFC 4361] 。<br />
<br />
為防止 {{ic|dhcpcd}} 加入網域名稱伺服器至 {{ic|/etc/resolv.conf}} 中,請於其中使用 {{ic|nooption}} 選項:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nooption domain_name_servers<br />
}}<br />
<br />
接著加入您自己的 DNS 名稱伺服器至 {{ic|/etc/resolv.conf}} 中。<br />
<br />
若有多個不同的執行緒要控制 {{ic|/etc/resolv.conf}} (如 {{Pkg|dhcpcd}} 與 VPN 用戶端),您可能會想要使用 {{Pkg|openresolv}} 軟體包。使用 {{Pkg|openresolv}} 並不需要額外地設定 {{Pkg|dhcpcd}} 。<br />
<br />
==== DHCP 靜態路由 ====<br />
若您需要加入靜態路由用戶端,請於 {{ic|/usr/lib/dhcpcd/dhcpcd-hooks}} 中建立一個新的 dhcpcd hook-script 。下列範例展示了加入靜態路由至一個通過閘道器為 192.168.192.5 ,位於 10.11.12.0/24 的 VPN 子網路:<br />
{{hc|/usr/lib/dhcpcd/dhcpcd-hooks/40-vpnroute|<br />
ip route add 10.11.12.0/24 via 192.168.192.5<br />
}}<br />
前置字串''40''表示其於 dhcpcd 啟動時的最後執行 hook-script 。<br />
<br />
=== 靜態 IP 位址 ===<br />
<br />
您可能因為各種原因而希望在您的網路中指派靜態 IP 位址,例如靜態的位址可以獲得一定程度的可預測性,或是您沒有可用的 DHCP 伺服器。<br />
<br />
{{注意|若您共通過 Windows 機器共享您的網路而沒有路由器,請確保兩台電腦皆使用了靜態 IP 位址以避免區域網路問題。}}<br />
<br />
您需要:<br />
<br />
* 靜態 IP 位址<br />
* [[Wikipedia:Subnetwork|子網路遮罩]]<br />
* [[Wikipedia:Broadcast_address|廣播位址]]<br />
* [[Wikipedia:Default_gateway|閘道器]]的 IP 位址<br />
<br />
若您處在內部網路中,使用 192.168.*.* 這樣的 IP 位址較為安全,搭配其的子網路遮罩 255.255.255.0 ,廣播位址為 192.168.*.255 。而閘道器通常是 192.168.*.1 或是 192.168.*.254 。<br />
<br />
==== 手動指派 ====<br />
<br />
您可於控制台中指派一靜態 IP 位址:<br />
<br />
# ip addr add <IP 位址>/<子網路遮罩> broadcast <廣播> dev <介面><br />
<br />
舉例來說:<br />
<br />
# ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev eth0<br />
<br />
{{注意|子網路遮罩使用了 [[Wikipedia:CIDR_notation|CIDR 表示法]](CIDR,Classless Inter-Domain Routing,無類別網路間路由)。}}<br />
<br />
詳情請參閱 {{ic|man ip}} 。<br />
<br />
以類似下列方法加上您的閘道器:<br />
<br />
# ip route add default via <預設閘道器 IP 位址><br />
<br />
舉例來說:<br />
<br />
# ip route add default via 192.168.1.1<br />
<br />
若您得到了 "No such process" 這樣的錯誤訊息,這代表您必須以 root 執行 {{ic|ip link set dev eth0 up}} 。<br />
<br />
==== 於啟動時通過 systemd 手動連線 ====<br />
<br />
先確保 dhcpcd 已停止並禁用:<br />
<br />
# systemctl status dhcpcd.service<br />
<br />
接著為 [[systemd]] 服務建立一個檔案。以正確的網路介面名稱取代其中的 {{ic|<interface>}} :<br />
<br />
{{hc|/etc/conf.d/network@<interface>|<nowiki><br />
address=192.168.0.15<br />
netmask=24<br />
broadcast=192.168.0.255<br />
gateway=192.168.0.1<br />
</nowiki>}}<br />
<br />
建立 systemd unit 檔案:<br />
<br />
{{hc|/etc/systemd/system/network@.service|<nowiki><br />
[Unit]<br />
Description=Network connectivity (%i)<br />
Wants=network.target<br />
Before=network.target<br />
BindsTo=sys-subsystem-net-devices-%i.device<br />
After=sys-subsystem-net-devices-%i.device<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
EnvironmentFile=/etc/conf.d/network@%i<br />
<br />
ExecStart=/usr/bin/ip link set dev %i up<br />
ExecStart=/usr/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i<br />
ExecStart=/usr/bin/ip route add default via ${gateway}<br />
<br />
ExecStop=/usr/bin/ip addr flush dev %i<br />
ExecStop=/usr/bin/ip link set dev %i down<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
啟用該 unit 並將其啟動,傳入介面名稱,例如 eno1 :<br />
<br />
# systemctl enable network@eno1.service<br />
# systemctl start network@eno1.service<br />
<br />
若您需要手動設定 nameservers ,請編輯 {{ic|/etc/resolv.conf}} 檔案:<br />
<br />
{{hc|/etc/resolv.conf|<br />
nameserver 208.67.222.222<br />
nameserver 208.67.220.220}}<br />
<br />
若 {{ic|/etc/resolv.conf}} 被持續遭到複寫,請參考 [[Resolv.conf]] 以瞭解如何解決此問題。<br />
<br />
有幾個類似的方法來讓 systemd 啟動網路,其中的差異為檔案內容,並且其可以寫死 EnvironmentFile 定義的參考檔案中抓到的參數。因此可以作為一種替代的,將介面名稱放置於 /etc/conf.d/ 中的 EnvironmentFile 接著直接使用介面名稱而不是 %i 。如此一來,檔案名稱便不需要「@」。這也是一種有用的方法來閱讀 http://www.freedesktop.org/software/systemd/man/systemd.unit.html 上的 systemd 服務文件。<br />
<br />
==== 計算位址 ====<br />
<br />
您可以使用 {{Pkg|ipcalc}} 提供的 {{ic|ipcalc}} 來計算 IP 廣播、網域、子網路遮罩與主機範圍等進階設定舉例來說,我使用了位於防火牆後的乙太網路來連線 Windows 機器至 Arch。為了安全性與網路組織,我將他們放置於各自獨立的網路,接著組態設定子網路遮罩與廣播位址,如此一來網路中就只有兩台機器。為了找出子網路遮罩跟廣播位址,我使用了 ipcalc ,提供其 Arch firewire nic 的 IP 位址 10.66.66.1 ,並指定 ipcalc 要建立一個只有兩台主機的網路。<br />
<br />
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|<nowiki><br />
Address: 10.66.66.1<br />
<br />
Netmask: 255.255.255.252 = 30<br />
Network: 10.66.66.0/30<br />
HostMin: 10.66.66.1<br />
HostMax: 10.66.66.2<br />
Broadcast: 10.66.66.3<br />
Hosts/Net: 2 Class A, Private Internet<br />
</nowiki>}}<br />
<br />
== 載入組態設定 ==<br />
<br />
要測試您的設定,您可以重新啟動電腦或是重新載入相關的 systemd 服務:<br />
<br />
# systemctl restart dhcpcd@eth0<br />
<br />
您可以試著 ping 您的閘道器、 DNS 伺服器、 ISP 提供商或是其他網路上的站台。如此一來便可以確認您的網路連線問題為何,例如:<br />
<br />
$ ping -c 3 www.google.com<br />
<br />
== 附加設定 ==<br />
<br />
=== 筆記型電腦之 ifplugd ===<br />
<br />
{{Tip|{{Pkg|dhcpcd}} provides the same feature out of the box.}}<br />
<br />
{{Pkg|ifplugd}} in [[Official Repositories]] is a daemon which will automatically configure your Ethernet device when a cable is plugged in and automatically unconfigure it if the cable is pulled. This is useful on laptops with onboard network adapters, since it will only configure the interface when a cable is really connected. Another use is when you just need to restart the network but do not want to restart the computer or do it from the shell.<br />
<br />
By default it is configured to work for the {{ic|eth0}} device. This and other settings like delays can be configured in {{ic|/etc/ifplugd/ifplugd.conf}}.<br />
<br />
{{Note|[[Netctl]] package includes {{ic|netctl-ifplugd@.service}}, otherwise you can use {{ic|ifplugd@.service}} from {{Pkg|ifplugd}} package. Use for example {{ic|systemctl enable ifplugd@eth0.service}}.}}<br />
<br />
=== Bonding 或 LAG ===<br />
<br />
請參閱 [[netctl#Bonding]] 。<br />
<br />
=== IP 別名 ===<br />
<br />
{{Expansion|Manual method using [[Core Utilities#ip|ip]] should be added; then move current example using ''netctl'' into [[netctl]].}}<br />
<br />
IP 別名為讓同一個網路介面有多個 IP 位址。如此一來,單個節點的網路就能有多個網路連線,進而實現不同的作用。經典的使用方法為網頁與 FTP 伺服器的虛擬主機,或是重組伺服器而無需更新任何其他的機器(對於名稱伺服器來說特別有用)。<br />
<br />
==== 範例 ====<br />
<br />
您將需要來自[[Official Repositories|官方軟體套件庫]]的 {{Pkg|netctl}} 。<br />
<br />
準備組態設定檔:<br />
<br />
{{hc|/etc/netctl/mynetwork|<nowiki><br />
Connection='ethernet'<br />
Description='Five different addresses on the same NIC.'<br />
Interface='eth0'<br />
IP='static'<br />
Address=('192.168.1.10' '192.168.178.11' '192.168.1.12' '192.168.1.13' '192.168.1.14' '192.168.1.15')<br />
Gateway='192.168.1.1'<br />
DNS=('192.168.1.1')<br />
</nowiki>}}<br />
<br />
接著只需要將其執行:<br />
<br />
$ netctl start mynetwork<br />
<br />
=== 更改 MAC/硬體 位址 ===<br />
<br />
請參閱 [[MAC Address Spoofing]] 。<br />
<br />
=== Internet Sharing ===<br />
<br />
請參閱 [[Internet Sharing]] 。<br />
<br />
=== Router Configuration ===<br />
<br />
請參閱 [[Router]] 。<br />
<br />
=== 區域網路主機名稱解析 ===<br />
<br />
The pre-requisite is to [[#Set the hostname]] after which hostname resolution works on the local system itself {{hc|$ ping hostname|<br />
PING hostname <nowiki>(192.168.1.2) 56(84) bytes of data.<br />
64 bytes from hostname (192.168.1.2): icmp_seq=1 ttl=64 time=0.043 ms</nowiki>}}<br />
To enable other machines to address the host by name, either a manual configuration of the respective {{ic|/etc/hosts}} files or a service to propagate/resolve the name is required. <br />
<br />
When setting up a DNS server such as [[BIND]] or [[Unbound]] is overkill, manually editing your {{ic|/etc/hosts}} is too cumbersome, or when you want more flexibility with dynamic leaving and joining of hosts to the network, it is possible to handle hostname resolution on your local network using zero-configuration networking. There are two options available:<br />
<br />
*[[Samba]] provides hostname resolution via Microsoft's '''NetBIOS'''. It only requires installation of {{Pkg|samba}} and enabling of the {{ic|nmbd.service}} service. Computers running Windows, OS X, or Linux with {{ic|nmbd}} running, will be able to find your machine.<br />
<br />
*[[Avahi]] provides hostname resolution via '''zeroconf''', also known as Avahi or Bonjour. It requires slightly more complex configuration than Samba: see [[Avahi#Hostname resolution]] for details. Computers running OS X, or Linux with an Avahi daemon running, will be able to find your machine. Windows does not have an built-in Avahi client or daemon.<br />
<br />
== 診斷 ==<br />
<br />
=== Swapping computers on the cable modem ===<br />
<br />
Some cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.<br />
<br />
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].<br />
<br />
=== The TCP window scaling problem ===<br />
<br />
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.<br />
<br />
Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html RFC 1323] was written to improve the situation: Window Scaling. The "window" value, provided in all packets, will be modified by a Scale Factor defined once, at the very beginning of the connection.<br />
<br />
That 8-bit Scale Factor allows the Window to be up to 32 times higher than the initial 64Kb.<br />
<br />
It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts.<br />
<br />
The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.<br />
<br />
The resulting connection is at best very slow or broken.<br />
<br />
==== How to diagnose the problem ====<br />
<br />
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).<br />
<br />
When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|ip addr}} will report normal status... and actually everything appears normal.<br />
<br />
If you cannot browse any website, but you can ping some random hosts, chances are great that you're experiencing this problem: ping uses ICMP and is not affected by TCP problems.<br />
<br />
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).<br />
<br />
==== How to fix it (The bad way) ====<br />
<br />
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.<br />
<br />
# echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem<br />
<br />
==== How to fix it (The good way) ====<br />
<br />
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.d/99-disable_window_scaling.conf}} (see also [[sysctl]])<br />
<br />
net.ipv4.tcp_window_scaling = 0<br />
<br />
==== How to fix it (The best way) ====<br />
<br />
This problem is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.<br />
<br />
==== More about it ====<br />
<br />
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].<br />
<br />
There are also several relevant threads on the LKML.<br />
<br />
=== Realtek no link / WOL problem ===<br />
<br />
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice a problem where the NIC seems to be disabled on boot and has no Link light. This can usually be found on a dual boot system where Windows is also installed. It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause. These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots. You will be able to notice if this problem is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off. Normal operation should be that the link light is always on as long as the system is on, even during POST. This problem will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this problem:<br />
<br />
==== Method 1 - Rollback/change Windows driver ====<br />
<br />
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).<br />
<br />
==== Method 2 - Enable WOL in Windows driver ====<br />
<br />
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems). In Windows, under Device Manager, find your Realtek network adapter and double-click it. Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.<br />
<br />
In Windows XP (example)<br />
Right click my computer<br />
--> Hardware tab<br />
--> Device Manager<br />
--> Network Adapters<br />
--> "double click" Realtek ...<br />
--> Advanced tab<br />
--> Wake-On-Lan After Shutdown<br />
--> Enable<br />
<br />
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{ic|Disable}} has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.}}<br />
<br />
==== Method 3 - Newer Realtek Linux driver ====<br />
<br />
Any newer driver for these Realtek cards can be found for Linux on the realtek site. (untested but believed to also solve the problem).<br />
<br />
==== Method 4 - Enable ''LAN Boot ROM'' in BIOS/CMOS ====<br />
<br />
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.<br />
<br />
{{Note|This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.}}<br />
<br />
=== DLink G604T/DLink G502T DNS problem ===<br />
<br />
Users with a DLink G604T/DLink G502T router, using DHCP and have firmware v2.00+ (typically users with AUS firmware) may have problems with certain programs not resolving the DNS. One of these programs are unfortunatley pacman. The problem is basically the router in certain situations is not sending the DNS properly to DHCP, which causes programs to try and connect to servers with an IP address of 1.0.0.0 and fail with a connection timed out error<br />
<br />
==== How to diagnose the problem ====<br />
<br />
The best way to diagnose the problem is to use Firefox/Konqueror/links/seamonkey and to enable wget for pacman. If this is a fresh install of Arch Linux, then you may want to consider installing {{ic|links}} through the live CD.<br />
<br />
Firstly, enable wget for pacman (since it gives us info about pacman when it is downloading packages)<br />
Open {{ic|/etc/pacman.conf}} with your favourite editor and uncomment the following line (remove the # if it is there)<br />
<br />
XferCommand=/usr/bin/wget --passive-ftp -c -O %o %u<br />
<br />
While you are editing {{ic|/etc/pacman.conf}}, check the default mirror that pacman uses to download packages.<br />
<br />
Now open up the default mirror in an Internet browser to see if the mirror actually works. If it does work, then do {{ic|pacman -Syy}} (otherwise pick another working mirror and set it to the pacman default). If you get something similar to the following (notice the 1.0.0.0),<br />
<br />
<nowiki>ftp://mirror.pacific.net.au/linux/archlinux/extra/os/i686/extra.db.tar.gz</nowiki><br />
=> '/var/lib/pacman/community.db.tar.gz.part'<br />
Resolving mirror.pacific.net.au... 1.0.0.0<br />
<br />
then you most likely have this problem. The 1.0.0.0 means it is unable to resolve DNS, so we must add it to {{ic|/etc/resolv.conf}}.<br />
<br />
==== How to fix it ====<br />
<br />
{{Out of date|{{Pkg|dhcpcd}} does not use {{ic|/etc/conf.d/dhcpcd}} any more.}}<br />
<br />
Basically what we need to do is to manually add the DNS servers to our {{ic|/etc/resolv.conf}} file. The problem is that DHCP automatically deletes and replaces this file on boot, so we need to edit {{ic|/etc/conf.d/dhcpcd}} and change the flags to stop DHCP from doing this.<br />
<br />
When you open {{ic|/etc/conf.d/dhcpcd}}, you should see something close to the following:<br />
<br />
DHCPCD_ARGS="-t 30 -h $HOSTNAME"<br />
<br />
Add the {{ic|-R}} flag to the arguments, e.g.,<br />
<br />
DHCPCD_ARGS="-R -t 30 -h $HOSTNAME"<br />
<br />
{{Note|1=If you are using {{Pkg|dhcpcd}} >= 4.0.2, the {{ic|-R}} flag has been deprecated. Please see the [[#Run DHCP at boot]] section for information on how to use a custom {{ic|/etc/resolv.conf}} file.}}<br />
<br />
Save and close the file; now open {{ic|/etc/resolv.conf}}. You should see a single nameserver (most likely 10.1.1.1). This is the gateway to your router, which we need to connect to in order to get the DNS servers of your ISP. Paste the IP address into your browser and log in to your router. Go to the DNS section, and you should see an IP address in the Primary DNS Server field; copy it and paste it as a nameserver '''ABOVE''' the current gateway one.<br />
<br />
For example, {{ic|/etc/resolv.conf}} should look something along the lines of:<br />
<br />
nameserver 10.1.1.1<br />
<br />
If my primary DNS server is 211.29.132.12, then change {{ic|/etc/resolv.conf}} to:<br />
<br />
nameserver 211.29.132.12<br />
nameserver 10.1.1.1<br />
<br />
Now restart the network daemon by running {{ic|systemctl restart dhcpcd@<interface>}} and do {{ic|pacman -Syy}}. If it syncs correctly with the server, then the problem is solved.<br />
<br />
==== More about it ====<br />
<br />
This is the whirlpool forum (Australian ISP community) which talks about and gives the same solution to the problem:<br />
<br />
http://forums.whirlpool.net.au/forum-replies-archive.cfm/461625.html<br />
<br />
=== Check DHCP problem by releasing IP first ===<br />
<br />
Problem may occur when DHCP get wrong IP assignment. For example when two routers are tied together through VPN. The router that is connected to me by VPN may assigning IP address. To fix it. On a console, as root, release IP address:<br />
<br />
# dhcpcd -k<br />
<br />
Then request a new one:<br />
<br />
# dhcpcd<br />
<br />
Maybe you had to run those two commands many times.<br />
<br />
=== No eth0 with Atheros AR8161 ===<br />
<br />
{{Note|With the 3.10.2-1-ARCH kernel update, the alx ethernet driver module is included in the package.}}<br />
<br />
With the Atheros AR8161 Gigabit Ethernet card, the ethernet connection is not working out-of-the-box (with the installation media of March 2013). The module "alx" needs to be loaded but is not present.<br />
<br />
The driver from [http://linuxwireless.org/en/users/Download/stable/#compat-wireless_stable_releases compat-wireless] (that has become [https://backports.wiki.kernel.org/index.php/Releases compat-drives] since linux 3.7) need to be installed. The "-u" postfix annotates that Qualcomm have applied a driver under a unified driver.<br />
<br />
$ wget https://www.kernel.org/pub/linux/kernel/projects/backports/2013/03/28/compat-drivers-2013-03-28-5-u.tar.bz2<br />
$ tar xjf compat*<br />
$ cd compat*<br />
$ ./scripts/driver-select alx<br />
$ make<br />
$ sudo make install<br />
$ sudo modprobe alx<br />
<br />
The alx driver has not been added to Linux kernel due to various problems. Compatibility between the different kernel versions has been spotty. For better support follow the [http://lists.infradead.org/mailman/listinfo/unified-drivers mailing list]and [http://www.linuxfoundation.org/collaborate/workgroups/networking/alx alx page]for latest working solution for alx.<br />
<br />
The driver must be built and installed after every kernel change.<br />
<br />
Alternatively you can use the AUR package for [https://aur.archlinux.org/packages/compat-drivers-patched/ compat drivers], which installs many other drivers.<br />
<br />
=== No eth0 with Atheros AR9485 ===<br />
<br />
The ethernet (eth0) for Atheros AR9485 are not working out-of-the-box (with installation media of March 2013). The working solution for this is to install the package [https://aur.archlinux.org/packages/compat-drivers-patched/ compat-drivers-patched] from AUR.<br />
<br />
=== No carrier / no connection after suspend ===<br />
After suspend to RAM no connection is found although the network cable is plugged in. <br />
This may be caused by PCI power management. What is the output of<br />
<br />
# ip link show eth0<br />
<br />
If the line contains "NO-CARRIER" even though there's a cable connected to your eth0 port, it is possible that the device was auto-suspended and the media sense feature doesn't work. To solve this, first you need to find your ethernet controllers PCI address by<br />
<br />
# lspci<br />
<br />
This should look similar to this:<br />
<br />
...<br />
00:19.0 Ethernet controller: Intel Corporation 82577LM Gigabit Network Connection (rev 06)<br />
...<br />
<br />
So the address is 00:19.0.<br />
Now check the PM status of the device by issuing<br />
<br />
# cat "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
substituting 00:19.0 with the address obtained from lspci.<br />
If the output reads "auto", you can try to bring the device out of suspend by<br />
<br />
# echo on > "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
Don't forget to substitute the address again.<br />
<br />
{{Note|1=This appears to be a bug in kernel 3.8.4.1- (3.8.8.1 is still affected): [https://bbs.archlinux.org/viewtopic.php?id=159837&p=2 Forum discussion.] It also appears a fix is [https://lkml.org/lkml/2013/1/18/147 on the way. (It will be likely fixed in 3.9.)] In the meantime, the above is a suitable workaround.}}<br />
<br />
=== Broadcom BCM57780 ===<br />
<br />
This Broadcom chipset sometimes does not behave well unless you specify the order of the modules to be loaded. The modules are {{ic|broadcom}} and {{ic|tg3}}, the former needing to be loaded first.<br />
<br />
These steps should help if your computer has this chipset:<br />
$ lspci | grep Ethernet<br />
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)<br />
<br />
If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following (as root):<br />
# modprobe -r tg3<br />
# modprobe broadcom<br />
# modprobe tg3<br />
<br />
Now plug you network cable in. If this solves your problems you can make this permanent by adding {{ic|broadcom}} and {{ic|tg3}} (in this order) to the {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}}:<br />
<br />
MODULES=".. broadcom tg3 .."<br />
<br />
Then rebuild the initramfs:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|These methods may work for other chipsets, such as BCM57760.}}</div>Binotahttps://wiki.archlinux.org/index.php?title=Network_configuration_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=293540Network configuration (正體中文)2014-01-19T09:31:57Z<p>Binota: /* Bonding 或 LAG */ Translated</p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:Networking (正體中文)]]<br />
[[Category:Getting and installing Arch (正體中文)]]<br />
<br />
[[cs:Configuring Network]]<br />
[[el:Configuring Network]]<br />
[[es:Configuring Network]]<br />
[[fr:Connexions reseau]]<br />
[[it:Configuring Network]]<br />
[[ja:Network Configuration]]<br />
[[nl:Configuring Network]]<br />
[[pt:Configuring Network]]<br />
[[ro:Configurare retea]]<br />
[[ru:Configuring Network]]<br />
[[sk:Configuring Network]]<br />
[[tr:Ağ_Yapılandırması]]<br />
[[zh-CN:Network Configuration]]<br />
[[zh-TW:Network Configuration]]<br />
{{Related articles start}}<br />
{{Related|Jumbo Frames}}<br />
{{Related|Firewalls}}<br />
{{Related|Wireless Setup}}<br />
{{Related|List of Applications#Network Managers}}<br />
{{Related articles end}}<br />
<br />
本頁將介紹如何設定 '''有線''' 網路連線。若您需要設定 '''無線''' 網路,請參考[[Wireless Setup|無線網路設定]]。<br />
<br />
== 檢查連線 ==<br />
<br />
{{注意|若您在執行 ping 時收到了類似 {{ic|ping: icmp open socket: Operation not permitted}} 這樣的錯誤訊息,請嘗試重新安裝 {{ic|iputils}} 軟體包。}} <br />
<br />
一般來說,基本的安裝過程都已經建立了可運作的網路設定。請執行下列指令以進行檢查:<br />
<br />
{{注意|{{ic|-c 3}} 選項表示將會呼叫三次。詳細請參閱 {{ic|man ping}} 。}}<br />
{{注意|您也可以嘗試使用其他的 Domain ,如 www.hinet.net 。}}<br />
<br />
{{hc|$ ping -c 3 www.google.com|<nowiki><br />
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.<br />
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms<br />
64 bytes from 74.125.224.146: icmp_req=2 ttl=50 time=385 ms<br />
64 bytes from 74.125.224.146: icmp_req=3 ttl=50 time=298 ms<br />
<br />
--- www.l.google.com ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 1999ms<br />
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms<br />
</nowiki>}}<br />
<br />
如果沒問題的話,您可能只是想以本文的下列部分來自定您的設定。<br />
<br />
若剛才的指令出現了 unknown hosts 之類的訊息,代表您的機器無法解析網域。這可能是因為您的網路服務提供商/網關造成的。您可以嘗試 ping 一個靜態 IP 以實驗您的機器可否存取網際網路。<br />
{{注意|您也可以嘗試使用其他的 IP ,如 168.95.1.1 。}}<br />
<br />
{{hc|$ ping -c 3 8.8.8.8|<nowiki><br />
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.<br />
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms<br />
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms<br />
64 bytes from 8.8.8.8: icmp_req=3 ttl=53 time=70.6 ms<br />
<br />
--- 8.8.8.8 ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 2002ms<br />
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms<br />
</nowiki>}}<br />
<br />
{{注意|{{ic|8.8.8.8}} 為一個好記的靜態 IP 位置。這是 Google 的主要 DNS 伺服器,這表示其有一定的可信度,並且通常不會被系統或代理伺服器擋下。}}<br />
<br />
若您可以 ping 通該位置,您可能需要試著在 {{ic|/etc/resolv.conf}} 檔案中加上網域名稱伺服器。<br />
<br />
== 設定主機名稱 ==<br />
<br />
[[Wikipedia:Hostname|主機名稱]]為網路中用於識別機器的唯一識別名稱:主機名稱可以通過 {{ic|/etc/hostname}} 檔案來進行設定。一般來說該檔案包含了系統的網域名稱。下面為設定主機名稱的方法:<br />
<br />
# hostnamectl set-hostname '''myhostname'''<br />
<br />
這樣會將 '''myhostname''' 寫入 {{ic|/etc/hostname}} 檔案中。<br />
<br />
詳細請參閱 {{ic|man 5 hostname}} 與 {{ic|man 1 hostnamectl}} 。<br />
<br />
{{注意|<br />
* {{ic|hostnamectl}} 支援 FQDN<br />
* 您不需要編輯 {{ic|/etc/hosts}} 檔案,{{pkg|systemd}} 會提供主機名稱解析且預設安裝於所有系統。<br />
}}<br />
<br />
使用來自 {{Pkg|inetutils}} 的 {{ic|hostname}} 指令以設定臨時主機名稱(直到重新啟動):<br />
<br />
# hostname ''myhostname''<br />
<br />
== 裝置驅動程式 ==<br />
<br />
=== 檢查驅動程式狀態 ===<br />
<br />
[[udev]] 應該會檢測您的網路介面卡([[Wikipedia:Network_interface_controller|NIC]])並自動於啟動時載入必要的模組。檢查 {{ic|lspci -v}} 輸出內容中的「Ethernet controller」 項目(或類似的)。這應該會告訴您哪些核心模組包含了網路設備的驅動程式。舉例來說:<br />
<br />
{{hc|$ lspci -v|<br />
02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)<br />
...<br />
Kernel driver in use: atl1<br />
Kernel modules: atl1<br />
}}<br />
<br />
接下來,確認該驅動程式已經通過 {{ic|dmesg <nowiki>|</nowiki> grep ''module_name''}} 載入了。舉例來說:<br />
<br />
$ dmesg | grep atl1<br />
...<br />
atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex<br />
<br />
若驅動程式已成功加載可以跳過接下來這段。否則,您會需要知道哪些模組時您的特定型號的裝置需要哪個模組。<br />
<br />
=== 載入裝置模組 ===<br />
<br />
以 Google 搜尋正確的晶片組模組/驅動程式。常見的驅動模組有 Realtek 晶片組網卡的 {{ic|8139too}} ,或是 SiS 晶片組網卡的 {{ic|sis900}}。當您知道要使用何種模組了之後,試著[[Kernel modules#Manual module handling|手動將其載入]]。若您的到了錯誤訊息告訴您找不到該模組,則該驅動可能未包含於 Arch 核心中。您可以在 [[AUR]] 中搜尋該模組名稱。<br />
<br />
若 udev 未在開機期間檢測與載入正確的模組,請參閱 [[Kernel modules#Loading]]。<br />
<br />
== 網路介面 ==<br />
<br />
=== 裝置名稱 ===<br />
<br />
對於多網路卡的電腦,固定裝置名稱非常重要。許多設定問題都是因為介面卡名稱的改動造成的。<br />
<br />
[[udev]] 負責命名裝置。Systemd v197 則有[http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames 可預測之網路介面名稱]並可自動支配靜態名稱給網路裝置。介面名稱以 {{ic|en}} (乙太網路)、 {{ic|wl}} (無線網路) 或是 {{ic|ww}} (WWAN)作為前置字串並附上一個自動產生的識別名稱,進而產生了類似 {{ic|enp0s25}} 這樣的名稱。 <br />
<br />
要禁用這種行為,可以加上一個連接:<br />
<br />
# ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules<br />
<br />
自早期版本升級 systemd 的使用者會有一自動建立的空規則檔案。因此,若您想使用一貫的裝置名稱,只需要刪除該檔案。<br />
<br />
{{提示|您可以執行 {{ic|ip link}} 或是 {{ic|ls /sys/class/net}} 以列出所有可用的介面。}}<br />
<br />
{{注意|當您更改了介面名稱規則後,別忘了更新所有跟網路有關的組態檔案與自定的 systemd unit 檔案以因應該更改。特別是當您啟用了 [[netctl#Basic method|netctl 靜態設定檔]] ,請執行 {{ic|netctl reenable ''profile''}} 以更新所有產生的服務檔案。}}<br />
<br />
==== 更改裝置名稱 ====<br />
<br />
您可以使用 udev-rule 來手動定義裝置名稱。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"<br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"<br />
</nowiki>}}<br />
<br />
請注意這兩點:<br />
<br />
* 使用這個指令以取得 MAC 位置:{{ic|cat /sys/class/net/''device_name''/address}}。<br />
* 請確定 udev 規則中使用的是小寫的十六進位數值而不是大寫。<br />
<br />
若您的網路卡為動態 MAC ,您可以使用 DEVPATH ,例如:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"<br />
</nowiki>}}<br />
<br />
{{注意|當使用了靜態的名稱時,'''應該要避免使用類似 "eth''X''" 與 "wlan''X''"''' 這樣的名稱,因為這可能會導致核心與 udev 在開機時發生衝突。而剛好相反地,最好使用核心預設不會使用的介面名稱,如 {{ic|net0}} 、 {{ic|net1}} 、 {{ic|wifi0}} 、 {{ic|wifi1}} 。詳細說明請參閱 [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames systemd] 文件。}}<br />
<br />
=== 設定裝置的 MTU 與佇列長度 ===<br />
<br />
您可以手動定義 udev 規則來更改裝置的 MTU 與佇列長度。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1480", ATTR{tx_queue_len}="2000"<br />
</nowiki>}}<br />
<br />
=== 取得目前的裝置名稱 ===<br />
<br />
目前的 NIC 名稱可以通過 sysfs 找到<br />
<br />
{{hc|$ ls /sys/class/net|<br />
lo eth0 eth1 firewire0<br />
}}<br />
<br />
=== 啟用與禁用網路介面 ===<br />
<br />
您可以使用下列指令來啟用或禁用網路介面:<br />
<br />
# ip link set eth0 up<br />
# ip link set eth0 down<br />
<br />
要確認結果,請執行:<br />
<br />
{{hc|$ ip link show dev eth0|<br />
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000<br />
...<br />
}}<br />
<br />
== 組態設定 IP 位址 ==<br />
<br />
您有兩個選擇:使用 [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]] 指派動態位址,或是使用「靜態」的位址。<br />
<br />
=== 動態 IP 位址 ===<br />
<br />
==== 手動執行 DHCP 用戶端 Daemon ====<br />
<br />
{{注意|請特別注意 {{ic|dhcpcd}} (DHCP ''Client'' Daemon,DHCP 用戶端 Daemon) 與 {{ic|dhcpd}} (DHCP ''(server)'' daemon,DHCP 伺服端 Daemon) 間的差異。}}<br />
<br />
{{hc|# dhcpcd eth0|<br />
dhcpcd: version 5.1.1 starting<br />
dhcpcd: eth0: broadcasting for a lease<br />
...<br />
dhcpcd: eth0: leased 192.168.1.70 for 86400 seconds<br />
}}<br />
<br />
緊接著, {{ic|ip addr show dev eth0}} 應該要顯示出您的 inet 位址。<br />
<br />
對部分的人而言,{{ic|dhcpcd}} 失敗時,可以使用 {{ic|dhclient}} (位於 {{Pkg|dhclient}} 軟體包中)<br />
<br />
==== 於啟動時執行 DHCP ====<br />
<br />
若您只是想使用 DHCP 來連線至您的乙太網路連線,您可以使用 {{ic|dhcpcd@.service}} (由 {{Pkg|dhcpcd}} 軟體包提供)。<br />
<br />
要啟動 {{ic|eth0}} 上的 DHCP ,只需要使用:<br />
<br />
# systemctl start dhcpcd@eth0.service<br />
<br />
您可以下列方法啟用該服務讓其於開機時自動啟動:<br />
<br />
# systemctl enable dhcpcd@eth0.service<br />
<br />
若您用了 DHCP 且您並 '''不想''' 讓您的 DNS 伺服器在每次啟動您的網路時自動指派,請將下列內容加到 {{ic|dhcpcd.conf}} 的最後一段中:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nohook resolv.conf<br />
}}<br />
<br />
另外,若您位於基於 MAC 位址的用戶端 IP 位址進行過濾的 DHCPv4 網路,您可能需要修改下列內容:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 Client ID as per RFC4361. <br />
duid<br />
}}<br />
<br />
為:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the hardware address of the interface for the Client ID (DHCPv4).<br />
clientid<br />
}}<br />
<br />
否則,您可能會因為 DHCP 伺服器無法正確讀取您的 [http://en.wikipedia.org/wiki/DHCPv6 DHCPv6-style] 用戶端 ID 而無法使用。詳細請參閱 [http://tools.ietf.org/html/rfc4361 RFC 4361] 。<br />
<br />
為防止 {{ic|dhcpcd}} 加入網域名稱伺服器至 {{ic|/etc/resolv.conf}} 中,請於其中使用 {{ic|nooption}} 選項:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nooption domain_name_servers<br />
}}<br />
<br />
接著加入您自己的 DNS 名稱伺服器至 {{ic|/etc/resolv.conf}} 中。<br />
<br />
若有多個不同的執行緒要控制 {{ic|/etc/resolv.conf}} (如 {{Pkg|dhcpcd}} 與 VPN 用戶端),您可能會想要使用 {{Pkg|openresolv}} 軟體包。使用 {{Pkg|openresolv}} 並不需要額外地設定 {{Pkg|dhcpcd}} 。<br />
<br />
==== DHCP 靜態路由 ====<br />
若您需要加入靜態路由用戶端,請於 {{ic|/usr/lib/dhcpcd/dhcpcd-hooks}} 中建立一個新的 dhcpcd hook-script 。下列範例展示了加入靜態路由至一個通過閘道器為 192.168.192.5 ,位於 10.11.12.0/24 的 VPN 子網路:<br />
{{hc|/usr/lib/dhcpcd/dhcpcd-hooks/40-vpnroute|<br />
ip route add 10.11.12.0/24 via 192.168.192.5<br />
}}<br />
前置字串''40''表示其於 dhcpcd 啟動時的最後執行 hook-script 。<br />
<br />
=== 靜態 IP 位址 ===<br />
<br />
您可能因為各種原因而希望在您的網路中指派靜態 IP 位址,例如靜態的位址可以獲得一定程度的可預測性,或是您沒有可用的 DHCP 伺服器。<br />
<br />
{{注意|若您共通過 Windows 機器共享您的網路而沒有路由器,請確保兩台電腦皆使用了靜態 IP 位址以避免區域網路問題。}}<br />
<br />
您需要:<br />
<br />
* 靜態 IP 位址<br />
* [[Wikipedia:Subnetwork|子網路遮罩]]<br />
* [[Wikipedia:Broadcast_address|廣播位址]]<br />
* [[Wikipedia:Default_gateway|閘道器]]的 IP 位址<br />
<br />
若您處在內部網路中,使用 192.168.*.* 這樣的 IP 位址較為安全,搭配其的子網路遮罩 255.255.255.0 ,廣播位址為 192.168.*.255 。而閘道器通常是 192.168.*.1 或是 192.168.*.254 。<br />
<br />
==== 手動指派 ====<br />
<br />
您可於控制台中指派一靜態 IP 位址:<br />
<br />
# ip addr add <IP 位址>/<子網路遮罩> broadcast <廣播> dev <介面><br />
<br />
舉例來說:<br />
<br />
# ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev eth0<br />
<br />
{{注意|子網路遮罩使用了 [[Wikipedia:CIDR_notation|CIDR 表示法]](CIDR,Classless Inter-Domain Routing,無類別網路間路由)。}}<br />
<br />
詳情請參閱 {{ic|man ip}} 。<br />
<br />
以類似下列方法加上您的閘道器:<br />
<br />
# ip route add default via <預設閘道器 IP 位址><br />
<br />
舉例來說:<br />
<br />
# ip route add default via 192.168.1.1<br />
<br />
若您得到了 "No such process" 這樣的錯誤訊息,這代表您必須以 root 執行 {{ic|ip link set dev eth0 up}} 。<br />
<br />
==== 於啟動時通過 systemd 手動連線 ====<br />
<br />
先確保 dhcpcd 已停止並禁用:<br />
<br />
# systemctl status dhcpcd.service<br />
<br />
接著為 [[systemd]] 服務建立一個檔案。以正確的網路介面名稱取代其中的 {{ic|<interface>}} :<br />
<br />
{{hc|/etc/conf.d/network@<interface>|<nowiki><br />
address=192.168.0.15<br />
netmask=24<br />
broadcast=192.168.0.255<br />
gateway=192.168.0.1<br />
</nowiki>}}<br />
<br />
建立 systemd unit 檔案:<br />
<br />
{{hc|/etc/systemd/system/network@.service|<nowiki><br />
[Unit]<br />
Description=Network connectivity (%i)<br />
Wants=network.target<br />
Before=network.target<br />
BindsTo=sys-subsystem-net-devices-%i.device<br />
After=sys-subsystem-net-devices-%i.device<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
EnvironmentFile=/etc/conf.d/network@%i<br />
<br />
ExecStart=/usr/bin/ip link set dev %i up<br />
ExecStart=/usr/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i<br />
ExecStart=/usr/bin/ip route add default via ${gateway}<br />
<br />
ExecStop=/usr/bin/ip addr flush dev %i<br />
ExecStop=/usr/bin/ip link set dev %i down<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
啟用該 unit 並將其啟動,傳入介面名稱,例如 eno1 :<br />
<br />
# systemctl enable network@eno1.service<br />
# systemctl start network@eno1.service<br />
<br />
若您需要手動設定 nameservers ,請編輯 {{ic|/etc/resolv.conf}} 檔案:<br />
<br />
{{hc|/etc/resolv.conf|<br />
nameserver 208.67.222.222<br />
nameserver 208.67.220.220}}<br />
<br />
若 {{ic|/etc/resolv.conf}} 被持續遭到複寫,請參考 [[Resolv.conf]] 以瞭解如何解決此問題。<br />
<br />
有幾個類似的方法來讓 systemd 啟動網路,其中的差異為檔案內容,並且其可以寫死 EnvironmentFile 定義的參考檔案中抓到的參數。因此可以作為一種替代的,將介面名稱放置於 /etc/conf.d/ 中的 EnvironmentFile 接著直接使用介面名稱而不是 %i 。如此一來,檔案名稱便不需要「@」。這也是一種有用的方法來閱讀 http://www.freedesktop.org/software/systemd/man/systemd.unit.html 上的 systemd 服務文件。<br />
<br />
==== 計算位址 ====<br />
<br />
您可以使用 {{Pkg|ipcalc}} 提供的 {{ic|ipcalc}} 來計算 IP 廣播、網域、子網路遮罩與主機範圍等進階設定舉例來說,我使用了位於防火牆後的乙太網路來連線 Windows 機器至 Arch。為了安全性與網路組織,我將他們放置於各自獨立的網路,接著組態設定子網路遮罩與廣播位址,如此一來網路中就只有兩台機器。為了找出子網路遮罩跟廣播位址,我使用了 ipcalc ,提供其 Arch firewire nic 的 IP 位址 10.66.66.1 ,並指定 ipcalc 要建立一個只有兩台主機的網路。<br />
<br />
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|<nowiki><br />
Address: 10.66.66.1<br />
<br />
Netmask: 255.255.255.252 = 30<br />
Network: 10.66.66.0/30<br />
HostMin: 10.66.66.1<br />
HostMax: 10.66.66.2<br />
Broadcast: 10.66.66.3<br />
Hosts/Net: 2 Class A, Private Internet<br />
</nowiki>}}<br />
<br />
== 載入組態設定 ==<br />
<br />
要測試您的設定,您可以重新啟動電腦或是重新載入相關的 systemd 服務:<br />
<br />
# systemctl restart dhcpcd@eth0<br />
<br />
您可以試著 ping 您的閘道器、 DNS 伺服器、 ISP 提供商或是其他網路上的站台。如此一來便可以確認您的網路連線問題為何,例如:<br />
<br />
$ ping -c 3 www.google.com<br />
<br />
== 附加設定 ==<br />
<br />
=== 筆記型電腦之 ifplugd ===<br />
<br />
{{Tip|{{Pkg|dhcpcd}} provides the same feature out of the box.}}<br />
<br />
{{Pkg|ifplugd}} in [[Official Repositories]] is a daemon which will automatically configure your Ethernet device when a cable is plugged in and automatically unconfigure it if the cable is pulled. This is useful on laptops with onboard network adapters, since it will only configure the interface when a cable is really connected. Another use is when you just need to restart the network but do not want to restart the computer or do it from the shell.<br />
<br />
By default it is configured to work for the {{ic|eth0}} device. This and other settings like delays can be configured in {{ic|/etc/ifplugd/ifplugd.conf}}.<br />
<br />
{{Note|[[Netctl]] package includes {{ic|netctl-ifplugd@.service}}, otherwise you can use {{ic|ifplugd@.service}} from {{Pkg|ifplugd}} package. Use for example {{ic|systemctl enable ifplugd@eth0.service}}.}}<br />
<br />
=== Bonding 或 LAG ===<br />
<br />
請參閱 [[netctl#Bonding]] 。<br />
<br />
=== IP 別名 ===<br />
<br />
{{Expansion|Manual method using [[Core Utilities#ip|ip]] should be added; then move current example using ''netctl'' into [[netctl]].}}<br />
<br />
IP aliasing is the process of adding more than one IP address to a network interface. With this, one node on a network can have multiple connections to a network, each serving a different purpose. Typical uses are virtual hosting of Web and FTP servers, or reorganizing servers without having to update any other machines (this is especially useful for nameservers).<br />
<br />
==== 範例 ====<br />
<br />
You will need {{Pkg|netctl}} from the [[Official Repositories]].<br />
<br />
Prepare the configuration:<br />
<br />
{{hc|/etc/netctl/mynetwork|<nowiki><br />
Connection='ethernet'<br />
Description='Five different addresses on the same NIC.'<br />
Interface='eth0'<br />
IP='static'<br />
Address=('192.168.1.10' '192.168.178.11' '192.168.1.12' '192.168.1.13' '192.168.1.14' '192.168.1.15')<br />
Gateway='192.168.1.1'<br />
DNS=('192.168.1.1')<br />
</nowiki>}}<br />
<br />
Then simply execute: <br />
<br />
$ netctl start mynetwork<br />
<br />
=== 更改 MAC/硬體 位址 ===<br />
<br />
請參閱 [[MAC Address Spoofing]] 。<br />
<br />
=== Internet Sharing ===<br />
<br />
請參閱 [[Internet Sharing]] 。<br />
<br />
=== Router Configuration ===<br />
<br />
請參閱 [[Router]] 。<br />
<br />
=== 區域網路主機名稱解析 ===<br />
<br />
The pre-requisite is to [[#Set the hostname]] after which hostname resolution works on the local system itself {{hc|$ ping hostname|<br />
PING hostname <nowiki>(192.168.1.2) 56(84) bytes of data.<br />
64 bytes from hostname (192.168.1.2): icmp_seq=1 ttl=64 time=0.043 ms</nowiki>}}<br />
To enable other machines to address the host by name, either a manual configuration of the respective {{ic|/etc/hosts}} files or a service to propagate/resolve the name is required. <br />
<br />
When setting up a DNS server such as [[BIND]] or [[Unbound]] is overkill, manually editing your {{ic|/etc/hosts}} is too cumbersome, or when you want more flexibility with dynamic leaving and joining of hosts to the network, it is possible to handle hostname resolution on your local network using zero-configuration networking. There are two options available:<br />
<br />
*[[Samba]] provides hostname resolution via Microsoft's '''NetBIOS'''. It only requires installation of {{Pkg|samba}} and enabling of the {{ic|nmbd.service}} service. Computers running Windows, OS X, or Linux with {{ic|nmbd}} running, will be able to find your machine.<br />
<br />
*[[Avahi]] provides hostname resolution via '''zeroconf''', also known as Avahi or Bonjour. It requires slightly more complex configuration than Samba: see [[Avahi#Hostname resolution]] for details. Computers running OS X, or Linux with an Avahi daemon running, will be able to find your machine. Windows does not have an built-in Avahi client or daemon.<br />
<br />
== 診斷 ==<br />
<br />
=== Swapping computers on the cable modem ===<br />
<br />
Some cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.<br />
<br />
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].<br />
<br />
=== The TCP window scaling problem ===<br />
<br />
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.<br />
<br />
Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html RFC 1323] was written to improve the situation: Window Scaling. The "window" value, provided in all packets, will be modified by a Scale Factor defined once, at the very beginning of the connection.<br />
<br />
That 8-bit Scale Factor allows the Window to be up to 32 times higher than the initial 64Kb.<br />
<br />
It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts.<br />
<br />
The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.<br />
<br />
The resulting connection is at best very slow or broken.<br />
<br />
==== How to diagnose the problem ====<br />
<br />
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).<br />
<br />
When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|ip addr}} will report normal status... and actually everything appears normal.<br />
<br />
If you cannot browse any website, but you can ping some random hosts, chances are great that you're experiencing this problem: ping uses ICMP and is not affected by TCP problems.<br />
<br />
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).<br />
<br />
==== How to fix it (The bad way) ====<br />
<br />
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.<br />
<br />
# echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem<br />
<br />
==== How to fix it (The good way) ====<br />
<br />
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.d/99-disable_window_scaling.conf}} (see also [[sysctl]])<br />
<br />
net.ipv4.tcp_window_scaling = 0<br />
<br />
==== How to fix it (The best way) ====<br />
<br />
This problem is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.<br />
<br />
==== More about it ====<br />
<br />
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].<br />
<br />
There are also several relevant threads on the LKML.<br />
<br />
=== Realtek no link / WOL problem ===<br />
<br />
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice a problem where the NIC seems to be disabled on boot and has no Link light. This can usually be found on a dual boot system where Windows is also installed. It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause. These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots. You will be able to notice if this problem is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off. Normal operation should be that the link light is always on as long as the system is on, even during POST. This problem will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this problem:<br />
<br />
==== Method 1 - Rollback/change Windows driver ====<br />
<br />
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).<br />
<br />
==== Method 2 - Enable WOL in Windows driver ====<br />
<br />
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems). In Windows, under Device Manager, find your Realtek network adapter and double-click it. Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.<br />
<br />
In Windows XP (example)<br />
Right click my computer<br />
--> Hardware tab<br />
--> Device Manager<br />
--> Network Adapters<br />
--> "double click" Realtek ...<br />
--> Advanced tab<br />
--> Wake-On-Lan After Shutdown<br />
--> Enable<br />
<br />
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{ic|Disable}} has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.}}<br />
<br />
==== Method 3 - Newer Realtek Linux driver ====<br />
<br />
Any newer driver for these Realtek cards can be found for Linux on the realtek site. (untested but believed to also solve the problem).<br />
<br />
==== Method 4 - Enable ''LAN Boot ROM'' in BIOS/CMOS ====<br />
<br />
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.<br />
<br />
{{Note|This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.}}<br />
<br />
=== DLink G604T/DLink G502T DNS problem ===<br />
<br />
Users with a DLink G604T/DLink G502T router, using DHCP and have firmware v2.00+ (typically users with AUS firmware) may have problems with certain programs not resolving the DNS. One of these programs are unfortunatley pacman. The problem is basically the router in certain situations is not sending the DNS properly to DHCP, which causes programs to try and connect to servers with an IP address of 1.0.0.0 and fail with a connection timed out error<br />
<br />
==== How to diagnose the problem ====<br />
<br />
The best way to diagnose the problem is to use Firefox/Konqueror/links/seamonkey and to enable wget for pacman. If this is a fresh install of Arch Linux, then you may want to consider installing {{ic|links}} through the live CD.<br />
<br />
Firstly, enable wget for pacman (since it gives us info about pacman when it is downloading packages)<br />
Open {{ic|/etc/pacman.conf}} with your favourite editor and uncomment the following line (remove the # if it is there)<br />
<br />
XferCommand=/usr/bin/wget --passive-ftp -c -O %o %u<br />
<br />
While you are editing {{ic|/etc/pacman.conf}}, check the default mirror that pacman uses to download packages.<br />
<br />
Now open up the default mirror in an Internet browser to see if the mirror actually works. If it does work, then do {{ic|pacman -Syy}} (otherwise pick another working mirror and set it to the pacman default). If you get something similar to the following (notice the 1.0.0.0),<br />
<br />
<nowiki>ftp://mirror.pacific.net.au/linux/archlinux/extra/os/i686/extra.db.tar.gz</nowiki><br />
=> '/var/lib/pacman/community.db.tar.gz.part'<br />
Resolving mirror.pacific.net.au... 1.0.0.0<br />
<br />
then you most likely have this problem. The 1.0.0.0 means it is unable to resolve DNS, so we must add it to {{ic|/etc/resolv.conf}}.<br />
<br />
==== How to fix it ====<br />
<br />
{{Out of date|{{Pkg|dhcpcd}} does not use {{ic|/etc/conf.d/dhcpcd}} any more.}}<br />
<br />
Basically what we need to do is to manually add the DNS servers to our {{ic|/etc/resolv.conf}} file. The problem is that DHCP automatically deletes and replaces this file on boot, so we need to edit {{ic|/etc/conf.d/dhcpcd}} and change the flags to stop DHCP from doing this.<br />
<br />
When you open {{ic|/etc/conf.d/dhcpcd}}, you should see something close to the following:<br />
<br />
DHCPCD_ARGS="-t 30 -h $HOSTNAME"<br />
<br />
Add the {{ic|-R}} flag to the arguments, e.g.,<br />
<br />
DHCPCD_ARGS="-R -t 30 -h $HOSTNAME"<br />
<br />
{{Note|1=If you are using {{Pkg|dhcpcd}} >= 4.0.2, the {{ic|-R}} flag has been deprecated. Please see the [[#Run DHCP at boot]] section for information on how to use a custom {{ic|/etc/resolv.conf}} file.}}<br />
<br />
Save and close the file; now open {{ic|/etc/resolv.conf}}. You should see a single nameserver (most likely 10.1.1.1). This is the gateway to your router, which we need to connect to in order to get the DNS servers of your ISP. Paste the IP address into your browser and log in to your router. Go to the DNS section, and you should see an IP address in the Primary DNS Server field; copy it and paste it as a nameserver '''ABOVE''' the current gateway one.<br />
<br />
For example, {{ic|/etc/resolv.conf}} should look something along the lines of:<br />
<br />
nameserver 10.1.1.1<br />
<br />
If my primary DNS server is 211.29.132.12, then change {{ic|/etc/resolv.conf}} to:<br />
<br />
nameserver 211.29.132.12<br />
nameserver 10.1.1.1<br />
<br />
Now restart the network daemon by running {{ic|systemctl restart dhcpcd@<interface>}} and do {{ic|pacman -Syy}}. If it syncs correctly with the server, then the problem is solved.<br />
<br />
==== More about it ====<br />
<br />
This is the whirlpool forum (Australian ISP community) which talks about and gives the same solution to the problem:<br />
<br />
http://forums.whirlpool.net.au/forum-replies-archive.cfm/461625.html<br />
<br />
=== Check DHCP problem by releasing IP first ===<br />
<br />
Problem may occur when DHCP get wrong IP assignment. For example when two routers are tied together through VPN. The router that is connected to me by VPN may assigning IP address. To fix it. On a console, as root, release IP address:<br />
<br />
# dhcpcd -k<br />
<br />
Then request a new one:<br />
<br />
# dhcpcd<br />
<br />
Maybe you had to run those two commands many times.<br />
<br />
=== No eth0 with Atheros AR8161 ===<br />
<br />
{{Note|With the 3.10.2-1-ARCH kernel update, the alx ethernet driver module is included in the package.}}<br />
<br />
With the Atheros AR8161 Gigabit Ethernet card, the ethernet connection is not working out-of-the-box (with the installation media of March 2013). The module "alx" needs to be loaded but is not present.<br />
<br />
The driver from [http://linuxwireless.org/en/users/Download/stable/#compat-wireless_stable_releases compat-wireless] (that has become [https://backports.wiki.kernel.org/index.php/Releases compat-drives] since linux 3.7) need to be installed. The "-u" postfix annotates that Qualcomm have applied a driver under a unified driver.<br />
<br />
$ wget https://www.kernel.org/pub/linux/kernel/projects/backports/2013/03/28/compat-drivers-2013-03-28-5-u.tar.bz2<br />
$ tar xjf compat*<br />
$ cd compat*<br />
$ ./scripts/driver-select alx<br />
$ make<br />
$ sudo make install<br />
$ sudo modprobe alx<br />
<br />
The alx driver has not been added to Linux kernel due to various problems. Compatibility between the different kernel versions has been spotty. For better support follow the [http://lists.infradead.org/mailman/listinfo/unified-drivers mailing list]and [http://www.linuxfoundation.org/collaborate/workgroups/networking/alx alx page]for latest working solution for alx.<br />
<br />
The driver must be built and installed after every kernel change.<br />
<br />
Alternatively you can use the AUR package for [https://aur.archlinux.org/packages/compat-drivers-patched/ compat drivers], which installs many other drivers.<br />
<br />
=== No eth0 with Atheros AR9485 ===<br />
<br />
The ethernet (eth0) for Atheros AR9485 are not working out-of-the-box (with installation media of March 2013). The working solution for this is to install the package [https://aur.archlinux.org/packages/compat-drivers-patched/ compat-drivers-patched] from AUR.<br />
<br />
=== No carrier / no connection after suspend ===<br />
After suspend to RAM no connection is found although the network cable is plugged in. <br />
This may be caused by PCI power management. What is the output of<br />
<br />
# ip link show eth0<br />
<br />
If the line contains "NO-CARRIER" even though there's a cable connected to your eth0 port, it is possible that the device was auto-suspended and the media sense feature doesn't work. To solve this, first you need to find your ethernet controllers PCI address by<br />
<br />
# lspci<br />
<br />
This should look similar to this:<br />
<br />
...<br />
00:19.0 Ethernet controller: Intel Corporation 82577LM Gigabit Network Connection (rev 06)<br />
...<br />
<br />
So the address is 00:19.0.<br />
Now check the PM status of the device by issuing<br />
<br />
# cat "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
substituting 00:19.0 with the address obtained from lspci.<br />
If the output reads "auto", you can try to bring the device out of suspend by<br />
<br />
# echo on > "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
Don't forget to substitute the address again.<br />
<br />
{{Note|1=This appears to be a bug in kernel 3.8.4.1- (3.8.8.1 is still affected): [https://bbs.archlinux.org/viewtopic.php?id=159837&p=2 Forum discussion.] It also appears a fix is [https://lkml.org/lkml/2013/1/18/147 on the way. (It will be likely fixed in 3.9.)] In the meantime, the above is a suitable workaround.}}<br />
<br />
=== Broadcom BCM57780 ===<br />
<br />
This Broadcom chipset sometimes does not behave well unless you specify the order of the modules to be loaded. The modules are {{ic|broadcom}} and {{ic|tg3}}, the former needing to be loaded first.<br />
<br />
These steps should help if your computer has this chipset:<br />
$ lspci | grep Ethernet<br />
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)<br />
<br />
If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following (as root):<br />
# modprobe -r tg3<br />
# modprobe broadcom<br />
# modprobe tg3<br />
<br />
Now plug you network cable in. If this solves your problems you can make this permanent by adding {{ic|broadcom}} and {{ic|tg3}} (in this order) to the {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}}:<br />
<br />
MODULES=".. broadcom tg3 .."<br />
<br />
Then rebuild the initramfs:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|These methods may work for other chipsets, such as BCM57760.}}</div>Binotahttps://wiki.archlinux.org/index.php?title=Network_configuration_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=293539Network configuration (正體中文)2014-01-19T09:30:26Z<p>Binota: /* 載入組態設定 */ Translated</p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:Networking (正體中文)]]<br />
[[Category:Getting and installing Arch (正體中文)]]<br />
<br />
[[cs:Configuring Network]]<br />
[[el:Configuring Network]]<br />
[[es:Configuring Network]]<br />
[[fr:Connexions reseau]]<br />
[[it:Configuring Network]]<br />
[[ja:Network Configuration]]<br />
[[nl:Configuring Network]]<br />
[[pt:Configuring Network]]<br />
[[ro:Configurare retea]]<br />
[[ru:Configuring Network]]<br />
[[sk:Configuring Network]]<br />
[[tr:Ağ_Yapılandırması]]<br />
[[zh-CN:Network Configuration]]<br />
[[zh-TW:Network Configuration]]<br />
{{Related articles start}}<br />
{{Related|Jumbo Frames}}<br />
{{Related|Firewalls}}<br />
{{Related|Wireless Setup}}<br />
{{Related|List of Applications#Network Managers}}<br />
{{Related articles end}}<br />
<br />
本頁將介紹如何設定 '''有線''' 網路連線。若您需要設定 '''無線''' 網路,請參考[[Wireless Setup|無線網路設定]]。<br />
<br />
== 檢查連線 ==<br />
<br />
{{注意|若您在執行 ping 時收到了類似 {{ic|ping: icmp open socket: Operation not permitted}} 這樣的錯誤訊息,請嘗試重新安裝 {{ic|iputils}} 軟體包。}} <br />
<br />
一般來說,基本的安裝過程都已經建立了可運作的網路設定。請執行下列指令以進行檢查:<br />
<br />
{{注意|{{ic|-c 3}} 選項表示將會呼叫三次。詳細請參閱 {{ic|man ping}} 。}}<br />
{{注意|您也可以嘗試使用其他的 Domain ,如 www.hinet.net 。}}<br />
<br />
{{hc|$ ping -c 3 www.google.com|<nowiki><br />
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.<br />
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms<br />
64 bytes from 74.125.224.146: icmp_req=2 ttl=50 time=385 ms<br />
64 bytes from 74.125.224.146: icmp_req=3 ttl=50 time=298 ms<br />
<br />
--- www.l.google.com ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 1999ms<br />
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms<br />
</nowiki>}}<br />
<br />
如果沒問題的話,您可能只是想以本文的下列部分來自定您的設定。<br />
<br />
若剛才的指令出現了 unknown hosts 之類的訊息,代表您的機器無法解析網域。這可能是因為您的網路服務提供商/網關造成的。您可以嘗試 ping 一個靜態 IP 以實驗您的機器可否存取網際網路。<br />
{{注意|您也可以嘗試使用其他的 IP ,如 168.95.1.1 。}}<br />
<br />
{{hc|$ ping -c 3 8.8.8.8|<nowiki><br />
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.<br />
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms<br />
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms<br />
64 bytes from 8.8.8.8: icmp_req=3 ttl=53 time=70.6 ms<br />
<br />
--- 8.8.8.8 ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 2002ms<br />
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms<br />
</nowiki>}}<br />
<br />
{{注意|{{ic|8.8.8.8}} 為一個好記的靜態 IP 位置。這是 Google 的主要 DNS 伺服器,這表示其有一定的可信度,並且通常不會被系統或代理伺服器擋下。}}<br />
<br />
若您可以 ping 通該位置,您可能需要試著在 {{ic|/etc/resolv.conf}} 檔案中加上網域名稱伺服器。<br />
<br />
== 設定主機名稱 ==<br />
<br />
[[Wikipedia:Hostname|主機名稱]]為網路中用於識別機器的唯一識別名稱:主機名稱可以通過 {{ic|/etc/hostname}} 檔案來進行設定。一般來說該檔案包含了系統的網域名稱。下面為設定主機名稱的方法:<br />
<br />
# hostnamectl set-hostname '''myhostname'''<br />
<br />
這樣會將 '''myhostname''' 寫入 {{ic|/etc/hostname}} 檔案中。<br />
<br />
詳細請參閱 {{ic|man 5 hostname}} 與 {{ic|man 1 hostnamectl}} 。<br />
<br />
{{注意|<br />
* {{ic|hostnamectl}} 支援 FQDN<br />
* 您不需要編輯 {{ic|/etc/hosts}} 檔案,{{pkg|systemd}} 會提供主機名稱解析且預設安裝於所有系統。<br />
}}<br />
<br />
使用來自 {{Pkg|inetutils}} 的 {{ic|hostname}} 指令以設定臨時主機名稱(直到重新啟動):<br />
<br />
# hostname ''myhostname''<br />
<br />
== 裝置驅動程式 ==<br />
<br />
=== 檢查驅動程式狀態 ===<br />
<br />
[[udev]] 應該會檢測您的網路介面卡([[Wikipedia:Network_interface_controller|NIC]])並自動於啟動時載入必要的模組。檢查 {{ic|lspci -v}} 輸出內容中的「Ethernet controller」 項目(或類似的)。這應該會告訴您哪些核心模組包含了網路設備的驅動程式。舉例來說:<br />
<br />
{{hc|$ lspci -v|<br />
02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)<br />
...<br />
Kernel driver in use: atl1<br />
Kernel modules: atl1<br />
}}<br />
<br />
接下來,確認該驅動程式已經通過 {{ic|dmesg <nowiki>|</nowiki> grep ''module_name''}} 載入了。舉例來說:<br />
<br />
$ dmesg | grep atl1<br />
...<br />
atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex<br />
<br />
若驅動程式已成功加載可以跳過接下來這段。否則,您會需要知道哪些模組時您的特定型號的裝置需要哪個模組。<br />
<br />
=== 載入裝置模組 ===<br />
<br />
以 Google 搜尋正確的晶片組模組/驅動程式。常見的驅動模組有 Realtek 晶片組網卡的 {{ic|8139too}} ,或是 SiS 晶片組網卡的 {{ic|sis900}}。當您知道要使用何種模組了之後,試著[[Kernel modules#Manual module handling|手動將其載入]]。若您的到了錯誤訊息告訴您找不到該模組,則該驅動可能未包含於 Arch 核心中。您可以在 [[AUR]] 中搜尋該模組名稱。<br />
<br />
若 udev 未在開機期間檢測與載入正確的模組,請參閱 [[Kernel modules#Loading]]。<br />
<br />
== 網路介面 ==<br />
<br />
=== 裝置名稱 ===<br />
<br />
對於多網路卡的電腦,固定裝置名稱非常重要。許多設定問題都是因為介面卡名稱的改動造成的。<br />
<br />
[[udev]] 負責命名裝置。Systemd v197 則有[http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames 可預測之網路介面名稱]並可自動支配靜態名稱給網路裝置。介面名稱以 {{ic|en}} (乙太網路)、 {{ic|wl}} (無線網路) 或是 {{ic|ww}} (WWAN)作為前置字串並附上一個自動產生的識別名稱,進而產生了類似 {{ic|enp0s25}} 這樣的名稱。 <br />
<br />
要禁用這種行為,可以加上一個連接:<br />
<br />
# ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules<br />
<br />
自早期版本升級 systemd 的使用者會有一自動建立的空規則檔案。因此,若您想使用一貫的裝置名稱,只需要刪除該檔案。<br />
<br />
{{提示|您可以執行 {{ic|ip link}} 或是 {{ic|ls /sys/class/net}} 以列出所有可用的介面。}}<br />
<br />
{{注意|當您更改了介面名稱規則後,別忘了更新所有跟網路有關的組態檔案與自定的 systemd unit 檔案以因應該更改。特別是當您啟用了 [[netctl#Basic method|netctl 靜態設定檔]] ,請執行 {{ic|netctl reenable ''profile''}} 以更新所有產生的服務檔案。}}<br />
<br />
==== 更改裝置名稱 ====<br />
<br />
您可以使用 udev-rule 來手動定義裝置名稱。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"<br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"<br />
</nowiki>}}<br />
<br />
請注意這兩點:<br />
<br />
* 使用這個指令以取得 MAC 位置:{{ic|cat /sys/class/net/''device_name''/address}}。<br />
* 請確定 udev 規則中使用的是小寫的十六進位數值而不是大寫。<br />
<br />
若您的網路卡為動態 MAC ,您可以使用 DEVPATH ,例如:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"<br />
</nowiki>}}<br />
<br />
{{注意|當使用了靜態的名稱時,'''應該要避免使用類似 "eth''X''" 與 "wlan''X''"''' 這樣的名稱,因為這可能會導致核心與 udev 在開機時發生衝突。而剛好相反地,最好使用核心預設不會使用的介面名稱,如 {{ic|net0}} 、 {{ic|net1}} 、 {{ic|wifi0}} 、 {{ic|wifi1}} 。詳細說明請參閱 [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames systemd] 文件。}}<br />
<br />
=== 設定裝置的 MTU 與佇列長度 ===<br />
<br />
您可以手動定義 udev 規則來更改裝置的 MTU 與佇列長度。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1480", ATTR{tx_queue_len}="2000"<br />
</nowiki>}}<br />
<br />
=== 取得目前的裝置名稱 ===<br />
<br />
目前的 NIC 名稱可以通過 sysfs 找到<br />
<br />
{{hc|$ ls /sys/class/net|<br />
lo eth0 eth1 firewire0<br />
}}<br />
<br />
=== 啟用與禁用網路介面 ===<br />
<br />
您可以使用下列指令來啟用或禁用網路介面:<br />
<br />
# ip link set eth0 up<br />
# ip link set eth0 down<br />
<br />
要確認結果,請執行:<br />
<br />
{{hc|$ ip link show dev eth0|<br />
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000<br />
...<br />
}}<br />
<br />
== 組態設定 IP 位址 ==<br />
<br />
您有兩個選擇:使用 [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]] 指派動態位址,或是使用「靜態」的位址。<br />
<br />
=== 動態 IP 位址 ===<br />
<br />
==== 手動執行 DHCP 用戶端 Daemon ====<br />
<br />
{{注意|請特別注意 {{ic|dhcpcd}} (DHCP ''Client'' Daemon,DHCP 用戶端 Daemon) 與 {{ic|dhcpd}} (DHCP ''(server)'' daemon,DHCP 伺服端 Daemon) 間的差異。}}<br />
<br />
{{hc|# dhcpcd eth0|<br />
dhcpcd: version 5.1.1 starting<br />
dhcpcd: eth0: broadcasting for a lease<br />
...<br />
dhcpcd: eth0: leased 192.168.1.70 for 86400 seconds<br />
}}<br />
<br />
緊接著, {{ic|ip addr show dev eth0}} 應該要顯示出您的 inet 位址。<br />
<br />
對部分的人而言,{{ic|dhcpcd}} 失敗時,可以使用 {{ic|dhclient}} (位於 {{Pkg|dhclient}} 軟體包中)<br />
<br />
==== 於啟動時執行 DHCP ====<br />
<br />
若您只是想使用 DHCP 來連線至您的乙太網路連線,您可以使用 {{ic|dhcpcd@.service}} (由 {{Pkg|dhcpcd}} 軟體包提供)。<br />
<br />
要啟動 {{ic|eth0}} 上的 DHCP ,只需要使用:<br />
<br />
# systemctl start dhcpcd@eth0.service<br />
<br />
您可以下列方法啟用該服務讓其於開機時自動啟動:<br />
<br />
# systemctl enable dhcpcd@eth0.service<br />
<br />
若您用了 DHCP 且您並 '''不想''' 讓您的 DNS 伺服器在每次啟動您的網路時自動指派,請將下列內容加到 {{ic|dhcpcd.conf}} 的最後一段中:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nohook resolv.conf<br />
}}<br />
<br />
另外,若您位於基於 MAC 位址的用戶端 IP 位址進行過濾的 DHCPv4 網路,您可能需要修改下列內容:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 Client ID as per RFC4361. <br />
duid<br />
}}<br />
<br />
為:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the hardware address of the interface for the Client ID (DHCPv4).<br />
clientid<br />
}}<br />
<br />
否則,您可能會因為 DHCP 伺服器無法正確讀取您的 [http://en.wikipedia.org/wiki/DHCPv6 DHCPv6-style] 用戶端 ID 而無法使用。詳細請參閱 [http://tools.ietf.org/html/rfc4361 RFC 4361] 。<br />
<br />
為防止 {{ic|dhcpcd}} 加入網域名稱伺服器至 {{ic|/etc/resolv.conf}} 中,請於其中使用 {{ic|nooption}} 選項:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nooption domain_name_servers<br />
}}<br />
<br />
接著加入您自己的 DNS 名稱伺服器至 {{ic|/etc/resolv.conf}} 中。<br />
<br />
若有多個不同的執行緒要控制 {{ic|/etc/resolv.conf}} (如 {{Pkg|dhcpcd}} 與 VPN 用戶端),您可能會想要使用 {{Pkg|openresolv}} 軟體包。使用 {{Pkg|openresolv}} 並不需要額外地設定 {{Pkg|dhcpcd}} 。<br />
<br />
==== DHCP 靜態路由 ====<br />
若您需要加入靜態路由用戶端,請於 {{ic|/usr/lib/dhcpcd/dhcpcd-hooks}} 中建立一個新的 dhcpcd hook-script 。下列範例展示了加入靜態路由至一個通過閘道器為 192.168.192.5 ,位於 10.11.12.0/24 的 VPN 子網路:<br />
{{hc|/usr/lib/dhcpcd/dhcpcd-hooks/40-vpnroute|<br />
ip route add 10.11.12.0/24 via 192.168.192.5<br />
}}<br />
前置字串''40''表示其於 dhcpcd 啟動時的最後執行 hook-script 。<br />
<br />
=== 靜態 IP 位址 ===<br />
<br />
您可能因為各種原因而希望在您的網路中指派靜態 IP 位址,例如靜態的位址可以獲得一定程度的可預測性,或是您沒有可用的 DHCP 伺服器。<br />
<br />
{{注意|若您共通過 Windows 機器共享您的網路而沒有路由器,請確保兩台電腦皆使用了靜態 IP 位址以避免區域網路問題。}}<br />
<br />
您需要:<br />
<br />
* 靜態 IP 位址<br />
* [[Wikipedia:Subnetwork|子網路遮罩]]<br />
* [[Wikipedia:Broadcast_address|廣播位址]]<br />
* [[Wikipedia:Default_gateway|閘道器]]的 IP 位址<br />
<br />
若您處在內部網路中,使用 192.168.*.* 這樣的 IP 位址較為安全,搭配其的子網路遮罩 255.255.255.0 ,廣播位址為 192.168.*.255 。而閘道器通常是 192.168.*.1 或是 192.168.*.254 。<br />
<br />
==== 手動指派 ====<br />
<br />
您可於控制台中指派一靜態 IP 位址:<br />
<br />
# ip addr add <IP 位址>/<子網路遮罩> broadcast <廣播> dev <介面><br />
<br />
舉例來說:<br />
<br />
# ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev eth0<br />
<br />
{{注意|子網路遮罩使用了 [[Wikipedia:CIDR_notation|CIDR 表示法]](CIDR,Classless Inter-Domain Routing,無類別網路間路由)。}}<br />
<br />
詳情請參閱 {{ic|man ip}} 。<br />
<br />
以類似下列方法加上您的閘道器:<br />
<br />
# ip route add default via <預設閘道器 IP 位址><br />
<br />
舉例來說:<br />
<br />
# ip route add default via 192.168.1.1<br />
<br />
若您得到了 "No such process" 這樣的錯誤訊息,這代表您必須以 root 執行 {{ic|ip link set dev eth0 up}} 。<br />
<br />
==== 於啟動時通過 systemd 手動連線 ====<br />
<br />
先確保 dhcpcd 已停止並禁用:<br />
<br />
# systemctl status dhcpcd.service<br />
<br />
接著為 [[systemd]] 服務建立一個檔案。以正確的網路介面名稱取代其中的 {{ic|<interface>}} :<br />
<br />
{{hc|/etc/conf.d/network@<interface>|<nowiki><br />
address=192.168.0.15<br />
netmask=24<br />
broadcast=192.168.0.255<br />
gateway=192.168.0.1<br />
</nowiki>}}<br />
<br />
建立 systemd unit 檔案:<br />
<br />
{{hc|/etc/systemd/system/network@.service|<nowiki><br />
[Unit]<br />
Description=Network connectivity (%i)<br />
Wants=network.target<br />
Before=network.target<br />
BindsTo=sys-subsystem-net-devices-%i.device<br />
After=sys-subsystem-net-devices-%i.device<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
EnvironmentFile=/etc/conf.d/network@%i<br />
<br />
ExecStart=/usr/bin/ip link set dev %i up<br />
ExecStart=/usr/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i<br />
ExecStart=/usr/bin/ip route add default via ${gateway}<br />
<br />
ExecStop=/usr/bin/ip addr flush dev %i<br />
ExecStop=/usr/bin/ip link set dev %i down<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
啟用該 unit 並將其啟動,傳入介面名稱,例如 eno1 :<br />
<br />
# systemctl enable network@eno1.service<br />
# systemctl start network@eno1.service<br />
<br />
若您需要手動設定 nameservers ,請編輯 {{ic|/etc/resolv.conf}} 檔案:<br />
<br />
{{hc|/etc/resolv.conf|<br />
nameserver 208.67.222.222<br />
nameserver 208.67.220.220}}<br />
<br />
若 {{ic|/etc/resolv.conf}} 被持續遭到複寫,請參考 [[Resolv.conf]] 以瞭解如何解決此問題。<br />
<br />
有幾個類似的方法來讓 systemd 啟動網路,其中的差異為檔案內容,並且其可以寫死 EnvironmentFile 定義的參考檔案中抓到的參數。因此可以作為一種替代的,將介面名稱放置於 /etc/conf.d/ 中的 EnvironmentFile 接著直接使用介面名稱而不是 %i 。如此一來,檔案名稱便不需要「@」。這也是一種有用的方法來閱讀 http://www.freedesktop.org/software/systemd/man/systemd.unit.html 上的 systemd 服務文件。<br />
<br />
==== 計算位址 ====<br />
<br />
您可以使用 {{Pkg|ipcalc}} 提供的 {{ic|ipcalc}} 來計算 IP 廣播、網域、子網路遮罩與主機範圍等進階設定舉例來說,我使用了位於防火牆後的乙太網路來連線 Windows 機器至 Arch。為了安全性與網路組織,我將他們放置於各自獨立的網路,接著組態設定子網路遮罩與廣播位址,如此一來網路中就只有兩台機器。為了找出子網路遮罩跟廣播位址,我使用了 ipcalc ,提供其 Arch firewire nic 的 IP 位址 10.66.66.1 ,並指定 ipcalc 要建立一個只有兩台主機的網路。<br />
<br />
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|<nowiki><br />
Address: 10.66.66.1<br />
<br />
Netmask: 255.255.255.252 = 30<br />
Network: 10.66.66.0/30<br />
HostMin: 10.66.66.1<br />
HostMax: 10.66.66.2<br />
Broadcast: 10.66.66.3<br />
Hosts/Net: 2 Class A, Private Internet<br />
</nowiki>}}<br />
<br />
== 載入組態設定 ==<br />
<br />
要測試您的設定,您可以重新啟動電腦或是重新載入相關的 systemd 服務:<br />
<br />
# systemctl restart dhcpcd@eth0<br />
<br />
您可以試著 ping 您的閘道器、 DNS 伺服器、 ISP 提供商或是其他網路上的站台。如此一來便可以確認您的網路連線問題為何,例如:<br />
<br />
$ ping -c 3 www.google.com<br />
<br />
== 附加設定 ==<br />
<br />
=== 筆記型電腦之 ifplugd ===<br />
<br />
{{Tip|{{Pkg|dhcpcd}} provides the same feature out of the box.}}<br />
<br />
{{Pkg|ifplugd}} in [[Official Repositories]] is a daemon which will automatically configure your Ethernet device when a cable is plugged in and automatically unconfigure it if the cable is pulled. This is useful on laptops with onboard network adapters, since it will only configure the interface when a cable is really connected. Another use is when you just need to restart the network but do not want to restart the computer or do it from the shell.<br />
<br />
By default it is configured to work for the {{ic|eth0}} device. This and other settings like delays can be configured in {{ic|/etc/ifplugd/ifplugd.conf}}.<br />
<br />
{{Note|[[Netctl]] package includes {{ic|netctl-ifplugd@.service}}, otherwise you can use {{ic|ifplugd@.service}} from {{Pkg|ifplugd}} package. Use for example {{ic|systemctl enable ifplugd@eth0.service}}.}}<br />
<br />
=== Bonding 或 LAG ===<br />
<br />
See [[netctl#Bonding]].<br />
<br />
=== IP 別名 ===<br />
<br />
{{Expansion|Manual method using [[Core Utilities#ip|ip]] should be added; then move current example using ''netctl'' into [[netctl]].}}<br />
<br />
IP aliasing is the process of adding more than one IP address to a network interface. With this, one node on a network can have multiple connections to a network, each serving a different purpose. Typical uses are virtual hosting of Web and FTP servers, or reorganizing servers without having to update any other machines (this is especially useful for nameservers).<br />
<br />
==== 範例 ====<br />
<br />
You will need {{Pkg|netctl}} from the [[Official Repositories]].<br />
<br />
Prepare the configuration:<br />
<br />
{{hc|/etc/netctl/mynetwork|<nowiki><br />
Connection='ethernet'<br />
Description='Five different addresses on the same NIC.'<br />
Interface='eth0'<br />
IP='static'<br />
Address=('192.168.1.10' '192.168.178.11' '192.168.1.12' '192.168.1.13' '192.168.1.14' '192.168.1.15')<br />
Gateway='192.168.1.1'<br />
DNS=('192.168.1.1')<br />
</nowiki>}}<br />
<br />
Then simply execute: <br />
<br />
$ netctl start mynetwork<br />
<br />
=== 更改 MAC/硬體 位址 ===<br />
<br />
請參閱 [[MAC Address Spoofing]] 。<br />
<br />
=== Internet Sharing ===<br />
<br />
請參閱 [[Internet Sharing]] 。<br />
<br />
=== Router Configuration ===<br />
<br />
請參閱 [[Router]] 。<br />
<br />
=== 區域網路主機名稱解析 ===<br />
<br />
The pre-requisite is to [[#Set the hostname]] after which hostname resolution works on the local system itself {{hc|$ ping hostname|<br />
PING hostname <nowiki>(192.168.1.2) 56(84) bytes of data.<br />
64 bytes from hostname (192.168.1.2): icmp_seq=1 ttl=64 time=0.043 ms</nowiki>}}<br />
To enable other machines to address the host by name, either a manual configuration of the respective {{ic|/etc/hosts}} files or a service to propagate/resolve the name is required. <br />
<br />
When setting up a DNS server such as [[BIND]] or [[Unbound]] is overkill, manually editing your {{ic|/etc/hosts}} is too cumbersome, or when you want more flexibility with dynamic leaving and joining of hosts to the network, it is possible to handle hostname resolution on your local network using zero-configuration networking. There are two options available:<br />
<br />
*[[Samba]] provides hostname resolution via Microsoft's '''NetBIOS'''. It only requires installation of {{Pkg|samba}} and enabling of the {{ic|nmbd.service}} service. Computers running Windows, OS X, or Linux with {{ic|nmbd}} running, will be able to find your machine.<br />
<br />
*[[Avahi]] provides hostname resolution via '''zeroconf''', also known as Avahi or Bonjour. It requires slightly more complex configuration than Samba: see [[Avahi#Hostname resolution]] for details. Computers running OS X, or Linux with an Avahi daemon running, will be able to find your machine. Windows does not have an built-in Avahi client or daemon.<br />
<br />
== 診斷 ==<br />
<br />
=== Swapping computers on the cable modem ===<br />
<br />
Some cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.<br />
<br />
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].<br />
<br />
=== The TCP window scaling problem ===<br />
<br />
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.<br />
<br />
Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html RFC 1323] was written to improve the situation: Window Scaling. The "window" value, provided in all packets, will be modified by a Scale Factor defined once, at the very beginning of the connection.<br />
<br />
That 8-bit Scale Factor allows the Window to be up to 32 times higher than the initial 64Kb.<br />
<br />
It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts.<br />
<br />
The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.<br />
<br />
The resulting connection is at best very slow or broken.<br />
<br />
==== How to diagnose the problem ====<br />
<br />
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).<br />
<br />
When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|ip addr}} will report normal status... and actually everything appears normal.<br />
<br />
If you cannot browse any website, but you can ping some random hosts, chances are great that you're experiencing this problem: ping uses ICMP and is not affected by TCP problems.<br />
<br />
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).<br />
<br />
==== How to fix it (The bad way) ====<br />
<br />
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.<br />
<br />
# echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem<br />
<br />
==== How to fix it (The good way) ====<br />
<br />
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.d/99-disable_window_scaling.conf}} (see also [[sysctl]])<br />
<br />
net.ipv4.tcp_window_scaling = 0<br />
<br />
==== How to fix it (The best way) ====<br />
<br />
This problem is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.<br />
<br />
==== More about it ====<br />
<br />
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].<br />
<br />
There are also several relevant threads on the LKML.<br />
<br />
=== Realtek no link / WOL problem ===<br />
<br />
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice a problem where the NIC seems to be disabled on boot and has no Link light. This can usually be found on a dual boot system where Windows is also installed. It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause. These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots. You will be able to notice if this problem is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off. Normal operation should be that the link light is always on as long as the system is on, even during POST. This problem will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this problem:<br />
<br />
==== Method 1 - Rollback/change Windows driver ====<br />
<br />
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).<br />
<br />
==== Method 2 - Enable WOL in Windows driver ====<br />
<br />
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems). In Windows, under Device Manager, find your Realtek network adapter and double-click it. Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.<br />
<br />
In Windows XP (example)<br />
Right click my computer<br />
--> Hardware tab<br />
--> Device Manager<br />
--> Network Adapters<br />
--> "double click" Realtek ...<br />
--> Advanced tab<br />
--> Wake-On-Lan After Shutdown<br />
--> Enable<br />
<br />
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{ic|Disable}} has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.}}<br />
<br />
==== Method 3 - Newer Realtek Linux driver ====<br />
<br />
Any newer driver for these Realtek cards can be found for Linux on the realtek site. (untested but believed to also solve the problem).<br />
<br />
==== Method 4 - Enable ''LAN Boot ROM'' in BIOS/CMOS ====<br />
<br />
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.<br />
<br />
{{Note|This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.}}<br />
<br />
=== DLink G604T/DLink G502T DNS problem ===<br />
<br />
Users with a DLink G604T/DLink G502T router, using DHCP and have firmware v2.00+ (typically users with AUS firmware) may have problems with certain programs not resolving the DNS. One of these programs are unfortunatley pacman. The problem is basically the router in certain situations is not sending the DNS properly to DHCP, which causes programs to try and connect to servers with an IP address of 1.0.0.0 and fail with a connection timed out error<br />
<br />
==== How to diagnose the problem ====<br />
<br />
The best way to diagnose the problem is to use Firefox/Konqueror/links/seamonkey and to enable wget for pacman. If this is a fresh install of Arch Linux, then you may want to consider installing {{ic|links}} through the live CD.<br />
<br />
Firstly, enable wget for pacman (since it gives us info about pacman when it is downloading packages)<br />
Open {{ic|/etc/pacman.conf}} with your favourite editor and uncomment the following line (remove the # if it is there)<br />
<br />
XferCommand=/usr/bin/wget --passive-ftp -c -O %o %u<br />
<br />
While you are editing {{ic|/etc/pacman.conf}}, check the default mirror that pacman uses to download packages.<br />
<br />
Now open up the default mirror in an Internet browser to see if the mirror actually works. If it does work, then do {{ic|pacman -Syy}} (otherwise pick another working mirror and set it to the pacman default). If you get something similar to the following (notice the 1.0.0.0),<br />
<br />
<nowiki>ftp://mirror.pacific.net.au/linux/archlinux/extra/os/i686/extra.db.tar.gz</nowiki><br />
=> '/var/lib/pacman/community.db.tar.gz.part'<br />
Resolving mirror.pacific.net.au... 1.0.0.0<br />
<br />
then you most likely have this problem. The 1.0.0.0 means it is unable to resolve DNS, so we must add it to {{ic|/etc/resolv.conf}}.<br />
<br />
==== How to fix it ====<br />
<br />
{{Out of date|{{Pkg|dhcpcd}} does not use {{ic|/etc/conf.d/dhcpcd}} any more.}}<br />
<br />
Basically what we need to do is to manually add the DNS servers to our {{ic|/etc/resolv.conf}} file. The problem is that DHCP automatically deletes and replaces this file on boot, so we need to edit {{ic|/etc/conf.d/dhcpcd}} and change the flags to stop DHCP from doing this.<br />
<br />
When you open {{ic|/etc/conf.d/dhcpcd}}, you should see something close to the following:<br />
<br />
DHCPCD_ARGS="-t 30 -h $HOSTNAME"<br />
<br />
Add the {{ic|-R}} flag to the arguments, e.g.,<br />
<br />
DHCPCD_ARGS="-R -t 30 -h $HOSTNAME"<br />
<br />
{{Note|1=If you are using {{Pkg|dhcpcd}} >= 4.0.2, the {{ic|-R}} flag has been deprecated. Please see the [[#Run DHCP at boot]] section for information on how to use a custom {{ic|/etc/resolv.conf}} file.}}<br />
<br />
Save and close the file; now open {{ic|/etc/resolv.conf}}. You should see a single nameserver (most likely 10.1.1.1). This is the gateway to your router, which we need to connect to in order to get the DNS servers of your ISP. Paste the IP address into your browser and log in to your router. Go to the DNS section, and you should see an IP address in the Primary DNS Server field; copy it and paste it as a nameserver '''ABOVE''' the current gateway one.<br />
<br />
For example, {{ic|/etc/resolv.conf}} should look something along the lines of:<br />
<br />
nameserver 10.1.1.1<br />
<br />
If my primary DNS server is 211.29.132.12, then change {{ic|/etc/resolv.conf}} to:<br />
<br />
nameserver 211.29.132.12<br />
nameserver 10.1.1.1<br />
<br />
Now restart the network daemon by running {{ic|systemctl restart dhcpcd@<interface>}} and do {{ic|pacman -Syy}}. If it syncs correctly with the server, then the problem is solved.<br />
<br />
==== More about it ====<br />
<br />
This is the whirlpool forum (Australian ISP community) which talks about and gives the same solution to the problem:<br />
<br />
http://forums.whirlpool.net.au/forum-replies-archive.cfm/461625.html<br />
<br />
=== Check DHCP problem by releasing IP first ===<br />
<br />
Problem may occur when DHCP get wrong IP assignment. For example when two routers are tied together through VPN. The router that is connected to me by VPN may assigning IP address. To fix it. On a console, as root, release IP address:<br />
<br />
# dhcpcd -k<br />
<br />
Then request a new one:<br />
<br />
# dhcpcd<br />
<br />
Maybe you had to run those two commands many times.<br />
<br />
=== No eth0 with Atheros AR8161 ===<br />
<br />
{{Note|With the 3.10.2-1-ARCH kernel update, the alx ethernet driver module is included in the package.}}<br />
<br />
With the Atheros AR8161 Gigabit Ethernet card, the ethernet connection is not working out-of-the-box (with the installation media of March 2013). The module "alx" needs to be loaded but is not present.<br />
<br />
The driver from [http://linuxwireless.org/en/users/Download/stable/#compat-wireless_stable_releases compat-wireless] (that has become [https://backports.wiki.kernel.org/index.php/Releases compat-drives] since linux 3.7) need to be installed. The "-u" postfix annotates that Qualcomm have applied a driver under a unified driver.<br />
<br />
$ wget https://www.kernel.org/pub/linux/kernel/projects/backports/2013/03/28/compat-drivers-2013-03-28-5-u.tar.bz2<br />
$ tar xjf compat*<br />
$ cd compat*<br />
$ ./scripts/driver-select alx<br />
$ make<br />
$ sudo make install<br />
$ sudo modprobe alx<br />
<br />
The alx driver has not been added to Linux kernel due to various problems. Compatibility between the different kernel versions has been spotty. For better support follow the [http://lists.infradead.org/mailman/listinfo/unified-drivers mailing list]and [http://www.linuxfoundation.org/collaborate/workgroups/networking/alx alx page]for latest working solution for alx.<br />
<br />
The driver must be built and installed after every kernel change.<br />
<br />
Alternatively you can use the AUR package for [https://aur.archlinux.org/packages/compat-drivers-patched/ compat drivers], which installs many other drivers.<br />
<br />
=== No eth0 with Atheros AR9485 ===<br />
<br />
The ethernet (eth0) for Atheros AR9485 are not working out-of-the-box (with installation media of March 2013). The working solution for this is to install the package [https://aur.archlinux.org/packages/compat-drivers-patched/ compat-drivers-patched] from AUR.<br />
<br />
=== No carrier / no connection after suspend ===<br />
After suspend to RAM no connection is found although the network cable is plugged in. <br />
This may be caused by PCI power management. What is the output of<br />
<br />
# ip link show eth0<br />
<br />
If the line contains "NO-CARRIER" even though there's a cable connected to your eth0 port, it is possible that the device was auto-suspended and the media sense feature doesn't work. To solve this, first you need to find your ethernet controllers PCI address by<br />
<br />
# lspci<br />
<br />
This should look similar to this:<br />
<br />
...<br />
00:19.0 Ethernet controller: Intel Corporation 82577LM Gigabit Network Connection (rev 06)<br />
...<br />
<br />
So the address is 00:19.0.<br />
Now check the PM status of the device by issuing<br />
<br />
# cat "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
substituting 00:19.0 with the address obtained from lspci.<br />
If the output reads "auto", you can try to bring the device out of suspend by<br />
<br />
# echo on > "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
Don't forget to substitute the address again.<br />
<br />
{{Note|1=This appears to be a bug in kernel 3.8.4.1- (3.8.8.1 is still affected): [https://bbs.archlinux.org/viewtopic.php?id=159837&p=2 Forum discussion.] It also appears a fix is [https://lkml.org/lkml/2013/1/18/147 on the way. (It will be likely fixed in 3.9.)] In the meantime, the above is a suitable workaround.}}<br />
<br />
=== Broadcom BCM57780 ===<br />
<br />
This Broadcom chipset sometimes does not behave well unless you specify the order of the modules to be loaded. The modules are {{ic|broadcom}} and {{ic|tg3}}, the former needing to be loaded first.<br />
<br />
These steps should help if your computer has this chipset:<br />
$ lspci | grep Ethernet<br />
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)<br />
<br />
If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following (as root):<br />
# modprobe -r tg3<br />
# modprobe broadcom<br />
# modprobe tg3<br />
<br />
Now plug you network cable in. If this solves your problems you can make this permanent by adding {{ic|broadcom}} and {{ic|tg3}} (in this order) to the {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}}:<br />
<br />
MODULES=".. broadcom tg3 .."<br />
<br />
Then rebuild the initramfs:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|These methods may work for other chipsets, such as BCM57760.}}</div>Binotahttps://wiki.archlinux.org/index.php?title=Network_configuration_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=293537Network configuration (正體中文)2014-01-19T09:27:34Z<p>Binota: /* 組態設定 IP 位址 */ Translated</p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:Networking (正體中文)]]<br />
[[Category:Getting and installing Arch (正體中文)]]<br />
<br />
[[cs:Configuring Network]]<br />
[[el:Configuring Network]]<br />
[[es:Configuring Network]]<br />
[[fr:Connexions reseau]]<br />
[[it:Configuring Network]]<br />
[[ja:Network Configuration]]<br />
[[nl:Configuring Network]]<br />
[[pt:Configuring Network]]<br />
[[ro:Configurare retea]]<br />
[[ru:Configuring Network]]<br />
[[sk:Configuring Network]]<br />
[[tr:Ağ_Yapılandırması]]<br />
[[zh-CN:Network Configuration]]<br />
[[zh-TW:Network Configuration]]<br />
{{Related articles start}}<br />
{{Related|Jumbo Frames}}<br />
{{Related|Firewalls}}<br />
{{Related|Wireless Setup}}<br />
{{Related|List of Applications#Network Managers}}<br />
{{Related articles end}}<br />
<br />
本頁將介紹如何設定 '''有線''' 網路連線。若您需要設定 '''無線''' 網路,請參考[[Wireless Setup|無線網路設定]]。<br />
<br />
== 檢查連線 ==<br />
<br />
{{注意|若您在執行 ping 時收到了類似 {{ic|ping: icmp open socket: Operation not permitted}} 這樣的錯誤訊息,請嘗試重新安裝 {{ic|iputils}} 軟體包。}} <br />
<br />
一般來說,基本的安裝過程都已經建立了可運作的網路設定。請執行下列指令以進行檢查:<br />
<br />
{{注意|{{ic|-c 3}} 選項表示將會呼叫三次。詳細請參閱 {{ic|man ping}} 。}}<br />
{{注意|您也可以嘗試使用其他的 Domain ,如 www.hinet.net 。}}<br />
<br />
{{hc|$ ping -c 3 www.google.com|<nowiki><br />
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.<br />
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms<br />
64 bytes from 74.125.224.146: icmp_req=2 ttl=50 time=385 ms<br />
64 bytes from 74.125.224.146: icmp_req=3 ttl=50 time=298 ms<br />
<br />
--- www.l.google.com ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 1999ms<br />
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms<br />
</nowiki>}}<br />
<br />
如果沒問題的話,您可能只是想以本文的下列部分來自定您的設定。<br />
<br />
若剛才的指令出現了 unknown hosts 之類的訊息,代表您的機器無法解析網域。這可能是因為您的網路服務提供商/網關造成的。您可以嘗試 ping 一個靜態 IP 以實驗您的機器可否存取網際網路。<br />
{{注意|您也可以嘗試使用其他的 IP ,如 168.95.1.1 。}}<br />
<br />
{{hc|$ ping -c 3 8.8.8.8|<nowiki><br />
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.<br />
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms<br />
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms<br />
64 bytes from 8.8.8.8: icmp_req=3 ttl=53 time=70.6 ms<br />
<br />
--- 8.8.8.8 ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 2002ms<br />
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms<br />
</nowiki>}}<br />
<br />
{{注意|{{ic|8.8.8.8}} 為一個好記的靜態 IP 位置。這是 Google 的主要 DNS 伺服器,這表示其有一定的可信度,並且通常不會被系統或代理伺服器擋下。}}<br />
<br />
若您可以 ping 通該位置,您可能需要試著在 {{ic|/etc/resolv.conf}} 檔案中加上網域名稱伺服器。<br />
<br />
== 設定主機名稱 ==<br />
<br />
[[Wikipedia:Hostname|主機名稱]]為網路中用於識別機器的唯一識別名稱:主機名稱可以通過 {{ic|/etc/hostname}} 檔案來進行設定。一般來說該檔案包含了系統的網域名稱。下面為設定主機名稱的方法:<br />
<br />
# hostnamectl set-hostname '''myhostname'''<br />
<br />
這樣會將 '''myhostname''' 寫入 {{ic|/etc/hostname}} 檔案中。<br />
<br />
詳細請參閱 {{ic|man 5 hostname}} 與 {{ic|man 1 hostnamectl}} 。<br />
<br />
{{注意|<br />
* {{ic|hostnamectl}} 支援 FQDN<br />
* 您不需要編輯 {{ic|/etc/hosts}} 檔案,{{pkg|systemd}} 會提供主機名稱解析且預設安裝於所有系統。<br />
}}<br />
<br />
使用來自 {{Pkg|inetutils}} 的 {{ic|hostname}} 指令以設定臨時主機名稱(直到重新啟動):<br />
<br />
# hostname ''myhostname''<br />
<br />
== 裝置驅動程式 ==<br />
<br />
=== 檢查驅動程式狀態 ===<br />
<br />
[[udev]] 應該會檢測您的網路介面卡([[Wikipedia:Network_interface_controller|NIC]])並自動於啟動時載入必要的模組。檢查 {{ic|lspci -v}} 輸出內容中的「Ethernet controller」 項目(或類似的)。這應該會告訴您哪些核心模組包含了網路設備的驅動程式。舉例來說:<br />
<br />
{{hc|$ lspci -v|<br />
02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)<br />
...<br />
Kernel driver in use: atl1<br />
Kernel modules: atl1<br />
}}<br />
<br />
接下來,確認該驅動程式已經通過 {{ic|dmesg <nowiki>|</nowiki> grep ''module_name''}} 載入了。舉例來說:<br />
<br />
$ dmesg | grep atl1<br />
...<br />
atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex<br />
<br />
若驅動程式已成功加載可以跳過接下來這段。否則,您會需要知道哪些模組時您的特定型號的裝置需要哪個模組。<br />
<br />
=== 載入裝置模組 ===<br />
<br />
以 Google 搜尋正確的晶片組模組/驅動程式。常見的驅動模組有 Realtek 晶片組網卡的 {{ic|8139too}} ,或是 SiS 晶片組網卡的 {{ic|sis900}}。當您知道要使用何種模組了之後,試著[[Kernel modules#Manual module handling|手動將其載入]]。若您的到了錯誤訊息告訴您找不到該模組,則該驅動可能未包含於 Arch 核心中。您可以在 [[AUR]] 中搜尋該模組名稱。<br />
<br />
若 udev 未在開機期間檢測與載入正確的模組,請參閱 [[Kernel modules#Loading]]。<br />
<br />
== 網路介面 ==<br />
<br />
=== 裝置名稱 ===<br />
<br />
對於多網路卡的電腦,固定裝置名稱非常重要。許多設定問題都是因為介面卡名稱的改動造成的。<br />
<br />
[[udev]] 負責命名裝置。Systemd v197 則有[http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames 可預測之網路介面名稱]並可自動支配靜態名稱給網路裝置。介面名稱以 {{ic|en}} (乙太網路)、 {{ic|wl}} (無線網路) 或是 {{ic|ww}} (WWAN)作為前置字串並附上一個自動產生的識別名稱,進而產生了類似 {{ic|enp0s25}} 這樣的名稱。 <br />
<br />
要禁用這種行為,可以加上一個連接:<br />
<br />
# ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules<br />
<br />
自早期版本升級 systemd 的使用者會有一自動建立的空規則檔案。因此,若您想使用一貫的裝置名稱,只需要刪除該檔案。<br />
<br />
{{提示|您可以執行 {{ic|ip link}} 或是 {{ic|ls /sys/class/net}} 以列出所有可用的介面。}}<br />
<br />
{{注意|當您更改了介面名稱規則後,別忘了更新所有跟網路有關的組態檔案與自定的 systemd unit 檔案以因應該更改。特別是當您啟用了 [[netctl#Basic method|netctl 靜態設定檔]] ,請執行 {{ic|netctl reenable ''profile''}} 以更新所有產生的服務檔案。}}<br />
<br />
==== 更改裝置名稱 ====<br />
<br />
您可以使用 udev-rule 來手動定義裝置名稱。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"<br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"<br />
</nowiki>}}<br />
<br />
請注意這兩點:<br />
<br />
* 使用這個指令以取得 MAC 位置:{{ic|cat /sys/class/net/''device_name''/address}}。<br />
* 請確定 udev 規則中使用的是小寫的十六進位數值而不是大寫。<br />
<br />
若您的網路卡為動態 MAC ,您可以使用 DEVPATH ,例如:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"<br />
</nowiki>}}<br />
<br />
{{注意|當使用了靜態的名稱時,'''應該要避免使用類似 "eth''X''" 與 "wlan''X''"''' 這樣的名稱,因為這可能會導致核心與 udev 在開機時發生衝突。而剛好相反地,最好使用核心預設不會使用的介面名稱,如 {{ic|net0}} 、 {{ic|net1}} 、 {{ic|wifi0}} 、 {{ic|wifi1}} 。詳細說明請參閱 [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames systemd] 文件。}}<br />
<br />
=== 設定裝置的 MTU 與佇列長度 ===<br />
<br />
您可以手動定義 udev 規則來更改裝置的 MTU 與佇列長度。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1480", ATTR{tx_queue_len}="2000"<br />
</nowiki>}}<br />
<br />
=== 取得目前的裝置名稱 ===<br />
<br />
目前的 NIC 名稱可以通過 sysfs 找到<br />
<br />
{{hc|$ ls /sys/class/net|<br />
lo eth0 eth1 firewire0<br />
}}<br />
<br />
=== 啟用與禁用網路介面 ===<br />
<br />
您可以使用下列指令來啟用或禁用網路介面:<br />
<br />
# ip link set eth0 up<br />
# ip link set eth0 down<br />
<br />
要確認結果,請執行:<br />
<br />
{{hc|$ ip link show dev eth0|<br />
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000<br />
...<br />
}}<br />
<br />
== 組態設定 IP 位址 ==<br />
<br />
您有兩個選擇:使用 [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]] 指派動態位址,或是使用「靜態」的位址。<br />
<br />
=== 動態 IP 位址 ===<br />
<br />
==== 手動執行 DHCP 用戶端 Daemon ====<br />
<br />
{{注意|請特別注意 {{ic|dhcpcd}} (DHCP ''Client'' Daemon,DHCP 用戶端 Daemon) 與 {{ic|dhcpd}} (DHCP ''(server)'' daemon,DHCP 伺服端 Daemon) 間的差異。}}<br />
<br />
{{hc|# dhcpcd eth0|<br />
dhcpcd: version 5.1.1 starting<br />
dhcpcd: eth0: broadcasting for a lease<br />
...<br />
dhcpcd: eth0: leased 192.168.1.70 for 86400 seconds<br />
}}<br />
<br />
緊接著, {{ic|ip addr show dev eth0}} 應該要顯示出您的 inet 位址。<br />
<br />
對部分的人而言,{{ic|dhcpcd}} 失敗時,可以使用 {{ic|dhclient}} (位於 {{Pkg|dhclient}} 軟體包中)<br />
<br />
==== 於啟動時執行 DHCP ====<br />
<br />
若您只是想使用 DHCP 來連線至您的乙太網路連線,您可以使用 {{ic|dhcpcd@.service}} (由 {{Pkg|dhcpcd}} 軟體包提供)。<br />
<br />
要啟動 {{ic|eth0}} 上的 DHCP ,只需要使用:<br />
<br />
# systemctl start dhcpcd@eth0.service<br />
<br />
您可以下列方法啟用該服務讓其於開機時自動啟動:<br />
<br />
# systemctl enable dhcpcd@eth0.service<br />
<br />
若您用了 DHCP 且您並 '''不想''' 讓您的 DNS 伺服器在每次啟動您的網路時自動指派,請將下列內容加到 {{ic|dhcpcd.conf}} 的最後一段中:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nohook resolv.conf<br />
}}<br />
<br />
另外,若您位於基於 MAC 位址的用戶端 IP 位址進行過濾的 DHCPv4 網路,您可能需要修改下列內容:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 Client ID as per RFC4361. <br />
duid<br />
}}<br />
<br />
為:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the hardware address of the interface for the Client ID (DHCPv4).<br />
clientid<br />
}}<br />
<br />
否則,您可能會因為 DHCP 伺服器無法正確讀取您的 [http://en.wikipedia.org/wiki/DHCPv6 DHCPv6-style] 用戶端 ID 而無法使用。詳細請參閱 [http://tools.ietf.org/html/rfc4361 RFC 4361] 。<br />
<br />
為防止 {{ic|dhcpcd}} 加入網域名稱伺服器至 {{ic|/etc/resolv.conf}} 中,請於其中使用 {{ic|nooption}} 選項:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nooption domain_name_servers<br />
}}<br />
<br />
接著加入您自己的 DNS 名稱伺服器至 {{ic|/etc/resolv.conf}} 中。<br />
<br />
若有多個不同的執行緒要控制 {{ic|/etc/resolv.conf}} (如 {{Pkg|dhcpcd}} 與 VPN 用戶端),您可能會想要使用 {{Pkg|openresolv}} 軟體包。使用 {{Pkg|openresolv}} 並不需要額外地設定 {{Pkg|dhcpcd}} 。<br />
<br />
==== DHCP 靜態路由 ====<br />
若您需要加入靜態路由用戶端,請於 {{ic|/usr/lib/dhcpcd/dhcpcd-hooks}} 中建立一個新的 dhcpcd hook-script 。下列範例展示了加入靜態路由至一個通過閘道器為 192.168.192.5 ,位於 10.11.12.0/24 的 VPN 子網路:<br />
{{hc|/usr/lib/dhcpcd/dhcpcd-hooks/40-vpnroute|<br />
ip route add 10.11.12.0/24 via 192.168.192.5<br />
}}<br />
前置字串''40''表示其於 dhcpcd 啟動時的最後執行 hook-script 。<br />
<br />
=== 靜態 IP 位址 ===<br />
<br />
您可能因為各種原因而希望在您的網路中指派靜態 IP 位址,例如靜態的位址可以獲得一定程度的可預測性,或是您沒有可用的 DHCP 伺服器。<br />
<br />
{{注意|若您共通過 Windows 機器共享您的網路而沒有路由器,請確保兩台電腦皆使用了靜態 IP 位址以避免區域網路問題。}}<br />
<br />
您需要:<br />
<br />
* 靜態 IP 位址<br />
* [[Wikipedia:Subnetwork|子網路遮罩]]<br />
* [[Wikipedia:Broadcast_address|廣播位址]]<br />
* [[Wikipedia:Default_gateway|閘道器]]的 IP 位址<br />
<br />
若您處在內部網路中,使用 192.168.*.* 這樣的 IP 位址較為安全,搭配其的子網路遮罩 255.255.255.0 ,廣播位址為 192.168.*.255 。而閘道器通常是 192.168.*.1 或是 192.168.*.254 。<br />
<br />
==== 手動指派 ====<br />
<br />
您可於控制台中指派一靜態 IP 位址:<br />
<br />
# ip addr add <IP 位址>/<子網路遮罩> broadcast <廣播> dev <介面><br />
<br />
舉例來說:<br />
<br />
# ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev eth0<br />
<br />
{{注意|子網路遮罩使用了 [[Wikipedia:CIDR_notation|CIDR 表示法]](CIDR,Classless Inter-Domain Routing,無類別網路間路由)。}}<br />
<br />
詳情請參閱 {{ic|man ip}} 。<br />
<br />
以類似下列方法加上您的閘道器:<br />
<br />
# ip route add default via <預設閘道器 IP 位址><br />
<br />
舉例來說:<br />
<br />
# ip route add default via 192.168.1.1<br />
<br />
若您得到了 "No such process" 這樣的錯誤訊息,這代表您必須以 root 執行 {{ic|ip link set dev eth0 up}} 。<br />
<br />
==== 於啟動時通過 systemd 手動連線 ====<br />
<br />
先確保 dhcpcd 已停止並禁用:<br />
<br />
# systemctl status dhcpcd.service<br />
<br />
接著為 [[systemd]] 服務建立一個檔案。以正確的網路介面名稱取代其中的 {{ic|<interface>}} :<br />
<br />
{{hc|/etc/conf.d/network@<interface>|<nowiki><br />
address=192.168.0.15<br />
netmask=24<br />
broadcast=192.168.0.255<br />
gateway=192.168.0.1<br />
</nowiki>}}<br />
<br />
建立 systemd unit 檔案:<br />
<br />
{{hc|/etc/systemd/system/network@.service|<nowiki><br />
[Unit]<br />
Description=Network connectivity (%i)<br />
Wants=network.target<br />
Before=network.target<br />
BindsTo=sys-subsystem-net-devices-%i.device<br />
After=sys-subsystem-net-devices-%i.device<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
EnvironmentFile=/etc/conf.d/network@%i<br />
<br />
ExecStart=/usr/bin/ip link set dev %i up<br />
ExecStart=/usr/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i<br />
ExecStart=/usr/bin/ip route add default via ${gateway}<br />
<br />
ExecStop=/usr/bin/ip addr flush dev %i<br />
ExecStop=/usr/bin/ip link set dev %i down<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
啟用該 unit 並將其啟動,傳入介面名稱,例如 eno1 :<br />
<br />
# systemctl enable network@eno1.service<br />
# systemctl start network@eno1.service<br />
<br />
若您需要手動設定 nameservers ,請編輯 {{ic|/etc/resolv.conf}} 檔案:<br />
<br />
{{hc|/etc/resolv.conf|<br />
nameserver 208.67.222.222<br />
nameserver 208.67.220.220}}<br />
<br />
若 {{ic|/etc/resolv.conf}} 被持續遭到複寫,請參考 [[Resolv.conf]] 以瞭解如何解決此問題。<br />
<br />
有幾個類似的方法來讓 systemd 啟動網路,其中的差異為檔案內容,並且其可以寫死 EnvironmentFile 定義的參考檔案中抓到的參數。因此可以作為一種替代的,將介面名稱放置於 /etc/conf.d/ 中的 EnvironmentFile 接著直接使用介面名稱而不是 %i 。如此一來,檔案名稱便不需要「@」。這也是一種有用的方法來閱讀 http://www.freedesktop.org/software/systemd/man/systemd.unit.html 上的 systemd 服務文件。<br />
<br />
==== 計算位址 ====<br />
<br />
您可以使用 {{Pkg|ipcalc}} 提供的 {{ic|ipcalc}} 來計算 IP 廣播、網域、子網路遮罩與主機範圍等進階設定舉例來說,我使用了位於防火牆後的乙太網路來連線 Windows 機器至 Arch。為了安全性與網路組織,我將他們放置於各自獨立的網路,接著組態設定子網路遮罩與廣播位址,如此一來網路中就只有兩台機器。為了找出子網路遮罩跟廣播位址,我使用了 ipcalc ,提供其 Arch firewire nic 的 IP 位址 10.66.66.1 ,並指定 ipcalc 要建立一個只有兩台主機的網路。<br />
<br />
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|<nowiki><br />
Address: 10.66.66.1<br />
<br />
Netmask: 255.255.255.252 = 30<br />
Network: 10.66.66.0/30<br />
HostMin: 10.66.66.1<br />
HostMax: 10.66.66.2<br />
Broadcast: 10.66.66.3<br />
Hosts/Net: 2 Class A, Private Internet<br />
</nowiki>}}<br />
<br />
== 載入組態設定 ==<br />
<br />
To test your settings either reboot the computer or reload the relevant systemd services:<br />
<br />
# systemctl restart dhcpcd@eth0<br />
<br />
Try pinging your gateway, DNS server, ISP provider and other Internet sites, in that order, to detect any connection problems along the way, as in this example:<br />
<br />
$ ping -c 3 www.google.com<br />
<br />
== 附加設定 ==<br />
<br />
=== 筆記型電腦之 ifplugd ===<br />
<br />
{{Tip|{{Pkg|dhcpcd}} provides the same feature out of the box.}}<br />
<br />
{{Pkg|ifplugd}} in [[Official Repositories]] is a daemon which will automatically configure your Ethernet device when a cable is plugged in and automatically unconfigure it if the cable is pulled. This is useful on laptops with onboard network adapters, since it will only configure the interface when a cable is really connected. Another use is when you just need to restart the network but do not want to restart the computer or do it from the shell.<br />
<br />
By default it is configured to work for the {{ic|eth0}} device. This and other settings like delays can be configured in {{ic|/etc/ifplugd/ifplugd.conf}}.<br />
<br />
{{Note|[[Netctl]] package includes {{ic|netctl-ifplugd@.service}}, otherwise you can use {{ic|ifplugd@.service}} from {{Pkg|ifplugd}} package. Use for example {{ic|systemctl enable ifplugd@eth0.service}}.}}<br />
<br />
=== Bonding 或 LAG ===<br />
<br />
See [[netctl#Bonding]].<br />
<br />
=== IP 別名 ===<br />
<br />
{{Expansion|Manual method using [[Core Utilities#ip|ip]] should be added; then move current example using ''netctl'' into [[netctl]].}}<br />
<br />
IP aliasing is the process of adding more than one IP address to a network interface. With this, one node on a network can have multiple connections to a network, each serving a different purpose. Typical uses are virtual hosting of Web and FTP servers, or reorganizing servers without having to update any other machines (this is especially useful for nameservers).<br />
<br />
==== 範例 ====<br />
<br />
You will need {{Pkg|netctl}} from the [[Official Repositories]].<br />
<br />
Prepare the configuration:<br />
<br />
{{hc|/etc/netctl/mynetwork|<nowiki><br />
Connection='ethernet'<br />
Description='Five different addresses on the same NIC.'<br />
Interface='eth0'<br />
IP='static'<br />
Address=('192.168.1.10' '192.168.178.11' '192.168.1.12' '192.168.1.13' '192.168.1.14' '192.168.1.15')<br />
Gateway='192.168.1.1'<br />
DNS=('192.168.1.1')<br />
</nowiki>}}<br />
<br />
Then simply execute: <br />
<br />
$ netctl start mynetwork<br />
<br />
=== 更改 MAC/硬體 位址 ===<br />
<br />
請參閱 [[MAC Address Spoofing]] 。<br />
<br />
=== Internet Sharing ===<br />
<br />
請參閱 [[Internet Sharing]] 。<br />
<br />
=== Router Configuration ===<br />
<br />
請參閱 [[Router]] 。<br />
<br />
=== 區域網路主機名稱解析 ===<br />
<br />
The pre-requisite is to [[#Set the hostname]] after which hostname resolution works on the local system itself {{hc|$ ping hostname|<br />
PING hostname <nowiki>(192.168.1.2) 56(84) bytes of data.<br />
64 bytes from hostname (192.168.1.2): icmp_seq=1 ttl=64 time=0.043 ms</nowiki>}}<br />
To enable other machines to address the host by name, either a manual configuration of the respective {{ic|/etc/hosts}} files or a service to propagate/resolve the name is required. <br />
<br />
When setting up a DNS server such as [[BIND]] or [[Unbound]] is overkill, manually editing your {{ic|/etc/hosts}} is too cumbersome, or when you want more flexibility with dynamic leaving and joining of hosts to the network, it is possible to handle hostname resolution on your local network using zero-configuration networking. There are two options available:<br />
<br />
*[[Samba]] provides hostname resolution via Microsoft's '''NetBIOS'''. It only requires installation of {{Pkg|samba}} and enabling of the {{ic|nmbd.service}} service. Computers running Windows, OS X, or Linux with {{ic|nmbd}} running, will be able to find your machine.<br />
<br />
*[[Avahi]] provides hostname resolution via '''zeroconf''', also known as Avahi or Bonjour. It requires slightly more complex configuration than Samba: see [[Avahi#Hostname resolution]] for details. Computers running OS X, or Linux with an Avahi daemon running, will be able to find your machine. Windows does not have an built-in Avahi client or daemon.<br />
<br />
== 診斷 ==<br />
<br />
=== Swapping computers on the cable modem ===<br />
<br />
Some cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.<br />
<br />
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].<br />
<br />
=== The TCP window scaling problem ===<br />
<br />
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.<br />
<br />
Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html RFC 1323] was written to improve the situation: Window Scaling. The "window" value, provided in all packets, will be modified by a Scale Factor defined once, at the very beginning of the connection.<br />
<br />
That 8-bit Scale Factor allows the Window to be up to 32 times higher than the initial 64Kb.<br />
<br />
It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts.<br />
<br />
The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.<br />
<br />
The resulting connection is at best very slow or broken.<br />
<br />
==== How to diagnose the problem ====<br />
<br />
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).<br />
<br />
When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|ip addr}} will report normal status... and actually everything appears normal.<br />
<br />
If you cannot browse any website, but you can ping some random hosts, chances are great that you're experiencing this problem: ping uses ICMP and is not affected by TCP problems.<br />
<br />
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).<br />
<br />
==== How to fix it (The bad way) ====<br />
<br />
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.<br />
<br />
# echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem<br />
<br />
==== How to fix it (The good way) ====<br />
<br />
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.d/99-disable_window_scaling.conf}} (see also [[sysctl]])<br />
<br />
net.ipv4.tcp_window_scaling = 0<br />
<br />
==== How to fix it (The best way) ====<br />
<br />
This problem is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.<br />
<br />
==== More about it ====<br />
<br />
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].<br />
<br />
There are also several relevant threads on the LKML.<br />
<br />
=== Realtek no link / WOL problem ===<br />
<br />
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice a problem where the NIC seems to be disabled on boot and has no Link light. This can usually be found on a dual boot system where Windows is also installed. It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause. These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots. You will be able to notice if this problem is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off. Normal operation should be that the link light is always on as long as the system is on, even during POST. This problem will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this problem:<br />
<br />
==== Method 1 - Rollback/change Windows driver ====<br />
<br />
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).<br />
<br />
==== Method 2 - Enable WOL in Windows driver ====<br />
<br />
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems). In Windows, under Device Manager, find your Realtek network adapter and double-click it. Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.<br />
<br />
In Windows XP (example)<br />
Right click my computer<br />
--> Hardware tab<br />
--> Device Manager<br />
--> Network Adapters<br />
--> "double click" Realtek ...<br />
--> Advanced tab<br />
--> Wake-On-Lan After Shutdown<br />
--> Enable<br />
<br />
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{ic|Disable}} has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.}}<br />
<br />
==== Method 3 - Newer Realtek Linux driver ====<br />
<br />
Any newer driver for these Realtek cards can be found for Linux on the realtek site. (untested but believed to also solve the problem).<br />
<br />
==== Method 4 - Enable ''LAN Boot ROM'' in BIOS/CMOS ====<br />
<br />
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.<br />
<br />
{{Note|This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.}}<br />
<br />
=== DLink G604T/DLink G502T DNS problem ===<br />
<br />
Users with a DLink G604T/DLink G502T router, using DHCP and have firmware v2.00+ (typically users with AUS firmware) may have problems with certain programs not resolving the DNS. One of these programs are unfortunatley pacman. The problem is basically the router in certain situations is not sending the DNS properly to DHCP, which causes programs to try and connect to servers with an IP address of 1.0.0.0 and fail with a connection timed out error<br />
<br />
==== How to diagnose the problem ====<br />
<br />
The best way to diagnose the problem is to use Firefox/Konqueror/links/seamonkey and to enable wget for pacman. If this is a fresh install of Arch Linux, then you may want to consider installing {{ic|links}} through the live CD.<br />
<br />
Firstly, enable wget for pacman (since it gives us info about pacman when it is downloading packages)<br />
Open {{ic|/etc/pacman.conf}} with your favourite editor and uncomment the following line (remove the # if it is there)<br />
<br />
XferCommand=/usr/bin/wget --passive-ftp -c -O %o %u<br />
<br />
While you are editing {{ic|/etc/pacman.conf}}, check the default mirror that pacman uses to download packages.<br />
<br />
Now open up the default mirror in an Internet browser to see if the mirror actually works. If it does work, then do {{ic|pacman -Syy}} (otherwise pick another working mirror and set it to the pacman default). If you get something similar to the following (notice the 1.0.0.0),<br />
<br />
<nowiki>ftp://mirror.pacific.net.au/linux/archlinux/extra/os/i686/extra.db.tar.gz</nowiki><br />
=> '/var/lib/pacman/community.db.tar.gz.part'<br />
Resolving mirror.pacific.net.au... 1.0.0.0<br />
<br />
then you most likely have this problem. The 1.0.0.0 means it is unable to resolve DNS, so we must add it to {{ic|/etc/resolv.conf}}.<br />
<br />
==== How to fix it ====<br />
<br />
{{Out of date|{{Pkg|dhcpcd}} does not use {{ic|/etc/conf.d/dhcpcd}} any more.}}<br />
<br />
Basically what we need to do is to manually add the DNS servers to our {{ic|/etc/resolv.conf}} file. The problem is that DHCP automatically deletes and replaces this file on boot, so we need to edit {{ic|/etc/conf.d/dhcpcd}} and change the flags to stop DHCP from doing this.<br />
<br />
When you open {{ic|/etc/conf.d/dhcpcd}}, you should see something close to the following:<br />
<br />
DHCPCD_ARGS="-t 30 -h $HOSTNAME"<br />
<br />
Add the {{ic|-R}} flag to the arguments, e.g.,<br />
<br />
DHCPCD_ARGS="-R -t 30 -h $HOSTNAME"<br />
<br />
{{Note|1=If you are using {{Pkg|dhcpcd}} >= 4.0.2, the {{ic|-R}} flag has been deprecated. Please see the [[#Run DHCP at boot]] section for information on how to use a custom {{ic|/etc/resolv.conf}} file.}}<br />
<br />
Save and close the file; now open {{ic|/etc/resolv.conf}}. You should see a single nameserver (most likely 10.1.1.1). This is the gateway to your router, which we need to connect to in order to get the DNS servers of your ISP. Paste the IP address into your browser and log in to your router. Go to the DNS section, and you should see an IP address in the Primary DNS Server field; copy it and paste it as a nameserver '''ABOVE''' the current gateway one.<br />
<br />
For example, {{ic|/etc/resolv.conf}} should look something along the lines of:<br />
<br />
nameserver 10.1.1.1<br />
<br />
If my primary DNS server is 211.29.132.12, then change {{ic|/etc/resolv.conf}} to:<br />
<br />
nameserver 211.29.132.12<br />
nameserver 10.1.1.1<br />
<br />
Now restart the network daemon by running {{ic|systemctl restart dhcpcd@<interface>}} and do {{ic|pacman -Syy}}. If it syncs correctly with the server, then the problem is solved.<br />
<br />
==== More about it ====<br />
<br />
This is the whirlpool forum (Australian ISP community) which talks about and gives the same solution to the problem:<br />
<br />
http://forums.whirlpool.net.au/forum-replies-archive.cfm/461625.html<br />
<br />
=== Check DHCP problem by releasing IP first ===<br />
<br />
Problem may occur when DHCP get wrong IP assignment. For example when two routers are tied together through VPN. The router that is connected to me by VPN may assigning IP address. To fix it. On a console, as root, release IP address:<br />
<br />
# dhcpcd -k<br />
<br />
Then request a new one:<br />
<br />
# dhcpcd<br />
<br />
Maybe you had to run those two commands many times.<br />
<br />
=== No eth0 with Atheros AR8161 ===<br />
<br />
{{Note|With the 3.10.2-1-ARCH kernel update, the alx ethernet driver module is included in the package.}}<br />
<br />
With the Atheros AR8161 Gigabit Ethernet card, the ethernet connection is not working out-of-the-box (with the installation media of March 2013). The module "alx" needs to be loaded but is not present.<br />
<br />
The driver from [http://linuxwireless.org/en/users/Download/stable/#compat-wireless_stable_releases compat-wireless] (that has become [https://backports.wiki.kernel.org/index.php/Releases compat-drives] since linux 3.7) need to be installed. The "-u" postfix annotates that Qualcomm have applied a driver under a unified driver.<br />
<br />
$ wget https://www.kernel.org/pub/linux/kernel/projects/backports/2013/03/28/compat-drivers-2013-03-28-5-u.tar.bz2<br />
$ tar xjf compat*<br />
$ cd compat*<br />
$ ./scripts/driver-select alx<br />
$ make<br />
$ sudo make install<br />
$ sudo modprobe alx<br />
<br />
The alx driver has not been added to Linux kernel due to various problems. Compatibility between the different kernel versions has been spotty. For better support follow the [http://lists.infradead.org/mailman/listinfo/unified-drivers mailing list]and [http://www.linuxfoundation.org/collaborate/workgroups/networking/alx alx page]for latest working solution for alx.<br />
<br />
The driver must be built and installed after every kernel change.<br />
<br />
Alternatively you can use the AUR package for [https://aur.archlinux.org/packages/compat-drivers-patched/ compat drivers], which installs many other drivers.<br />
<br />
=== No eth0 with Atheros AR9485 ===<br />
<br />
The ethernet (eth0) for Atheros AR9485 are not working out-of-the-box (with installation media of March 2013). The working solution for this is to install the package [https://aur.archlinux.org/packages/compat-drivers-patched/ compat-drivers-patched] from AUR.<br />
<br />
=== No carrier / no connection after suspend ===<br />
After suspend to RAM no connection is found although the network cable is plugged in. <br />
This may be caused by PCI power management. What is the output of<br />
<br />
# ip link show eth0<br />
<br />
If the line contains "NO-CARRIER" even though there's a cable connected to your eth0 port, it is possible that the device was auto-suspended and the media sense feature doesn't work. To solve this, first you need to find your ethernet controllers PCI address by<br />
<br />
# lspci<br />
<br />
This should look similar to this:<br />
<br />
...<br />
00:19.0 Ethernet controller: Intel Corporation 82577LM Gigabit Network Connection (rev 06)<br />
...<br />
<br />
So the address is 00:19.0.<br />
Now check the PM status of the device by issuing<br />
<br />
# cat "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
substituting 00:19.0 with the address obtained from lspci.<br />
If the output reads "auto", you can try to bring the device out of suspend by<br />
<br />
# echo on > "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
Don't forget to substitute the address again.<br />
<br />
{{Note|1=This appears to be a bug in kernel 3.8.4.1- (3.8.8.1 is still affected): [https://bbs.archlinux.org/viewtopic.php?id=159837&p=2 Forum discussion.] It also appears a fix is [https://lkml.org/lkml/2013/1/18/147 on the way. (It will be likely fixed in 3.9.)] In the meantime, the above is a suitable workaround.}}<br />
<br />
=== Broadcom BCM57780 ===<br />
<br />
This Broadcom chipset sometimes does not behave well unless you specify the order of the modules to be loaded. The modules are {{ic|broadcom}} and {{ic|tg3}}, the former needing to be loaded first.<br />
<br />
These steps should help if your computer has this chipset:<br />
$ lspci | grep Ethernet<br />
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)<br />
<br />
If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following (as root):<br />
# modprobe -r tg3<br />
# modprobe broadcom<br />
# modprobe tg3<br />
<br />
Now plug you network cable in. If this solves your problems you can make this permanent by adding {{ic|broadcom}} and {{ic|tg3}} (in this order) to the {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}}:<br />
<br />
MODULES=".. broadcom tg3 .."<br />
<br />
Then rebuild the initramfs:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|These methods may work for other chipsets, such as BCM57760.}}</div>Binotahttps://wiki.archlinux.org/index.php?title=Network_configuration_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=293529Network configuration (正體中文)2014-01-19T08:19:24Z<p>Binota: 修正粗體字排版</p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:Networking (正體中文)]]<br />
[[Category:Getting and installing Arch (正體中文)]]<br />
<br />
[[cs:Configuring Network]]<br />
[[el:Configuring Network]]<br />
[[es:Configuring Network]]<br />
[[fr:Connexions reseau]]<br />
[[it:Configuring Network]]<br />
[[ja:Network Configuration]]<br />
[[nl:Configuring Network]]<br />
[[pt:Configuring Network]]<br />
[[ro:Configurare retea]]<br />
[[ru:Configuring Network]]<br />
[[sk:Configuring Network]]<br />
[[tr:Ağ_Yapılandırması]]<br />
[[zh-CN:Network Configuration]]<br />
[[zh-TW:Network Configuration]]<br />
{{Related articles start}}<br />
{{Related|Jumbo Frames}}<br />
{{Related|Firewalls}}<br />
{{Related|Wireless Setup}}<br />
{{Related|List of Applications#Network Managers}}<br />
{{Related articles end}}<br />
<br />
本頁將介紹如何設定 '''有線''' 網路連線。若您需要設定 '''無線''' 網路,請參考[[Wireless Setup|無線網路設定]]。<br />
<br />
== 檢查連線 ==<br />
<br />
{{注意|若您在執行 ping 時收到了類似 {{ic|ping: icmp open socket: Operation not permitted}} 這樣的錯誤訊息,請嘗試重新安裝 {{ic|iputils}} 軟體包。}} <br />
<br />
一般來說,基本的安裝過程都已經建立了可運作的網路設定。請執行下列指令以進行檢查:<br />
<br />
{{注意|{{ic|-c 3}} 選項表示將會呼叫三次。詳細請參閱 {{ic|man ping}} 。}}<br />
{{注意|您也可以嘗試使用其他的 Domain ,如 www.hinet.net 。}}<br />
<br />
{{hc|$ ping -c 3 www.google.com|<nowiki><br />
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.<br />
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms<br />
64 bytes from 74.125.224.146: icmp_req=2 ttl=50 time=385 ms<br />
64 bytes from 74.125.224.146: icmp_req=3 ttl=50 time=298 ms<br />
<br />
--- www.l.google.com ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 1999ms<br />
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms<br />
</nowiki>}}<br />
<br />
如果沒問題的話,您可能只是想以本文的下列部分來自定您的設定。<br />
<br />
若剛才的指令出現了 unknown hosts 之類的訊息,代表您的機器無法解析網域。這可能是因為您的網路服務提供商/網關造成的。您可以嘗試 ping 一個靜態 IP 以實驗您的機器可否存取網際網路。<br />
{{注意|您也可以嘗試使用其他的 IP ,如 168.95.1.1 。}}<br />
<br />
{{hc|$ ping -c 3 8.8.8.8|<nowiki><br />
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.<br />
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms<br />
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms<br />
64 bytes from 8.8.8.8: icmp_req=3 ttl=53 time=70.6 ms<br />
<br />
--- 8.8.8.8 ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 2002ms<br />
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms<br />
</nowiki>}}<br />
<br />
{{注意|{{ic|8.8.8.8}} 為一個好記的靜態 IP 位置。這是 Google 的主要 DNS 伺服器,這表示其有一定的可信度,並且通常不會被系統或代理伺服器擋下。}}<br />
<br />
若您可以 ping 通該位置,您可能需要試著在 {{ic|/etc/resolv.conf}} 檔案中加上網域名稱伺服器。<br />
<br />
== 設定主機名稱 ==<br />
<br />
[[Wikipedia:Hostname|主機名稱]]為網路中用於識別機器的唯一識別名稱:主機名稱可以通過 {{ic|/etc/hostname}} 檔案來進行設定。一般來說該檔案包含了系統的網域名稱。下面為設定主機名稱的方法:<br />
<br />
# hostnamectl set-hostname '''myhostname'''<br />
<br />
這樣會將 '''myhostname''' 寫入 {{ic|/etc/hostname}} 檔案中。<br />
<br />
詳細請參閱 {{ic|man 5 hostname}} 與 {{ic|man 1 hostnamectl}} 。<br />
<br />
{{注意|<br />
* {{ic|hostnamectl}} 支援 FQDN<br />
* 您不需要編輯 {{ic|/etc/hosts}} 檔案,{{pkg|systemd}} 會提供主機名稱解析且預設安裝於所有系統。<br />
}}<br />
<br />
使用來自 {{Pkg|inetutils}} 的 {{ic|hostname}} 指令以設定臨時主機名稱(直到重新啟動):<br />
<br />
# hostname ''myhostname''<br />
<br />
== 裝置驅動程式 ==<br />
<br />
=== 檢查驅動程式狀態 ===<br />
<br />
[[udev]] 應該會檢測您的網路介面卡([[Wikipedia:Network_interface_controller|NIC]])並自動於啟動時載入必要的模組。檢查 {{ic|lspci -v}} 輸出內容中的「Ethernet controller」 項目(或類似的)。這應該會告訴您哪些核心模組包含了網路設備的驅動程式。舉例來說:<br />
<br />
{{hc|$ lspci -v|<br />
02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)<br />
...<br />
Kernel driver in use: atl1<br />
Kernel modules: atl1<br />
}}<br />
<br />
接下來,確認該驅動程式已經通過 {{ic|dmesg <nowiki>|</nowiki> grep ''module_name''}} 載入了。舉例來說:<br />
<br />
$ dmesg | grep atl1<br />
...<br />
atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex<br />
<br />
若驅動程式已成功加載可以跳過接下來這段。否則,您會需要知道哪些模組時您的特定型號的裝置需要哪個模組。<br />
<br />
=== 載入裝置模組 ===<br />
<br />
以 Google 搜尋正確的晶片組模組/驅動程式。常見的驅動模組有 Realtek 晶片組網卡的 {{ic|8139too}} ,或是 SiS 晶片組網卡的 {{ic|sis900}}。當您知道要使用何種模組了之後,試著[[Kernel modules#Manual module handling|手動將其載入]]。若您的到了錯誤訊息告訴您找不到該模組,則該驅動可能未包含於 Arch 核心中。您可以在 [[AUR]] 中搜尋該模組名稱。<br />
<br />
若 udev 未在開機期間檢測與載入正確的模組,請參閱 [[Kernel modules#Loading]]。<br />
<br />
== 網路介面 ==<br />
<br />
=== 裝置名稱 ===<br />
<br />
對於多網路卡的電腦,固定裝置名稱非常重要。許多設定問題都是因為介面卡名稱的改動造成的。<br />
<br />
[[udev]] 負責命名裝置。Systemd v197 則有[http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames 可預測之網路介面名稱]並可自動支配靜態名稱給網路裝置。介面名稱以 {{ic|en}} (乙太網路)、 {{ic|wl}} (無線網路) 或是 {{ic|ww}} (WWAN)作為前置字串並附上一個自動產生的識別名稱,進而產生了類似 {{ic|enp0s25}} 這樣的名稱。 <br />
<br />
要禁用這種行為,可以加上一個連接:<br />
<br />
# ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules<br />
<br />
自早期版本升級 systemd 的使用者會有一自動建立的空規則檔案。因此,若您想使用一貫的裝置名稱,只需要刪除該檔案。<br />
<br />
{{提示|您可以執行 {{ic|ip link}} 或是 {{ic|ls /sys/class/net}} 以列出所有可用的介面。}}<br />
<br />
{{注意|當您更改了介面名稱規則後,別忘了更新所有跟網路有關的組態檔案與自定的 systemd unit 檔案以因應該更改。特別是當您啟用了 [[netctl#Basic method|netctl 靜態設定檔]] ,請執行 {{ic|netctl reenable ''profile''}} 以更新所有產生的服務檔案。}}<br />
<br />
==== 更改裝置名稱 ====<br />
<br />
您可以使用 udev-rule 來手動定義裝置名稱。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"<br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"<br />
</nowiki>}}<br />
<br />
請注意這兩點:<br />
<br />
* 使用這個指令以取得 MAC 位置:{{ic|cat /sys/class/net/''device_name''/address}}。<br />
* 請確定 udev 規則中使用的是小寫的十六進位數值而不是大寫。<br />
<br />
若您的網路卡為動態 MAC ,您可以使用 DEVPATH ,例如:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"<br />
</nowiki>}}<br />
<br />
{{注意|當使用了靜態的名稱時,'''應該要避免使用類似 "eth''X''" 與 "wlan''X''"''' 這樣的名稱,因為這可能會導致核心與 udev 在開機時發生衝突。而剛好相反地,最好使用核心預設不會使用的介面名稱,如 {{ic|net0}} 、 {{ic|net1}} 、 {{ic|wifi0}} 、 {{ic|wifi1}} 。詳細說明請參閱 [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames systemd] 文件。}}<br />
<br />
=== 設定裝置的 MTU 與佇列長度 ===<br />
<br />
您可以手動定義 udev 規則來更改裝置的 MTU 與佇列長度。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1480", ATTR{tx_queue_len}="2000"<br />
</nowiki>}}<br />
<br />
=== 取得目前的裝置名稱 ===<br />
<br />
目前的 NIC 名稱可以通過 sysfs 找到<br />
<br />
{{hc|$ ls /sys/class/net|<br />
lo eth0 eth1 firewire0<br />
}}<br />
<br />
=== 啟用與禁用網路介面 ===<br />
<br />
您可以使用下列指令來啟用或禁用網路介面:<br />
<br />
# ip link set eth0 up<br />
# ip link set eth0 down<br />
<br />
要確認結果,請執行:<br />
<br />
{{hc|$ ip link show dev eth0|<br />
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000<br />
...<br />
}}<br />
<br />
== 組態設定 IP 位址 ==<br />
<br />
You have two options: a dynamically assigned address using [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]], or an unchanging "static" address.<br />
<br />
=== 動態 IP 位址 ===<br />
<br />
==== 手動執行 DHCP 用戶端 Daemon ====<br />
<br />
{{Note|{{ic|dhcpcd}} (DHCP ''client'' daemon) is not the same as {{ic|dhcpd}} (DHCP ''(server)'' daemon).}}<br />
<br />
{{hc|# dhcpcd eth0|<br />
dhcpcd: version 5.1.1 starting<br />
dhcpcd: eth0: broadcasting for a lease<br />
...<br />
dhcpcd: eth0: leased 192.168.1.70 for 86400 seconds<br />
}}<br />
<br />
And now, {{ic|ip addr show dev eth0}} should show your inet address.<br />
<br />
For some people, {{ic|dhclient}} (from the {{Pkg|dhclient}} package) works where {{ic|dhcpcd}} fails.<br />
<br />
==== 於啟動時執行 DHCP ====<br />
<br />
If you simply want to use DHCP for your Ethernet connection, you can use {{ic|dhcpcd@.service}} (provided by the {{Pkg|dhcpcd}} package).<br />
<br />
To start DHCP for {{ic|eth0}}, simply use:<br />
<br />
# systemctl start dhcpcd@eth0.service<br />
<br />
You can enable the service to automatically start at boot with:<br />
<br />
# systemctl enable dhcpcd@eth0.service<br />
<br />
If you use DHCP and you do '''not''' want your DNS servers automatically assigned every time you start your network, be sure to add the following to the last section of {{ic|dhcpcd.conf}}:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nohook resolv.conf<br />
}}<br />
<br />
Also, if you are on a network with DHCPv4 that filters Client IDs based on MAC addresses, you may need to change the following line:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 Client ID as per RFC4361. <br />
duid<br />
}}<br />
<br />
To:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the hardware address of the interface for the Client ID (DHCPv4).<br />
clientid<br />
}}<br />
<br />
Else, you may not obtain a lease since the DHCP server may not read your [http://en.wikipedia.org/wiki/DHCPv6 DHCPv6-style] Client ID correctly. See [http://tools.ietf.org/html/rfc4361 RFC 4361] for more information.<br />
<br />
To prevent {{ic|dhcpcd}} from adding domain name servers to {{ic|/etc/resolv.conf}}, use the {{ic|nooption}} option:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nooption domain_name_servers<br />
}}<br />
<br />
Then add your own DNS name server to {{ic|/etc/resolv.conf}}.<br />
<br />
You may use the {{Pkg|openresolv}} package if several different processes want to control {{ic|/etc/resolv.conf}} (e.g. {{Pkg|dhcpcd}} and a VPN client). No additional configuration for {{Pkg|dhcpcd}} is needed to use {{Pkg|openresolv}}.<br />
<br />
==== DHCP 靜態路由 ====<br />
If you need to add a static route client-side, create a new dhcpcd hook-script in {{ic|/usr/lib/dhcpcd/dhcpcd-hooks}}. The example shows a new hook-script which adds a static route to a VPN subnet on 10.11.12.0/24 via a gateway machine at 192.168.192.5:<br />
{{hc|/usr/lib/dhcpcd/dhcpcd-hooks/40-vpnroute|<br />
ip route add 10.11.12.0/24 via 192.168.192.5<br />
}}<br />
The ''40'' prefix means that it is the final hook-script to run when dhcpcd starts.<br />
<br />
=== 靜態 IP 位址 ===<br />
<br />
There are various reasons why you may wish to assign static IP addresses on your network. For instance, one may gain a certain degree of predictability with unchanging addresses, or you may not have a DHCP server available.<br />
<br />
{{Note|If you share your Internet connection from a Windows machine without a router, be sure to use static IP addresses on both computers to avoid LAN problems.}}<br />
<br />
You need:<br />
<br />
* Static IP address<br />
* [[Wikipedia:Subnetwork|Subnet mask]]<br />
* [[Wikipedia:Broadcast_address|Broadcast address]]<br />
* [[Wikipedia:Default_gateway|Gateway]]'s IP address<br />
<br />
If you are running a private network, it is safe to use IP addresses in 192.168.*.* for your IP addresses, with a subnet mask of 255.255.255.0 and a broadcast address of 192.168.*.255. The gateway is usually 192.168.*.1 or 192.168.*.254.<br />
<br />
==== 手動指派 ====<br />
<br />
You can assign a static IP address in the console:<br />
<br />
# ip addr add <IP address>/<subnet mask> broadcast <broadcast> dev <interface><br />
<br />
For example:<br />
<br />
# ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev eth0<br />
<br />
{{Note|The subnet mask was specified using [[Wikipedia:CIDR_notation|CIDR notation]].}}<br />
<br />
For more options, see {{ic|man ip}}.<br />
<br />
Add your gateway like so:<br />
<br />
# ip route add default via <default gateway IP address><br />
<br />
For example:<br />
<br />
# ip route add default via 192.168.1.1<br />
<br />
If you the get the error "No such process", it means you have to run {{ic|ip link set dev eth0 up}} as root.<br />
<br />
==== 於啟動時通過 systemd 手動連線 ====<br />
<br />
Ensure that dhcpcd is stopped and disabled:<br />
<br />
# systemctl status dhcpcd.service<br />
<br />
Create a configuration file for the [[systemd]] service. Replace {{ic|<interface>}} with the proper network interface name:<br />
<br />
{{hc|/etc/conf.d/network@<interface>|<nowiki><br />
address=192.168.0.15<br />
netmask=24<br />
broadcast=192.168.0.255<br />
gateway=192.168.0.1<br />
</nowiki>}}<br />
<br />
Create a systemd unit file:<br />
<br />
{{hc|/etc/systemd/system/network@.service|<nowiki><br />
[Unit]<br />
Description=Network connectivity (%i)<br />
Wants=network.target<br />
Before=network.target<br />
BindsTo=sys-subsystem-net-devices-%i.device<br />
After=sys-subsystem-net-devices-%i.device<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
EnvironmentFile=/etc/conf.d/network@%i<br />
<br />
ExecStart=/usr/bin/ip link set dev %i up<br />
ExecStart=/usr/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i<br />
ExecStart=/usr/bin/ip route add default via ${gateway}<br />
<br />
ExecStop=/usr/bin/ip addr flush dev %i<br />
ExecStop=/usr/bin/ip link set dev %i down<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
Enable the unit and start it, passing the name of the interface, in this case eno1:<br />
<br />
# systemctl enable network@eno1.service<br />
# systemctl start network@eno1.service<br />
<br />
If you need to manually set the nameservers, edit {{ic|/etc/resolv.conf}}:<br />
<br />
{{hc|/etc/resolv.conf|<br />
nameserver 208.67.222.222<br />
nameserver 208.67.220.220}}<br />
<br />
If {{ic|/etc/resolv.conf}} keeps getting overwritten see [[Resolv.conf]] for more details on how to address this issue.<br />
<br />
There are several different ways to utilise systemd to start the network using similar, but different, file contents, and it is also possible to hard code the parameters that can then be picked up from the file referenced in the EnvironmentFile definition. It is therefore possible, as an alternative, to put the interface name into the EnvironmentFile in /etc/conf.d/ and then use the interface name directly instead of %i. In that case the name of the file does not need the "@". It is also useful to read the documentation on systemd service files at http://www.freedesktop.org/software/systemd/man/systemd.unit.html<br />
<br />
==== 計算位址 ====<br />
<br />
You can use {{ic|ipcalc}} provided by the {{Pkg|ipcalc}} package to calculate IP broadcast, network, netmask, and host ranges for more advanced configurations. For example, I use ethernet over firewire to connect a windows machine to arch. For security and network organization, I placed them on their own network and configured the netmask and broadcast so that they are the only 2 machines on it. To figure out the netmask and broadcast addresses for this, I used ipcalc, providing it with the IP of the arch firewire nic 10.66.66.1, and specifying ipcalc should create a network of only 2 hosts.<br />
<br />
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|<nowiki><br />
Address: 10.66.66.1<br />
<br />
Netmask: 255.255.255.252 = 30<br />
Network: 10.66.66.0/30<br />
HostMin: 10.66.66.1<br />
HostMax: 10.66.66.2<br />
Broadcast: 10.66.66.3<br />
Hosts/Net: 2 Class A, Private Internet<br />
</nowiki>}}<br />
<br />
== 載入組態設定 ==<br />
<br />
To test your settings either reboot the computer or reload the relevant systemd services:<br />
<br />
# systemctl restart dhcpcd@eth0<br />
<br />
Try pinging your gateway, DNS server, ISP provider and other Internet sites, in that order, to detect any connection problems along the way, as in this example:<br />
<br />
$ ping -c 3 www.google.com<br />
<br />
== 附加設定 ==<br />
<br />
=== 筆記型電腦之 ifplugd ===<br />
<br />
{{Tip|{{Pkg|dhcpcd}} provides the same feature out of the box.}}<br />
<br />
{{Pkg|ifplugd}} in [[Official Repositories]] is a daemon which will automatically configure your Ethernet device when a cable is plugged in and automatically unconfigure it if the cable is pulled. This is useful on laptops with onboard network adapters, since it will only configure the interface when a cable is really connected. Another use is when you just need to restart the network but do not want to restart the computer or do it from the shell.<br />
<br />
By default it is configured to work for the {{ic|eth0}} device. This and other settings like delays can be configured in {{ic|/etc/ifplugd/ifplugd.conf}}.<br />
<br />
{{Note|[[Netctl]] package includes {{ic|netctl-ifplugd@.service}}, otherwise you can use {{ic|ifplugd@.service}} from {{Pkg|ifplugd}} package. Use for example {{ic|systemctl enable ifplugd@eth0.service}}.}}<br />
<br />
=== Bonding 或 LAG ===<br />
<br />
See [[netctl#Bonding]].<br />
<br />
=== IP 別名 ===<br />
<br />
{{Expansion|Manual method using [[Core Utilities#ip|ip]] should be added; then move current example using ''netctl'' into [[netctl]].}}<br />
<br />
IP aliasing is the process of adding more than one IP address to a network interface. With this, one node on a network can have multiple connections to a network, each serving a different purpose. Typical uses are virtual hosting of Web and FTP servers, or reorganizing servers without having to update any other machines (this is especially useful for nameservers).<br />
<br />
==== 範例 ====<br />
<br />
You will need {{Pkg|netctl}} from the [[Official Repositories]].<br />
<br />
Prepare the configuration:<br />
<br />
{{hc|/etc/netctl/mynetwork|<nowiki><br />
Connection='ethernet'<br />
Description='Five different addresses on the same NIC.'<br />
Interface='eth0'<br />
IP='static'<br />
Address=('192.168.1.10' '192.168.178.11' '192.168.1.12' '192.168.1.13' '192.168.1.14' '192.168.1.15')<br />
Gateway='192.168.1.1'<br />
DNS=('192.168.1.1')<br />
</nowiki>}}<br />
<br />
Then simply execute: <br />
<br />
$ netctl start mynetwork<br />
<br />
=== 更改 MAC/硬體 位址 ===<br />
<br />
請參閱 [[MAC Address Spoofing]] 。<br />
<br />
=== Internet Sharing ===<br />
<br />
請參閱 [[Internet Sharing]] 。<br />
<br />
=== Router Configuration ===<br />
<br />
請參閱 [[Router]] 。<br />
<br />
=== 區域網路主機名稱解析 ===<br />
<br />
The pre-requisite is to [[#Set the hostname]] after which hostname resolution works on the local system itself {{hc|$ ping hostname|<br />
PING hostname <nowiki>(192.168.1.2) 56(84) bytes of data.<br />
64 bytes from hostname (192.168.1.2): icmp_seq=1 ttl=64 time=0.043 ms</nowiki>}}<br />
To enable other machines to address the host by name, either a manual configuration of the respective {{ic|/etc/hosts}} files or a service to propagate/resolve the name is required. <br />
<br />
When setting up a DNS server such as [[BIND]] or [[Unbound]] is overkill, manually editing your {{ic|/etc/hosts}} is too cumbersome, or when you want more flexibility with dynamic leaving and joining of hosts to the network, it is possible to handle hostname resolution on your local network using zero-configuration networking. There are two options available:<br />
<br />
*[[Samba]] provides hostname resolution via Microsoft's '''NetBIOS'''. It only requires installation of {{Pkg|samba}} and enabling of the {{ic|nmbd.service}} service. Computers running Windows, OS X, or Linux with {{ic|nmbd}} running, will be able to find your machine.<br />
<br />
*[[Avahi]] provides hostname resolution via '''zeroconf''', also known as Avahi or Bonjour. It requires slightly more complex configuration than Samba: see [[Avahi#Hostname resolution]] for details. Computers running OS X, or Linux with an Avahi daemon running, will be able to find your machine. Windows does not have an built-in Avahi client or daemon.<br />
<br />
== 診斷 ==<br />
<br />
=== Swapping computers on the cable modem ===<br />
<br />
Some cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.<br />
<br />
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].<br />
<br />
=== The TCP window scaling problem ===<br />
<br />
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.<br />
<br />
Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html RFC 1323] was written to improve the situation: Window Scaling. The "window" value, provided in all packets, will be modified by a Scale Factor defined once, at the very beginning of the connection.<br />
<br />
That 8-bit Scale Factor allows the Window to be up to 32 times higher than the initial 64Kb.<br />
<br />
It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts.<br />
<br />
The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.<br />
<br />
The resulting connection is at best very slow or broken.<br />
<br />
==== How to diagnose the problem ====<br />
<br />
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).<br />
<br />
When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|ip addr}} will report normal status... and actually everything appears normal.<br />
<br />
If you cannot browse any website, but you can ping some random hosts, chances are great that you're experiencing this problem: ping uses ICMP and is not affected by TCP problems.<br />
<br />
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).<br />
<br />
==== How to fix it (The bad way) ====<br />
<br />
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.<br />
<br />
# echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem<br />
<br />
==== How to fix it (The good way) ====<br />
<br />
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.d/99-disable_window_scaling.conf}} (see also [[sysctl]])<br />
<br />
net.ipv4.tcp_window_scaling = 0<br />
<br />
==== How to fix it (The best way) ====<br />
<br />
This problem is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.<br />
<br />
==== More about it ====<br />
<br />
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].<br />
<br />
There are also several relevant threads on the LKML.<br />
<br />
=== Realtek no link / WOL problem ===<br />
<br />
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice a problem where the NIC seems to be disabled on boot and has no Link light. This can usually be found on a dual boot system where Windows is also installed. It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause. These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots. You will be able to notice if this problem is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off. Normal operation should be that the link light is always on as long as the system is on, even during POST. This problem will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this problem:<br />
<br />
==== Method 1 - Rollback/change Windows driver ====<br />
<br />
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).<br />
<br />
==== Method 2 - Enable WOL in Windows driver ====<br />
<br />
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems). In Windows, under Device Manager, find your Realtek network adapter and double-click it. Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.<br />
<br />
In Windows XP (example)<br />
Right click my computer<br />
--> Hardware tab<br />
--> Device Manager<br />
--> Network Adapters<br />
--> "double click" Realtek ...<br />
--> Advanced tab<br />
--> Wake-On-Lan After Shutdown<br />
--> Enable<br />
<br />
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{ic|Disable}} has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.}}<br />
<br />
==== Method 3 - Newer Realtek Linux driver ====<br />
<br />
Any newer driver for these Realtek cards can be found for Linux on the realtek site. (untested but believed to also solve the problem).<br />
<br />
==== Method 4 - Enable ''LAN Boot ROM'' in BIOS/CMOS ====<br />
<br />
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.<br />
<br />
{{Note|This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.}}<br />
<br />
=== DLink G604T/DLink G502T DNS problem ===<br />
<br />
Users with a DLink G604T/DLink G502T router, using DHCP and have firmware v2.00+ (typically users with AUS firmware) may have problems with certain programs not resolving the DNS. One of these programs are unfortunatley pacman. The problem is basically the router in certain situations is not sending the DNS properly to DHCP, which causes programs to try and connect to servers with an IP address of 1.0.0.0 and fail with a connection timed out error<br />
<br />
==== How to diagnose the problem ====<br />
<br />
The best way to diagnose the problem is to use Firefox/Konqueror/links/seamonkey and to enable wget for pacman. If this is a fresh install of Arch Linux, then you may want to consider installing {{ic|links}} through the live CD.<br />
<br />
Firstly, enable wget for pacman (since it gives us info about pacman when it is downloading packages)<br />
Open {{ic|/etc/pacman.conf}} with your favourite editor and uncomment the following line (remove the # if it is there)<br />
<br />
XferCommand=/usr/bin/wget --passive-ftp -c -O %o %u<br />
<br />
While you are editing {{ic|/etc/pacman.conf}}, check the default mirror that pacman uses to download packages.<br />
<br />
Now open up the default mirror in an Internet browser to see if the mirror actually works. If it does work, then do {{ic|pacman -Syy}} (otherwise pick another working mirror and set it to the pacman default). If you get something similar to the following (notice the 1.0.0.0),<br />
<br />
<nowiki>ftp://mirror.pacific.net.au/linux/archlinux/extra/os/i686/extra.db.tar.gz</nowiki><br />
=> '/var/lib/pacman/community.db.tar.gz.part'<br />
Resolving mirror.pacific.net.au... 1.0.0.0<br />
<br />
then you most likely have this problem. The 1.0.0.0 means it is unable to resolve DNS, so we must add it to {{ic|/etc/resolv.conf}}.<br />
<br />
==== How to fix it ====<br />
<br />
{{Out of date|{{Pkg|dhcpcd}} does not use {{ic|/etc/conf.d/dhcpcd}} any more.}}<br />
<br />
Basically what we need to do is to manually add the DNS servers to our {{ic|/etc/resolv.conf}} file. The problem is that DHCP automatically deletes and replaces this file on boot, so we need to edit {{ic|/etc/conf.d/dhcpcd}} and change the flags to stop DHCP from doing this.<br />
<br />
When you open {{ic|/etc/conf.d/dhcpcd}}, you should see something close to the following:<br />
<br />
DHCPCD_ARGS="-t 30 -h $HOSTNAME"<br />
<br />
Add the {{ic|-R}} flag to the arguments, e.g.,<br />
<br />
DHCPCD_ARGS="-R -t 30 -h $HOSTNAME"<br />
<br />
{{Note|1=If you are using {{Pkg|dhcpcd}} >= 4.0.2, the {{ic|-R}} flag has been deprecated. Please see the [[#Run DHCP at boot]] section for information on how to use a custom {{ic|/etc/resolv.conf}} file.}}<br />
<br />
Save and close the file; now open {{ic|/etc/resolv.conf}}. You should see a single nameserver (most likely 10.1.1.1). This is the gateway to your router, which we need to connect to in order to get the DNS servers of your ISP. Paste the IP address into your browser and log in to your router. Go to the DNS section, and you should see an IP address in the Primary DNS Server field; copy it and paste it as a nameserver '''ABOVE''' the current gateway one.<br />
<br />
For example, {{ic|/etc/resolv.conf}} should look something along the lines of:<br />
<br />
nameserver 10.1.1.1<br />
<br />
If my primary DNS server is 211.29.132.12, then change {{ic|/etc/resolv.conf}} to:<br />
<br />
nameserver 211.29.132.12<br />
nameserver 10.1.1.1<br />
<br />
Now restart the network daemon by running {{ic|systemctl restart dhcpcd@<interface>}} and do {{ic|pacman -Syy}}. If it syncs correctly with the server, then the problem is solved.<br />
<br />
==== More about it ====<br />
<br />
This is the whirlpool forum (Australian ISP community) which talks about and gives the same solution to the problem:<br />
<br />
http://forums.whirlpool.net.au/forum-replies-archive.cfm/461625.html<br />
<br />
=== Check DHCP problem by releasing IP first ===<br />
<br />
Problem may occur when DHCP get wrong IP assignment. For example when two routers are tied together through VPN. The router that is connected to me by VPN may assigning IP address. To fix it. On a console, as root, release IP address:<br />
<br />
# dhcpcd -k<br />
<br />
Then request a new one:<br />
<br />
# dhcpcd<br />
<br />
Maybe you had to run those two commands many times.<br />
<br />
=== No eth0 with Atheros AR8161 ===<br />
<br />
{{Note|With the 3.10.2-1-ARCH kernel update, the alx ethernet driver module is included in the package.}}<br />
<br />
With the Atheros AR8161 Gigabit Ethernet card, the ethernet connection is not working out-of-the-box (with the installation media of March 2013). The module "alx" needs to be loaded but is not present.<br />
<br />
The driver from [http://linuxwireless.org/en/users/Download/stable/#compat-wireless_stable_releases compat-wireless] (that has become [https://backports.wiki.kernel.org/index.php/Releases compat-drives] since linux 3.7) need to be installed. The "-u" postfix annotates that Qualcomm have applied a driver under a unified driver.<br />
<br />
$ wget https://www.kernel.org/pub/linux/kernel/projects/backports/2013/03/28/compat-drivers-2013-03-28-5-u.tar.bz2<br />
$ tar xjf compat*<br />
$ cd compat*<br />
$ ./scripts/driver-select alx<br />
$ make<br />
$ sudo make install<br />
$ sudo modprobe alx<br />
<br />
The alx driver has not been added to Linux kernel due to various problems. Compatibility between the different kernel versions has been spotty. For better support follow the [http://lists.infradead.org/mailman/listinfo/unified-drivers mailing list]and [http://www.linuxfoundation.org/collaborate/workgroups/networking/alx alx page]for latest working solution for alx.<br />
<br />
The driver must be built and installed after every kernel change.<br />
<br />
Alternatively you can use the AUR package for [https://aur.archlinux.org/packages/compat-drivers-patched/ compat drivers], which installs many other drivers.<br />
<br />
=== No eth0 with Atheros AR9485 ===<br />
<br />
The ethernet (eth0) for Atheros AR9485 are not working out-of-the-box (with installation media of March 2013). The working solution for this is to install the package [https://aur.archlinux.org/packages/compat-drivers-patched/ compat-drivers-patched] from AUR.<br />
<br />
=== No carrier / no connection after suspend ===<br />
After suspend to RAM no connection is found although the network cable is plugged in. <br />
This may be caused by PCI power management. What is the output of<br />
<br />
# ip link show eth0<br />
<br />
If the line contains "NO-CARRIER" even though there's a cable connected to your eth0 port, it is possible that the device was auto-suspended and the media sense feature doesn't work. To solve this, first you need to find your ethernet controllers PCI address by<br />
<br />
# lspci<br />
<br />
This should look similar to this:<br />
<br />
...<br />
00:19.0 Ethernet controller: Intel Corporation 82577LM Gigabit Network Connection (rev 06)<br />
...<br />
<br />
So the address is 00:19.0.<br />
Now check the PM status of the device by issuing<br />
<br />
# cat "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
substituting 00:19.0 with the address obtained from lspci.<br />
If the output reads "auto", you can try to bring the device out of suspend by<br />
<br />
# echo on > "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
Don't forget to substitute the address again.<br />
<br />
{{Note|1=This appears to be a bug in kernel 3.8.4.1- (3.8.8.1 is still affected): [https://bbs.archlinux.org/viewtopic.php?id=159837&p=2 Forum discussion.] It also appears a fix is [https://lkml.org/lkml/2013/1/18/147 on the way. (It will be likely fixed in 3.9.)] In the meantime, the above is a suitable workaround.}}<br />
<br />
=== Broadcom BCM57780 ===<br />
<br />
This Broadcom chipset sometimes does not behave well unless you specify the order of the modules to be loaded. The modules are {{ic|broadcom}} and {{ic|tg3}}, the former needing to be loaded first.<br />
<br />
These steps should help if your computer has this chipset:<br />
$ lspci | grep Ethernet<br />
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)<br />
<br />
If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following (as root):<br />
# modprobe -r tg3<br />
# modprobe broadcom<br />
# modprobe tg3<br />
<br />
Now plug you network cable in. If this solves your problems you can make this permanent by adding {{ic|broadcom}} and {{ic|tg3}} (in this order) to the {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}}:<br />
<br />
MODULES=".. broadcom tg3 .."<br />
<br />
Then rebuild the initramfs:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|These methods may work for other chipsets, such as BCM57760.}}</div>Binotahttps://wiki.archlinux.org/index.php?title=Network_configuration_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=293528Network configuration (正體中文)2014-01-19T08:18:27Z<p>Binota: /* 啟用與禁用網路介面 */ Translated</p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:Networking (正體中文)]]<br />
[[Category:Getting and installing Arch (正體中文)]]<br />
<br />
[[cs:Configuring Network]]<br />
[[el:Configuring Network]]<br />
[[es:Configuring Network]]<br />
[[fr:Connexions reseau]]<br />
[[it:Configuring Network]]<br />
[[ja:Network Configuration]]<br />
[[nl:Configuring Network]]<br />
[[pt:Configuring Network]]<br />
[[ro:Configurare retea]]<br />
[[ru:Configuring Network]]<br />
[[sk:Configuring Network]]<br />
[[tr:Ağ_Yapılandırması]]<br />
[[zh-CN:Network Configuration]]<br />
[[zh-TW:Network Configuration]]<br />
{{Related articles start}}<br />
{{Related|Jumbo Frames}}<br />
{{Related|Firewalls}}<br />
{{Related|Wireless Setup}}<br />
{{Related|List of Applications#Network Managers}}<br />
{{Related articles end}}<br />
<br />
本頁將介紹如何設定'''有線'''網路連線。若您需要設定'''無線'''網路,請參考[[Wireless Setup|無線網路設定]]。<br />
<br />
== 檢查連線 ==<br />
<br />
{{注意|若您在執行 ping 時收到了類似 {{ic|ping: icmp open socket: Operation not permitted}} 這樣的錯誤訊息,請嘗試重新安裝 {{ic|iputils}} 軟體包。}} <br />
<br />
一般來說,基本的安裝過程都已經建立了可運作的網路設定。請執行下列指令以進行檢查:<br />
<br />
{{注意|{{ic|-c 3}} 選項表示將會呼叫三次。詳細請參閱 {{ic|man ping}} 。}}<br />
{{注意|您也可以嘗試使用其他的 Domain ,如 www.hinet.net 。}}<br />
<br />
{{hc|$ ping -c 3 www.google.com|<nowiki><br />
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.<br />
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms<br />
64 bytes from 74.125.224.146: icmp_req=2 ttl=50 time=385 ms<br />
64 bytes from 74.125.224.146: icmp_req=3 ttl=50 time=298 ms<br />
<br />
--- www.l.google.com ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 1999ms<br />
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms<br />
</nowiki>}}<br />
<br />
如果沒問題的話,您可能只是想以本文的下列部分來自定您的設定。<br />
<br />
若剛才的指令出現了 unknown hosts 之類的訊息,代表您的機器無法解析網域。這可能是因為您的網路服務提供商/網關造成的。您可以嘗試 ping 一個靜態 IP 以實驗您的機器可否存取網際網路。<br />
{{注意|您也可以嘗試使用其他的 IP ,如 168.95.1.1 。}}<br />
<br />
{{hc|$ ping -c 3 8.8.8.8|<nowiki><br />
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.<br />
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms<br />
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms<br />
64 bytes from 8.8.8.8: icmp_req=3 ttl=53 time=70.6 ms<br />
<br />
--- 8.8.8.8 ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 2002ms<br />
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms<br />
</nowiki>}}<br />
<br />
{{注意|{{ic|8.8.8.8}} 為一個好記的靜態 IP 位置。這是 Google 的主要 DNS 伺服器,這表示其有一定的可信度,並且通常不會被系統或代理伺服器擋下。}}<br />
<br />
若您可以 ping 通該位置,您可能需要試著在 {{ic|/etc/resolv.conf}} 檔案中加上網域名稱伺服器。<br />
<br />
== 設定主機名稱 ==<br />
<br />
[[Wikipedia:Hostname|主機名稱]]為網路中用於識別機器的唯一識別名稱:主機名稱可以通過 {{ic|/etc/hostname}} 檔案來進行設定。一般來說該檔案包含了系統的網域名稱。下面為設定主機名稱的方法:<br />
<br />
# hostnamectl set-hostname '''myhostname'''<br />
<br />
這樣會將 '''myhostname''' 寫入 {{ic|/etc/hostname}} 檔案中。<br />
<br />
詳細請參閱 {{ic|man 5 hostname}} 與 {{ic|man 1 hostnamectl}} 。<br />
<br />
{{注意|<br />
* {{ic|hostnamectl}} 支援 FQDN<br />
* 您不需要編輯 {{ic|/etc/hosts}} 檔案,{{pkg|systemd}} 會提供主機名稱解析且預設安裝於所有系統。<br />
}}<br />
<br />
使用來自 {{Pkg|inetutils}} 的 {{ic|hostname}} 指令以設定臨時主機名稱(直到重新啟動):<br />
<br />
# hostname ''myhostname''<br />
<br />
== 裝置驅動程式 ==<br />
<br />
=== 檢查驅動程式狀態 ===<br />
<br />
[[udev]] 應該會檢測您的網路介面卡([[Wikipedia:Network_interface_controller|NIC]])並自動於啟動時載入必要的模組。檢查 {{ic|lspci -v}} 輸出內容中的「Ethernet controller」 項目(或類似的)。這應該會告訴您哪些核心模組包含了網路設備的驅動程式。舉例來說:<br />
<br />
{{hc|$ lspci -v|<br />
02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)<br />
...<br />
Kernel driver in use: atl1<br />
Kernel modules: atl1<br />
}}<br />
<br />
接下來,確認該驅動程式已經通過 {{ic|dmesg <nowiki>|</nowiki> grep ''module_name''}} 載入了。舉例來說:<br />
<br />
$ dmesg | grep atl1<br />
...<br />
atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex<br />
<br />
若驅動程式已成功加載可以跳過接下來這段。否則,您會需要知道哪些模組時您的特定型號的裝置需要哪個模組。<br />
<br />
=== 載入裝置模組 ===<br />
<br />
以 Google 搜尋正確的晶片組模組/驅動程式。常見的驅動模組有 Realtek 晶片組網卡的 {{ic|8139too}} ,或是 SiS 晶片組網卡的 {{ic|sis900}}。當您知道要使用何種模組了之後,試著[[Kernel modules#Manual module handling|手動將其載入]]。若您的到了錯誤訊息告訴您找不到該模組,則該驅動可能未包含於 Arch 核心中。您可以在 [[AUR]] 中搜尋該模組名稱。<br />
<br />
若 udev 未在開機期間檢測與載入正確的模組,請參閱 [[Kernel modules#Loading]]。<br />
<br />
== 網路介面 ==<br />
<br />
=== 裝置名稱 ===<br />
<br />
對於多網路卡的電腦,固定裝置名稱非常重要。許多設定問題都是因為介面卡名稱的改動造成的。<br />
<br />
[[udev]] 負責命名裝置。Systemd v197 則有[http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames 可預測之網路介面名稱]並可自動支配靜態名稱給網路裝置。介面名稱以 {{ic|en}} (乙太網路)、 {{ic|wl}} (無線網路) 或是 {{ic|ww}} (WWAN)作為前置字串並附上一個自動產生的識別名稱,進而產生了類似 {{ic|enp0s25}} 這樣的名稱。 <br />
<br />
要禁用這種行為,可以加上一個連接:<br />
<br />
# ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules<br />
<br />
自早期版本升級 systemd 的使用者會有一自動建立的空規則檔案。因此,若您想使用一貫的裝置名稱,只需要刪除該檔案。<br />
<br />
{{提示|您可以執行 {{ic|ip link}} 或是 {{ic|ls /sys/class/net}} 以列出所有可用的介面。}}<br />
<br />
{{注意|當您更改了介面名稱規則後,別忘了更新所有跟網路有關的組態檔案與自定的 systemd unit 檔案以因應該更改。特別是當您啟用了 [[netctl#Basic method|netctl 靜態設定檔]] ,請執行 {{ic|netctl reenable ''profile''}} 以更新所有產生的服務檔案。}}<br />
<br />
==== 更改裝置名稱 ====<br />
<br />
您可以使用 udev-rule 來手動定義裝置名稱。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"<br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"<br />
</nowiki>}}<br />
<br />
請注意這兩點:<br />
<br />
* 使用這個指令以取得 MAC 位置:{{ic|cat /sys/class/net/''device_name''/address}}。<br />
* 請確定 udev 規則中使用的是小寫的十六進位數值而不是大寫。<br />
<br />
若您的網路卡為動態 MAC ,您可以使用 DEVPATH ,例如:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"<br />
</nowiki>}}<br />
<br />
{{注意|當使用了靜態的名稱時,'''應該要避免使用類似 "eth''X''" 與 "wlan''X''"''' 這樣的名稱,因為這可能會導致核心與 udev 在開機時發生衝突。而剛好相反地,最好使用核心預設不會使用的介面名稱,如 {{ic|net0}} 、 {{ic|net1}} 、 {{ic|wifi0}} 、 {{ic|wifi1}} 。詳細說明請參閱 [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames systemd] 文件。}}<br />
<br />
=== 設定裝置的 MTU 與佇列長度 ===<br />
<br />
您可以手動定義 udev 規則來更改裝置的 MTU 與佇列長度。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1480", ATTR{tx_queue_len}="2000"<br />
</nowiki>}}<br />
<br />
=== 取得目前的裝置名稱 ===<br />
<br />
目前的 NIC 名稱可以通過 sysfs 找到<br />
<br />
{{hc|$ ls /sys/class/net|<br />
lo eth0 eth1 firewire0<br />
}}<br />
<br />
=== 啟用與禁用網路介面 ===<br />
<br />
您可以使用下列指令來啟用或禁用網路介面:<br />
<br />
# ip link set eth0 up<br />
# ip link set eth0 down<br />
<br />
要確認結果,請執行:<br />
<br />
{{hc|$ ip link show dev eth0|<br />
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000<br />
...<br />
}}<br />
<br />
== 組態設定 IP 位址 ==<br />
<br />
You have two options: a dynamically assigned address using [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]], or an unchanging "static" address.<br />
<br />
=== 動態 IP 位址 ===<br />
<br />
==== 手動執行 DHCP 用戶端 Daemon ====<br />
<br />
{{Note|{{ic|dhcpcd}} (DHCP ''client'' daemon) is not the same as {{ic|dhcpd}} (DHCP ''(server)'' daemon).}}<br />
<br />
{{hc|# dhcpcd eth0|<br />
dhcpcd: version 5.1.1 starting<br />
dhcpcd: eth0: broadcasting for a lease<br />
...<br />
dhcpcd: eth0: leased 192.168.1.70 for 86400 seconds<br />
}}<br />
<br />
And now, {{ic|ip addr show dev eth0}} should show your inet address.<br />
<br />
For some people, {{ic|dhclient}} (from the {{Pkg|dhclient}} package) works where {{ic|dhcpcd}} fails.<br />
<br />
==== 於啟動時執行 DHCP ====<br />
<br />
If you simply want to use DHCP for your Ethernet connection, you can use {{ic|dhcpcd@.service}} (provided by the {{Pkg|dhcpcd}} package).<br />
<br />
To start DHCP for {{ic|eth0}}, simply use:<br />
<br />
# systemctl start dhcpcd@eth0.service<br />
<br />
You can enable the service to automatically start at boot with:<br />
<br />
# systemctl enable dhcpcd@eth0.service<br />
<br />
If you use DHCP and you do '''not''' want your DNS servers automatically assigned every time you start your network, be sure to add the following to the last section of {{ic|dhcpcd.conf}}:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nohook resolv.conf<br />
}}<br />
<br />
Also, if you are on a network with DHCPv4 that filters Client IDs based on MAC addresses, you may need to change the following line:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 Client ID as per RFC4361. <br />
duid<br />
}}<br />
<br />
To:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the hardware address of the interface for the Client ID (DHCPv4).<br />
clientid<br />
}}<br />
<br />
Else, you may not obtain a lease since the DHCP server may not read your [http://en.wikipedia.org/wiki/DHCPv6 DHCPv6-style] Client ID correctly. See [http://tools.ietf.org/html/rfc4361 RFC 4361] for more information.<br />
<br />
To prevent {{ic|dhcpcd}} from adding domain name servers to {{ic|/etc/resolv.conf}}, use the {{ic|nooption}} option:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nooption domain_name_servers<br />
}}<br />
<br />
Then add your own DNS name server to {{ic|/etc/resolv.conf}}.<br />
<br />
You may use the {{Pkg|openresolv}} package if several different processes want to control {{ic|/etc/resolv.conf}} (e.g. {{Pkg|dhcpcd}} and a VPN client). No additional configuration for {{Pkg|dhcpcd}} is needed to use {{Pkg|openresolv}}.<br />
<br />
==== DHCP 靜態路由 ====<br />
If you need to add a static route client-side, create a new dhcpcd hook-script in {{ic|/usr/lib/dhcpcd/dhcpcd-hooks}}. The example shows a new hook-script which adds a static route to a VPN subnet on 10.11.12.0/24 via a gateway machine at 192.168.192.5:<br />
{{hc|/usr/lib/dhcpcd/dhcpcd-hooks/40-vpnroute|<br />
ip route add 10.11.12.0/24 via 192.168.192.5<br />
}}<br />
The ''40'' prefix means that it is the final hook-script to run when dhcpcd starts.<br />
<br />
=== 靜態 IP 位址 ===<br />
<br />
There are various reasons why you may wish to assign static IP addresses on your network. For instance, one may gain a certain degree of predictability with unchanging addresses, or you may not have a DHCP server available.<br />
<br />
{{Note|If you share your Internet connection from a Windows machine without a router, be sure to use static IP addresses on both computers to avoid LAN problems.}}<br />
<br />
You need:<br />
<br />
* Static IP address<br />
* [[Wikipedia:Subnetwork|Subnet mask]]<br />
* [[Wikipedia:Broadcast_address|Broadcast address]]<br />
* [[Wikipedia:Default_gateway|Gateway]]'s IP address<br />
<br />
If you are running a private network, it is safe to use IP addresses in 192.168.*.* for your IP addresses, with a subnet mask of 255.255.255.0 and a broadcast address of 192.168.*.255. The gateway is usually 192.168.*.1 or 192.168.*.254.<br />
<br />
==== 手動指派 ====<br />
<br />
You can assign a static IP address in the console:<br />
<br />
# ip addr add <IP address>/<subnet mask> broadcast <broadcast> dev <interface><br />
<br />
For example:<br />
<br />
# ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev eth0<br />
<br />
{{Note|The subnet mask was specified using [[Wikipedia:CIDR_notation|CIDR notation]].}}<br />
<br />
For more options, see {{ic|man ip}}.<br />
<br />
Add your gateway like so:<br />
<br />
# ip route add default via <default gateway IP address><br />
<br />
For example:<br />
<br />
# ip route add default via 192.168.1.1<br />
<br />
If you the get the error "No such process", it means you have to run {{ic|ip link set dev eth0 up}} as root.<br />
<br />
==== 於啟動時通過 systemd 手動連線 ====<br />
<br />
Ensure that dhcpcd is stopped and disabled:<br />
<br />
# systemctl status dhcpcd.service<br />
<br />
Create a configuration file for the [[systemd]] service. Replace {{ic|<interface>}} with the proper network interface name:<br />
<br />
{{hc|/etc/conf.d/network@<interface>|<nowiki><br />
address=192.168.0.15<br />
netmask=24<br />
broadcast=192.168.0.255<br />
gateway=192.168.0.1<br />
</nowiki>}}<br />
<br />
Create a systemd unit file:<br />
<br />
{{hc|/etc/systemd/system/network@.service|<nowiki><br />
[Unit]<br />
Description=Network connectivity (%i)<br />
Wants=network.target<br />
Before=network.target<br />
BindsTo=sys-subsystem-net-devices-%i.device<br />
After=sys-subsystem-net-devices-%i.device<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
EnvironmentFile=/etc/conf.d/network@%i<br />
<br />
ExecStart=/usr/bin/ip link set dev %i up<br />
ExecStart=/usr/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i<br />
ExecStart=/usr/bin/ip route add default via ${gateway}<br />
<br />
ExecStop=/usr/bin/ip addr flush dev %i<br />
ExecStop=/usr/bin/ip link set dev %i down<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
Enable the unit and start it, passing the name of the interface, in this case eno1:<br />
<br />
# systemctl enable network@eno1.service<br />
# systemctl start network@eno1.service<br />
<br />
If you need to manually set the nameservers, edit {{ic|/etc/resolv.conf}}:<br />
<br />
{{hc|/etc/resolv.conf|<br />
nameserver 208.67.222.222<br />
nameserver 208.67.220.220}}<br />
<br />
If {{ic|/etc/resolv.conf}} keeps getting overwritten see [[Resolv.conf]] for more details on how to address this issue.<br />
<br />
There are several different ways to utilise systemd to start the network using similar, but different, file contents, and it is also possible to hard code the parameters that can then be picked up from the file referenced in the EnvironmentFile definition. It is therefore possible, as an alternative, to put the interface name into the EnvironmentFile in /etc/conf.d/ and then use the interface name directly instead of %i. In that case the name of the file does not need the "@". It is also useful to read the documentation on systemd service files at http://www.freedesktop.org/software/systemd/man/systemd.unit.html<br />
<br />
==== 計算位址 ====<br />
<br />
You can use {{ic|ipcalc}} provided by the {{Pkg|ipcalc}} package to calculate IP broadcast, network, netmask, and host ranges for more advanced configurations. For example, I use ethernet over firewire to connect a windows machine to arch. For security and network organization, I placed them on their own network and configured the netmask and broadcast so that they are the only 2 machines on it. To figure out the netmask and broadcast addresses for this, I used ipcalc, providing it with the IP of the arch firewire nic 10.66.66.1, and specifying ipcalc should create a network of only 2 hosts.<br />
<br />
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|<nowiki><br />
Address: 10.66.66.1<br />
<br />
Netmask: 255.255.255.252 = 30<br />
Network: 10.66.66.0/30<br />
HostMin: 10.66.66.1<br />
HostMax: 10.66.66.2<br />
Broadcast: 10.66.66.3<br />
Hosts/Net: 2 Class A, Private Internet<br />
</nowiki>}}<br />
<br />
== 載入組態設定 ==<br />
<br />
To test your settings either reboot the computer or reload the relevant systemd services:<br />
<br />
# systemctl restart dhcpcd@eth0<br />
<br />
Try pinging your gateway, DNS server, ISP provider and other Internet sites, in that order, to detect any connection problems along the way, as in this example:<br />
<br />
$ ping -c 3 www.google.com<br />
<br />
== 附加設定 ==<br />
<br />
=== 筆記型電腦之 ifplugd ===<br />
<br />
{{Tip|{{Pkg|dhcpcd}} provides the same feature out of the box.}}<br />
<br />
{{Pkg|ifplugd}} in [[Official Repositories]] is a daemon which will automatically configure your Ethernet device when a cable is plugged in and automatically unconfigure it if the cable is pulled. This is useful on laptops with onboard network adapters, since it will only configure the interface when a cable is really connected. Another use is when you just need to restart the network but do not want to restart the computer or do it from the shell.<br />
<br />
By default it is configured to work for the {{ic|eth0}} device. This and other settings like delays can be configured in {{ic|/etc/ifplugd/ifplugd.conf}}.<br />
<br />
{{Note|[[Netctl]] package includes {{ic|netctl-ifplugd@.service}}, otherwise you can use {{ic|ifplugd@.service}} from {{Pkg|ifplugd}} package. Use for example {{ic|systemctl enable ifplugd@eth0.service}}.}}<br />
<br />
=== Bonding 或 LAG ===<br />
<br />
See [[netctl#Bonding]].<br />
<br />
=== IP 別名 ===<br />
<br />
{{Expansion|Manual method using [[Core Utilities#ip|ip]] should be added; then move current example using ''netctl'' into [[netctl]].}}<br />
<br />
IP aliasing is the process of adding more than one IP address to a network interface. With this, one node on a network can have multiple connections to a network, each serving a different purpose. Typical uses are virtual hosting of Web and FTP servers, or reorganizing servers without having to update any other machines (this is especially useful for nameservers).<br />
<br />
==== 範例 ====<br />
<br />
You will need {{Pkg|netctl}} from the [[Official Repositories]].<br />
<br />
Prepare the configuration:<br />
<br />
{{hc|/etc/netctl/mynetwork|<nowiki><br />
Connection='ethernet'<br />
Description='Five different addresses on the same NIC.'<br />
Interface='eth0'<br />
IP='static'<br />
Address=('192.168.1.10' '192.168.178.11' '192.168.1.12' '192.168.1.13' '192.168.1.14' '192.168.1.15')<br />
Gateway='192.168.1.1'<br />
DNS=('192.168.1.1')<br />
</nowiki>}}<br />
<br />
Then simply execute: <br />
<br />
$ netctl start mynetwork<br />
<br />
=== 更改 MAC/硬體 位址 ===<br />
<br />
請參閱 [[MAC Address Spoofing]] 。<br />
<br />
=== Internet Sharing ===<br />
<br />
請參閱 [[Internet Sharing]] 。<br />
<br />
=== Router Configuration ===<br />
<br />
請參閱 [[Router]] 。<br />
<br />
=== 區域網路主機名稱解析 ===<br />
<br />
The pre-requisite is to [[#Set the hostname]] after which hostname resolution works on the local system itself {{hc|$ ping hostname|<br />
PING hostname <nowiki>(192.168.1.2) 56(84) bytes of data.<br />
64 bytes from hostname (192.168.1.2): icmp_seq=1 ttl=64 time=0.043 ms</nowiki>}}<br />
To enable other machines to address the host by name, either a manual configuration of the respective {{ic|/etc/hosts}} files or a service to propagate/resolve the name is required. <br />
<br />
When setting up a DNS server such as [[BIND]] or [[Unbound]] is overkill, manually editing your {{ic|/etc/hosts}} is too cumbersome, or when you want more flexibility with dynamic leaving and joining of hosts to the network, it is possible to handle hostname resolution on your local network using zero-configuration networking. There are two options available:<br />
<br />
*[[Samba]] provides hostname resolution via Microsoft's '''NetBIOS'''. It only requires installation of {{Pkg|samba}} and enabling of the {{ic|nmbd.service}} service. Computers running Windows, OS X, or Linux with {{ic|nmbd}} running, will be able to find your machine.<br />
<br />
*[[Avahi]] provides hostname resolution via '''zeroconf''', also known as Avahi or Bonjour. It requires slightly more complex configuration than Samba: see [[Avahi#Hostname resolution]] for details. Computers running OS X, or Linux with an Avahi daemon running, will be able to find your machine. Windows does not have an built-in Avahi client or daemon.<br />
<br />
== 診斷 ==<br />
<br />
=== Swapping computers on the cable modem ===<br />
<br />
Some cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.<br />
<br />
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].<br />
<br />
=== The TCP window scaling problem ===<br />
<br />
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.<br />
<br />
Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html RFC 1323] was written to improve the situation: Window Scaling. The "window" value, provided in all packets, will be modified by a Scale Factor defined once, at the very beginning of the connection.<br />
<br />
That 8-bit Scale Factor allows the Window to be up to 32 times higher than the initial 64Kb.<br />
<br />
It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts.<br />
<br />
The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.<br />
<br />
The resulting connection is at best very slow or broken.<br />
<br />
==== How to diagnose the problem ====<br />
<br />
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).<br />
<br />
When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|ip addr}} will report normal status... and actually everything appears normal.<br />
<br />
If you cannot browse any website, but you can ping some random hosts, chances are great that you're experiencing this problem: ping uses ICMP and is not affected by TCP problems.<br />
<br />
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).<br />
<br />
==== How to fix it (The bad way) ====<br />
<br />
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.<br />
<br />
# echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem<br />
<br />
==== How to fix it (The good way) ====<br />
<br />
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.d/99-disable_window_scaling.conf}} (see also [[sysctl]])<br />
<br />
net.ipv4.tcp_window_scaling = 0<br />
<br />
==== How to fix it (The best way) ====<br />
<br />
This problem is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.<br />
<br />
==== More about it ====<br />
<br />
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].<br />
<br />
There are also several relevant threads on the LKML.<br />
<br />
=== Realtek no link / WOL problem ===<br />
<br />
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice a problem where the NIC seems to be disabled on boot and has no Link light. This can usually be found on a dual boot system where Windows is also installed. It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause. These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots. You will be able to notice if this problem is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off. Normal operation should be that the link light is always on as long as the system is on, even during POST. This problem will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this problem:<br />
<br />
==== Method 1 - Rollback/change Windows driver ====<br />
<br />
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).<br />
<br />
==== Method 2 - Enable WOL in Windows driver ====<br />
<br />
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems). In Windows, under Device Manager, find your Realtek network adapter and double-click it. Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.<br />
<br />
In Windows XP (example)<br />
Right click my computer<br />
--> Hardware tab<br />
--> Device Manager<br />
--> Network Adapters<br />
--> "double click" Realtek ...<br />
--> Advanced tab<br />
--> Wake-On-Lan After Shutdown<br />
--> Enable<br />
<br />
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{ic|Disable}} has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.}}<br />
<br />
==== Method 3 - Newer Realtek Linux driver ====<br />
<br />
Any newer driver for these Realtek cards can be found for Linux on the realtek site. (untested but believed to also solve the problem).<br />
<br />
==== Method 4 - Enable ''LAN Boot ROM'' in BIOS/CMOS ====<br />
<br />
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.<br />
<br />
{{Note|This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.}}<br />
<br />
=== DLink G604T/DLink G502T DNS problem ===<br />
<br />
Users with a DLink G604T/DLink G502T router, using DHCP and have firmware v2.00+ (typically users with AUS firmware) may have problems with certain programs not resolving the DNS. One of these programs are unfortunatley pacman. The problem is basically the router in certain situations is not sending the DNS properly to DHCP, which causes programs to try and connect to servers with an IP address of 1.0.0.0 and fail with a connection timed out error<br />
<br />
==== How to diagnose the problem ====<br />
<br />
The best way to diagnose the problem is to use Firefox/Konqueror/links/seamonkey and to enable wget for pacman. If this is a fresh install of Arch Linux, then you may want to consider installing {{ic|links}} through the live CD.<br />
<br />
Firstly, enable wget for pacman (since it gives us info about pacman when it is downloading packages)<br />
Open {{ic|/etc/pacman.conf}} with your favourite editor and uncomment the following line (remove the # if it is there)<br />
<br />
XferCommand=/usr/bin/wget --passive-ftp -c -O %o %u<br />
<br />
While you are editing {{ic|/etc/pacman.conf}}, check the default mirror that pacman uses to download packages.<br />
<br />
Now open up the default mirror in an Internet browser to see if the mirror actually works. If it does work, then do {{ic|pacman -Syy}} (otherwise pick another working mirror and set it to the pacman default). If you get something similar to the following (notice the 1.0.0.0),<br />
<br />
<nowiki>ftp://mirror.pacific.net.au/linux/archlinux/extra/os/i686/extra.db.tar.gz</nowiki><br />
=> '/var/lib/pacman/community.db.tar.gz.part'<br />
Resolving mirror.pacific.net.au... 1.0.0.0<br />
<br />
then you most likely have this problem. The 1.0.0.0 means it is unable to resolve DNS, so we must add it to {{ic|/etc/resolv.conf}}.<br />
<br />
==== How to fix it ====<br />
<br />
{{Out of date|{{Pkg|dhcpcd}} does not use {{ic|/etc/conf.d/dhcpcd}} any more.}}<br />
<br />
Basically what we need to do is to manually add the DNS servers to our {{ic|/etc/resolv.conf}} file. The problem is that DHCP automatically deletes and replaces this file on boot, so we need to edit {{ic|/etc/conf.d/dhcpcd}} and change the flags to stop DHCP from doing this.<br />
<br />
When you open {{ic|/etc/conf.d/dhcpcd}}, you should see something close to the following:<br />
<br />
DHCPCD_ARGS="-t 30 -h $HOSTNAME"<br />
<br />
Add the {{ic|-R}} flag to the arguments, e.g.,<br />
<br />
DHCPCD_ARGS="-R -t 30 -h $HOSTNAME"<br />
<br />
{{Note|1=If you are using {{Pkg|dhcpcd}} >= 4.0.2, the {{ic|-R}} flag has been deprecated. Please see the [[#Run DHCP at boot]] section for information on how to use a custom {{ic|/etc/resolv.conf}} file.}}<br />
<br />
Save and close the file; now open {{ic|/etc/resolv.conf}}. You should see a single nameserver (most likely 10.1.1.1). This is the gateway to your router, which we need to connect to in order to get the DNS servers of your ISP. Paste the IP address into your browser and log in to your router. Go to the DNS section, and you should see an IP address in the Primary DNS Server field; copy it and paste it as a nameserver '''ABOVE''' the current gateway one.<br />
<br />
For example, {{ic|/etc/resolv.conf}} should look something along the lines of:<br />
<br />
nameserver 10.1.1.1<br />
<br />
If my primary DNS server is 211.29.132.12, then change {{ic|/etc/resolv.conf}} to:<br />
<br />
nameserver 211.29.132.12<br />
nameserver 10.1.1.1<br />
<br />
Now restart the network daemon by running {{ic|systemctl restart dhcpcd@<interface>}} and do {{ic|pacman -Syy}}. If it syncs correctly with the server, then the problem is solved.<br />
<br />
==== More about it ====<br />
<br />
This is the whirlpool forum (Australian ISP community) which talks about and gives the same solution to the problem:<br />
<br />
http://forums.whirlpool.net.au/forum-replies-archive.cfm/461625.html<br />
<br />
=== Check DHCP problem by releasing IP first ===<br />
<br />
Problem may occur when DHCP get wrong IP assignment. For example when two routers are tied together through VPN. The router that is connected to me by VPN may assigning IP address. To fix it. On a console, as root, release IP address:<br />
<br />
# dhcpcd -k<br />
<br />
Then request a new one:<br />
<br />
# dhcpcd<br />
<br />
Maybe you had to run those two commands many times.<br />
<br />
=== No eth0 with Atheros AR8161 ===<br />
<br />
{{Note|With the 3.10.2-1-ARCH kernel update, the alx ethernet driver module is included in the package.}}<br />
<br />
With the Atheros AR8161 Gigabit Ethernet card, the ethernet connection is not working out-of-the-box (with the installation media of March 2013). The module "alx" needs to be loaded but is not present.<br />
<br />
The driver from [http://linuxwireless.org/en/users/Download/stable/#compat-wireless_stable_releases compat-wireless] (that has become [https://backports.wiki.kernel.org/index.php/Releases compat-drives] since linux 3.7) need to be installed. The "-u" postfix annotates that Qualcomm have applied a driver under a unified driver.<br />
<br />
$ wget https://www.kernel.org/pub/linux/kernel/projects/backports/2013/03/28/compat-drivers-2013-03-28-5-u.tar.bz2<br />
$ tar xjf compat*<br />
$ cd compat*<br />
$ ./scripts/driver-select alx<br />
$ make<br />
$ sudo make install<br />
$ sudo modprobe alx<br />
<br />
The alx driver has not been added to Linux kernel due to various problems. Compatibility between the different kernel versions has been spotty. For better support follow the [http://lists.infradead.org/mailman/listinfo/unified-drivers mailing list]and [http://www.linuxfoundation.org/collaborate/workgroups/networking/alx alx page]for latest working solution for alx.<br />
<br />
The driver must be built and installed after every kernel change.<br />
<br />
Alternatively you can use the AUR package for [https://aur.archlinux.org/packages/compat-drivers-patched/ compat drivers], which installs many other drivers.<br />
<br />
=== No eth0 with Atheros AR9485 ===<br />
<br />
The ethernet (eth0) for Atheros AR9485 are not working out-of-the-box (with installation media of March 2013). The working solution for this is to install the package [https://aur.archlinux.org/packages/compat-drivers-patched/ compat-drivers-patched] from AUR.<br />
<br />
=== No carrier / no connection after suspend ===<br />
After suspend to RAM no connection is found although the network cable is plugged in. <br />
This may be caused by PCI power management. What is the output of<br />
<br />
# ip link show eth0<br />
<br />
If the line contains "NO-CARRIER" even though there's a cable connected to your eth0 port, it is possible that the device was auto-suspended and the media sense feature doesn't work. To solve this, first you need to find your ethernet controllers PCI address by<br />
<br />
# lspci<br />
<br />
This should look similar to this:<br />
<br />
...<br />
00:19.0 Ethernet controller: Intel Corporation 82577LM Gigabit Network Connection (rev 06)<br />
...<br />
<br />
So the address is 00:19.0.<br />
Now check the PM status of the device by issuing<br />
<br />
# cat "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
substituting 00:19.0 with the address obtained from lspci.<br />
If the output reads "auto", you can try to bring the device out of suspend by<br />
<br />
# echo on > "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
Don't forget to substitute the address again.<br />
<br />
{{Note|1=This appears to be a bug in kernel 3.8.4.1- (3.8.8.1 is still affected): [https://bbs.archlinux.org/viewtopic.php?id=159837&p=2 Forum discussion.] It also appears a fix is [https://lkml.org/lkml/2013/1/18/147 on the way. (It will be likely fixed in 3.9.)] In the meantime, the above is a suitable workaround.}}<br />
<br />
=== Broadcom BCM57780 ===<br />
<br />
This Broadcom chipset sometimes does not behave well unless you specify the order of the modules to be loaded. The modules are {{ic|broadcom}} and {{ic|tg3}}, the former needing to be loaded first.<br />
<br />
These steps should help if your computer has this chipset:<br />
$ lspci | grep Ethernet<br />
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)<br />
<br />
If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following (as root):<br />
# modprobe -r tg3<br />
# modprobe broadcom<br />
# modprobe tg3<br />
<br />
Now plug you network cable in. If this solves your problems you can make this permanent by adding {{ic|broadcom}} and {{ic|tg3}} (in this order) to the {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}}:<br />
<br />
MODULES=".. broadcom tg3 .."<br />
<br />
Then rebuild the initramfs:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|These methods may work for other chipsets, such as BCM57760.}}</div>Binotahttps://wiki.archlinux.org/index.php?title=Network_configuration_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=293527Network configuration (正體中文)2014-01-19T08:17:33Z<p>Binota: /* 取得目前的裝置名稱 */ Translated</p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:Networking (正體中文)]]<br />
[[Category:Getting and installing Arch (正體中文)]]<br />
<br />
[[cs:Configuring Network]]<br />
[[el:Configuring Network]]<br />
[[es:Configuring Network]]<br />
[[fr:Connexions reseau]]<br />
[[it:Configuring Network]]<br />
[[ja:Network Configuration]]<br />
[[nl:Configuring Network]]<br />
[[pt:Configuring Network]]<br />
[[ro:Configurare retea]]<br />
[[ru:Configuring Network]]<br />
[[sk:Configuring Network]]<br />
[[tr:Ağ_Yapılandırması]]<br />
[[zh-CN:Network Configuration]]<br />
[[zh-TW:Network Configuration]]<br />
{{Related articles start}}<br />
{{Related|Jumbo Frames}}<br />
{{Related|Firewalls}}<br />
{{Related|Wireless Setup}}<br />
{{Related|List of Applications#Network Managers}}<br />
{{Related articles end}}<br />
<br />
本頁將介紹如何設定'''有線'''網路連線。若您需要設定'''無線'''網路,請參考[[Wireless Setup|無線網路設定]]。<br />
<br />
== 檢查連線 ==<br />
<br />
{{注意|若您在執行 ping 時收到了類似 {{ic|ping: icmp open socket: Operation not permitted}} 這樣的錯誤訊息,請嘗試重新安裝 {{ic|iputils}} 軟體包。}} <br />
<br />
一般來說,基本的安裝過程都已經建立了可運作的網路設定。請執行下列指令以進行檢查:<br />
<br />
{{注意|{{ic|-c 3}} 選項表示將會呼叫三次。詳細請參閱 {{ic|man ping}} 。}}<br />
{{注意|您也可以嘗試使用其他的 Domain ,如 www.hinet.net 。}}<br />
<br />
{{hc|$ ping -c 3 www.google.com|<nowiki><br />
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.<br />
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms<br />
64 bytes from 74.125.224.146: icmp_req=2 ttl=50 time=385 ms<br />
64 bytes from 74.125.224.146: icmp_req=3 ttl=50 time=298 ms<br />
<br />
--- www.l.google.com ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 1999ms<br />
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms<br />
</nowiki>}}<br />
<br />
如果沒問題的話,您可能只是想以本文的下列部分來自定您的設定。<br />
<br />
若剛才的指令出現了 unknown hosts 之類的訊息,代表您的機器無法解析網域。這可能是因為您的網路服務提供商/網關造成的。您可以嘗試 ping 一個靜態 IP 以實驗您的機器可否存取網際網路。<br />
{{注意|您也可以嘗試使用其他的 IP ,如 168.95.1.1 。}}<br />
<br />
{{hc|$ ping -c 3 8.8.8.8|<nowiki><br />
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.<br />
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms<br />
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms<br />
64 bytes from 8.8.8.8: icmp_req=3 ttl=53 time=70.6 ms<br />
<br />
--- 8.8.8.8 ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 2002ms<br />
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms<br />
</nowiki>}}<br />
<br />
{{注意|{{ic|8.8.8.8}} 為一個好記的靜態 IP 位置。這是 Google 的主要 DNS 伺服器,這表示其有一定的可信度,並且通常不會被系統或代理伺服器擋下。}}<br />
<br />
若您可以 ping 通該位置,您可能需要試著在 {{ic|/etc/resolv.conf}} 檔案中加上網域名稱伺服器。<br />
<br />
== 設定主機名稱 ==<br />
<br />
[[Wikipedia:Hostname|主機名稱]]為網路中用於識別機器的唯一識別名稱:主機名稱可以通過 {{ic|/etc/hostname}} 檔案來進行設定。一般來說該檔案包含了系統的網域名稱。下面為設定主機名稱的方法:<br />
<br />
# hostnamectl set-hostname '''myhostname'''<br />
<br />
這樣會將 '''myhostname''' 寫入 {{ic|/etc/hostname}} 檔案中。<br />
<br />
詳細請參閱 {{ic|man 5 hostname}} 與 {{ic|man 1 hostnamectl}} 。<br />
<br />
{{注意|<br />
* {{ic|hostnamectl}} 支援 FQDN<br />
* 您不需要編輯 {{ic|/etc/hosts}} 檔案,{{pkg|systemd}} 會提供主機名稱解析且預設安裝於所有系統。<br />
}}<br />
<br />
使用來自 {{Pkg|inetutils}} 的 {{ic|hostname}} 指令以設定臨時主機名稱(直到重新啟動):<br />
<br />
# hostname ''myhostname''<br />
<br />
== 裝置驅動程式 ==<br />
<br />
=== 檢查驅動程式狀態 ===<br />
<br />
[[udev]] 應該會檢測您的網路介面卡([[Wikipedia:Network_interface_controller|NIC]])並自動於啟動時載入必要的模組。檢查 {{ic|lspci -v}} 輸出內容中的「Ethernet controller」 項目(或類似的)。這應該會告訴您哪些核心模組包含了網路設備的驅動程式。舉例來說:<br />
<br />
{{hc|$ lspci -v|<br />
02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)<br />
...<br />
Kernel driver in use: atl1<br />
Kernel modules: atl1<br />
}}<br />
<br />
接下來,確認該驅動程式已經通過 {{ic|dmesg <nowiki>|</nowiki> grep ''module_name''}} 載入了。舉例來說:<br />
<br />
$ dmesg | grep atl1<br />
...<br />
atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex<br />
<br />
若驅動程式已成功加載可以跳過接下來這段。否則,您會需要知道哪些模組時您的特定型號的裝置需要哪個模組。<br />
<br />
=== 載入裝置模組 ===<br />
<br />
以 Google 搜尋正確的晶片組模組/驅動程式。常見的驅動模組有 Realtek 晶片組網卡的 {{ic|8139too}} ,或是 SiS 晶片組網卡的 {{ic|sis900}}。當您知道要使用何種模組了之後,試著[[Kernel modules#Manual module handling|手動將其載入]]。若您的到了錯誤訊息告訴您找不到該模組,則該驅動可能未包含於 Arch 核心中。您可以在 [[AUR]] 中搜尋該模組名稱。<br />
<br />
若 udev 未在開機期間檢測與載入正確的模組,請參閱 [[Kernel modules#Loading]]。<br />
<br />
== 網路介面 ==<br />
<br />
=== 裝置名稱 ===<br />
<br />
對於多網路卡的電腦,固定裝置名稱非常重要。許多設定問題都是因為介面卡名稱的改動造成的。<br />
<br />
[[udev]] 負責命名裝置。Systemd v197 則有[http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames 可預測之網路介面名稱]並可自動支配靜態名稱給網路裝置。介面名稱以 {{ic|en}} (乙太網路)、 {{ic|wl}} (無線網路) 或是 {{ic|ww}} (WWAN)作為前置字串並附上一個自動產生的識別名稱,進而產生了類似 {{ic|enp0s25}} 這樣的名稱。 <br />
<br />
要禁用這種行為,可以加上一個連接:<br />
<br />
# ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules<br />
<br />
自早期版本升級 systemd 的使用者會有一自動建立的空規則檔案。因此,若您想使用一貫的裝置名稱,只需要刪除該檔案。<br />
<br />
{{提示|您可以執行 {{ic|ip link}} 或是 {{ic|ls /sys/class/net}} 以列出所有可用的介面。}}<br />
<br />
{{注意|當您更改了介面名稱規則後,別忘了更新所有跟網路有關的組態檔案與自定的 systemd unit 檔案以因應該更改。特別是當您啟用了 [[netctl#Basic method|netctl 靜態設定檔]] ,請執行 {{ic|netctl reenable ''profile''}} 以更新所有產生的服務檔案。}}<br />
<br />
==== 更改裝置名稱 ====<br />
<br />
您可以使用 udev-rule 來手動定義裝置名稱。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"<br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"<br />
</nowiki>}}<br />
<br />
請注意這兩點:<br />
<br />
* 使用這個指令以取得 MAC 位置:{{ic|cat /sys/class/net/''device_name''/address}}。<br />
* 請確定 udev 規則中使用的是小寫的十六進位數值而不是大寫。<br />
<br />
若您的網路卡為動態 MAC ,您可以使用 DEVPATH ,例如:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"<br />
</nowiki>}}<br />
<br />
{{注意|當使用了靜態的名稱時,'''應該要避免使用類似 "eth''X''" 與 "wlan''X''"''' 這樣的名稱,因為這可能會導致核心與 udev 在開機時發生衝突。而剛好相反地,最好使用核心預設不會使用的介面名稱,如 {{ic|net0}} 、 {{ic|net1}} 、 {{ic|wifi0}} 、 {{ic|wifi1}} 。詳細說明請參閱 [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames systemd] 文件。}}<br />
<br />
=== 設定裝置的 MTU 與佇列長度 ===<br />
<br />
您可以手動定義 udev 規則來更改裝置的 MTU 與佇列長度。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1480", ATTR{tx_queue_len}="2000"<br />
</nowiki>}}<br />
<br />
=== 取得目前的裝置名稱 ===<br />
<br />
目前的 NIC 名稱可以通過 sysfs 找到<br />
<br />
{{hc|$ ls /sys/class/net|<br />
lo eth0 eth1 firewire0<br />
}}<br />
<br />
=== 啟用與禁用網路介面 ===<br />
<br />
You can activate or deactivate network interfaces using:<br />
<br />
# ip link set eth0 up<br />
# ip link set eth0 down<br />
<br />
To check the result:<br />
<br />
{{hc|$ ip link show dev eth0|<br />
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000<br />
...<br />
}}<br />
<br />
== 組態設定 IP 位址 ==<br />
<br />
You have two options: a dynamically assigned address using [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]], or an unchanging "static" address.<br />
<br />
=== 動態 IP 位址 ===<br />
<br />
==== 手動執行 DHCP 用戶端 Daemon ====<br />
<br />
{{Note|{{ic|dhcpcd}} (DHCP ''client'' daemon) is not the same as {{ic|dhcpd}} (DHCP ''(server)'' daemon).}}<br />
<br />
{{hc|# dhcpcd eth0|<br />
dhcpcd: version 5.1.1 starting<br />
dhcpcd: eth0: broadcasting for a lease<br />
...<br />
dhcpcd: eth0: leased 192.168.1.70 for 86400 seconds<br />
}}<br />
<br />
And now, {{ic|ip addr show dev eth0}} should show your inet address.<br />
<br />
For some people, {{ic|dhclient}} (from the {{Pkg|dhclient}} package) works where {{ic|dhcpcd}} fails.<br />
<br />
==== 於啟動時執行 DHCP ====<br />
<br />
If you simply want to use DHCP for your Ethernet connection, you can use {{ic|dhcpcd@.service}} (provided by the {{Pkg|dhcpcd}} package).<br />
<br />
To start DHCP for {{ic|eth0}}, simply use:<br />
<br />
# systemctl start dhcpcd@eth0.service<br />
<br />
You can enable the service to automatically start at boot with:<br />
<br />
# systemctl enable dhcpcd@eth0.service<br />
<br />
If you use DHCP and you do '''not''' want your DNS servers automatically assigned every time you start your network, be sure to add the following to the last section of {{ic|dhcpcd.conf}}:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nohook resolv.conf<br />
}}<br />
<br />
Also, if you are on a network with DHCPv4 that filters Client IDs based on MAC addresses, you may need to change the following line:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 Client ID as per RFC4361. <br />
duid<br />
}}<br />
<br />
To:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the hardware address of the interface for the Client ID (DHCPv4).<br />
clientid<br />
}}<br />
<br />
Else, you may not obtain a lease since the DHCP server may not read your [http://en.wikipedia.org/wiki/DHCPv6 DHCPv6-style] Client ID correctly. See [http://tools.ietf.org/html/rfc4361 RFC 4361] for more information.<br />
<br />
To prevent {{ic|dhcpcd}} from adding domain name servers to {{ic|/etc/resolv.conf}}, use the {{ic|nooption}} option:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nooption domain_name_servers<br />
}}<br />
<br />
Then add your own DNS name server to {{ic|/etc/resolv.conf}}.<br />
<br />
You may use the {{Pkg|openresolv}} package if several different processes want to control {{ic|/etc/resolv.conf}} (e.g. {{Pkg|dhcpcd}} and a VPN client). No additional configuration for {{Pkg|dhcpcd}} is needed to use {{Pkg|openresolv}}.<br />
<br />
==== DHCP 靜態路由 ====<br />
If you need to add a static route client-side, create a new dhcpcd hook-script in {{ic|/usr/lib/dhcpcd/dhcpcd-hooks}}. The example shows a new hook-script which adds a static route to a VPN subnet on 10.11.12.0/24 via a gateway machine at 192.168.192.5:<br />
{{hc|/usr/lib/dhcpcd/dhcpcd-hooks/40-vpnroute|<br />
ip route add 10.11.12.0/24 via 192.168.192.5<br />
}}<br />
The ''40'' prefix means that it is the final hook-script to run when dhcpcd starts.<br />
<br />
=== 靜態 IP 位址 ===<br />
<br />
There are various reasons why you may wish to assign static IP addresses on your network. For instance, one may gain a certain degree of predictability with unchanging addresses, or you may not have a DHCP server available.<br />
<br />
{{Note|If you share your Internet connection from a Windows machine without a router, be sure to use static IP addresses on both computers to avoid LAN problems.}}<br />
<br />
You need:<br />
<br />
* Static IP address<br />
* [[Wikipedia:Subnetwork|Subnet mask]]<br />
* [[Wikipedia:Broadcast_address|Broadcast address]]<br />
* [[Wikipedia:Default_gateway|Gateway]]'s IP address<br />
<br />
If you are running a private network, it is safe to use IP addresses in 192.168.*.* for your IP addresses, with a subnet mask of 255.255.255.0 and a broadcast address of 192.168.*.255. The gateway is usually 192.168.*.1 or 192.168.*.254.<br />
<br />
==== 手動指派 ====<br />
<br />
You can assign a static IP address in the console:<br />
<br />
# ip addr add <IP address>/<subnet mask> broadcast <broadcast> dev <interface><br />
<br />
For example:<br />
<br />
# ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev eth0<br />
<br />
{{Note|The subnet mask was specified using [[Wikipedia:CIDR_notation|CIDR notation]].}}<br />
<br />
For more options, see {{ic|man ip}}.<br />
<br />
Add your gateway like so:<br />
<br />
# ip route add default via <default gateway IP address><br />
<br />
For example:<br />
<br />
# ip route add default via 192.168.1.1<br />
<br />
If you the get the error "No such process", it means you have to run {{ic|ip link set dev eth0 up}} as root.<br />
<br />
==== 於啟動時通過 systemd 手動連線 ====<br />
<br />
Ensure that dhcpcd is stopped and disabled:<br />
<br />
# systemctl status dhcpcd.service<br />
<br />
Create a configuration file for the [[systemd]] service. Replace {{ic|<interface>}} with the proper network interface name:<br />
<br />
{{hc|/etc/conf.d/network@<interface>|<nowiki><br />
address=192.168.0.15<br />
netmask=24<br />
broadcast=192.168.0.255<br />
gateway=192.168.0.1<br />
</nowiki>}}<br />
<br />
Create a systemd unit file:<br />
<br />
{{hc|/etc/systemd/system/network@.service|<nowiki><br />
[Unit]<br />
Description=Network connectivity (%i)<br />
Wants=network.target<br />
Before=network.target<br />
BindsTo=sys-subsystem-net-devices-%i.device<br />
After=sys-subsystem-net-devices-%i.device<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
EnvironmentFile=/etc/conf.d/network@%i<br />
<br />
ExecStart=/usr/bin/ip link set dev %i up<br />
ExecStart=/usr/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i<br />
ExecStart=/usr/bin/ip route add default via ${gateway}<br />
<br />
ExecStop=/usr/bin/ip addr flush dev %i<br />
ExecStop=/usr/bin/ip link set dev %i down<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
Enable the unit and start it, passing the name of the interface, in this case eno1:<br />
<br />
# systemctl enable network@eno1.service<br />
# systemctl start network@eno1.service<br />
<br />
If you need to manually set the nameservers, edit {{ic|/etc/resolv.conf}}:<br />
<br />
{{hc|/etc/resolv.conf|<br />
nameserver 208.67.222.222<br />
nameserver 208.67.220.220}}<br />
<br />
If {{ic|/etc/resolv.conf}} keeps getting overwritten see [[Resolv.conf]] for more details on how to address this issue.<br />
<br />
There are several different ways to utilise systemd to start the network using similar, but different, file contents, and it is also possible to hard code the parameters that can then be picked up from the file referenced in the EnvironmentFile definition. It is therefore possible, as an alternative, to put the interface name into the EnvironmentFile in /etc/conf.d/ and then use the interface name directly instead of %i. In that case the name of the file does not need the "@". It is also useful to read the documentation on systemd service files at http://www.freedesktop.org/software/systemd/man/systemd.unit.html<br />
<br />
==== 計算位址 ====<br />
<br />
You can use {{ic|ipcalc}} provided by the {{Pkg|ipcalc}} package to calculate IP broadcast, network, netmask, and host ranges for more advanced configurations. For example, I use ethernet over firewire to connect a windows machine to arch. For security and network organization, I placed them on their own network and configured the netmask and broadcast so that they are the only 2 machines on it. To figure out the netmask and broadcast addresses for this, I used ipcalc, providing it with the IP of the arch firewire nic 10.66.66.1, and specifying ipcalc should create a network of only 2 hosts.<br />
<br />
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|<nowiki><br />
Address: 10.66.66.1<br />
<br />
Netmask: 255.255.255.252 = 30<br />
Network: 10.66.66.0/30<br />
HostMin: 10.66.66.1<br />
HostMax: 10.66.66.2<br />
Broadcast: 10.66.66.3<br />
Hosts/Net: 2 Class A, Private Internet<br />
</nowiki>}}<br />
<br />
== 載入組態設定 ==<br />
<br />
To test your settings either reboot the computer or reload the relevant systemd services:<br />
<br />
# systemctl restart dhcpcd@eth0<br />
<br />
Try pinging your gateway, DNS server, ISP provider and other Internet sites, in that order, to detect any connection problems along the way, as in this example:<br />
<br />
$ ping -c 3 www.google.com<br />
<br />
== 附加設定 ==<br />
<br />
=== 筆記型電腦之 ifplugd ===<br />
<br />
{{Tip|{{Pkg|dhcpcd}} provides the same feature out of the box.}}<br />
<br />
{{Pkg|ifplugd}} in [[Official Repositories]] is a daemon which will automatically configure your Ethernet device when a cable is plugged in and automatically unconfigure it if the cable is pulled. This is useful on laptops with onboard network adapters, since it will only configure the interface when a cable is really connected. Another use is when you just need to restart the network but do not want to restart the computer or do it from the shell.<br />
<br />
By default it is configured to work for the {{ic|eth0}} device. This and other settings like delays can be configured in {{ic|/etc/ifplugd/ifplugd.conf}}.<br />
<br />
{{Note|[[Netctl]] package includes {{ic|netctl-ifplugd@.service}}, otherwise you can use {{ic|ifplugd@.service}} from {{Pkg|ifplugd}} package. Use for example {{ic|systemctl enable ifplugd@eth0.service}}.}}<br />
<br />
=== Bonding 或 LAG ===<br />
<br />
See [[netctl#Bonding]].<br />
<br />
=== IP 別名 ===<br />
<br />
{{Expansion|Manual method using [[Core Utilities#ip|ip]] should be added; then move current example using ''netctl'' into [[netctl]].}}<br />
<br />
IP aliasing is the process of adding more than one IP address to a network interface. With this, one node on a network can have multiple connections to a network, each serving a different purpose. Typical uses are virtual hosting of Web and FTP servers, or reorganizing servers without having to update any other machines (this is especially useful for nameservers).<br />
<br />
==== 範例 ====<br />
<br />
You will need {{Pkg|netctl}} from the [[Official Repositories]].<br />
<br />
Prepare the configuration:<br />
<br />
{{hc|/etc/netctl/mynetwork|<nowiki><br />
Connection='ethernet'<br />
Description='Five different addresses on the same NIC.'<br />
Interface='eth0'<br />
IP='static'<br />
Address=('192.168.1.10' '192.168.178.11' '192.168.1.12' '192.168.1.13' '192.168.1.14' '192.168.1.15')<br />
Gateway='192.168.1.1'<br />
DNS=('192.168.1.1')<br />
</nowiki>}}<br />
<br />
Then simply execute: <br />
<br />
$ netctl start mynetwork<br />
<br />
=== 更改 MAC/硬體 位址 ===<br />
<br />
請參閱 [[MAC Address Spoofing]] 。<br />
<br />
=== Internet Sharing ===<br />
<br />
請參閱 [[Internet Sharing]] 。<br />
<br />
=== Router Configuration ===<br />
<br />
請參閱 [[Router]] 。<br />
<br />
=== 區域網路主機名稱解析 ===<br />
<br />
The pre-requisite is to [[#Set the hostname]] after which hostname resolution works on the local system itself {{hc|$ ping hostname|<br />
PING hostname <nowiki>(192.168.1.2) 56(84) bytes of data.<br />
64 bytes from hostname (192.168.1.2): icmp_seq=1 ttl=64 time=0.043 ms</nowiki>}}<br />
To enable other machines to address the host by name, either a manual configuration of the respective {{ic|/etc/hosts}} files or a service to propagate/resolve the name is required. <br />
<br />
When setting up a DNS server such as [[BIND]] or [[Unbound]] is overkill, manually editing your {{ic|/etc/hosts}} is too cumbersome, or when you want more flexibility with dynamic leaving and joining of hosts to the network, it is possible to handle hostname resolution on your local network using zero-configuration networking. There are two options available:<br />
<br />
*[[Samba]] provides hostname resolution via Microsoft's '''NetBIOS'''. It only requires installation of {{Pkg|samba}} and enabling of the {{ic|nmbd.service}} service. Computers running Windows, OS X, or Linux with {{ic|nmbd}} running, will be able to find your machine.<br />
<br />
*[[Avahi]] provides hostname resolution via '''zeroconf''', also known as Avahi or Bonjour. It requires slightly more complex configuration than Samba: see [[Avahi#Hostname resolution]] for details. Computers running OS X, or Linux with an Avahi daemon running, will be able to find your machine. Windows does not have an built-in Avahi client or daemon.<br />
<br />
== 診斷 ==<br />
<br />
=== Swapping computers on the cable modem ===<br />
<br />
Some cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.<br />
<br />
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].<br />
<br />
=== The TCP window scaling problem ===<br />
<br />
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.<br />
<br />
Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html RFC 1323] was written to improve the situation: Window Scaling. The "window" value, provided in all packets, will be modified by a Scale Factor defined once, at the very beginning of the connection.<br />
<br />
That 8-bit Scale Factor allows the Window to be up to 32 times higher than the initial 64Kb.<br />
<br />
It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts.<br />
<br />
The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.<br />
<br />
The resulting connection is at best very slow or broken.<br />
<br />
==== How to diagnose the problem ====<br />
<br />
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).<br />
<br />
When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|ip addr}} will report normal status... and actually everything appears normal.<br />
<br />
If you cannot browse any website, but you can ping some random hosts, chances are great that you're experiencing this problem: ping uses ICMP and is not affected by TCP problems.<br />
<br />
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).<br />
<br />
==== How to fix it (The bad way) ====<br />
<br />
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.<br />
<br />
# echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem<br />
<br />
==== How to fix it (The good way) ====<br />
<br />
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.d/99-disable_window_scaling.conf}} (see also [[sysctl]])<br />
<br />
net.ipv4.tcp_window_scaling = 0<br />
<br />
==== How to fix it (The best way) ====<br />
<br />
This problem is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.<br />
<br />
==== More about it ====<br />
<br />
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].<br />
<br />
There are also several relevant threads on the LKML.<br />
<br />
=== Realtek no link / WOL problem ===<br />
<br />
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice a problem where the NIC seems to be disabled on boot and has no Link light. This can usually be found on a dual boot system where Windows is also installed. It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause. These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots. You will be able to notice if this problem is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off. Normal operation should be that the link light is always on as long as the system is on, even during POST. This problem will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this problem:<br />
<br />
==== Method 1 - Rollback/change Windows driver ====<br />
<br />
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).<br />
<br />
==== Method 2 - Enable WOL in Windows driver ====<br />
<br />
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems). In Windows, under Device Manager, find your Realtek network adapter and double-click it. Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.<br />
<br />
In Windows XP (example)<br />
Right click my computer<br />
--> Hardware tab<br />
--> Device Manager<br />
--> Network Adapters<br />
--> "double click" Realtek ...<br />
--> Advanced tab<br />
--> Wake-On-Lan After Shutdown<br />
--> Enable<br />
<br />
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{ic|Disable}} has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.}}<br />
<br />
==== Method 3 - Newer Realtek Linux driver ====<br />
<br />
Any newer driver for these Realtek cards can be found for Linux on the realtek site. (untested but believed to also solve the problem).<br />
<br />
==== Method 4 - Enable ''LAN Boot ROM'' in BIOS/CMOS ====<br />
<br />
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.<br />
<br />
{{Note|This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.}}<br />
<br />
=== DLink G604T/DLink G502T DNS problem ===<br />
<br />
Users with a DLink G604T/DLink G502T router, using DHCP and have firmware v2.00+ (typically users with AUS firmware) may have problems with certain programs not resolving the DNS. One of these programs are unfortunatley pacman. The problem is basically the router in certain situations is not sending the DNS properly to DHCP, which causes programs to try and connect to servers with an IP address of 1.0.0.0 and fail with a connection timed out error<br />
<br />
==== How to diagnose the problem ====<br />
<br />
The best way to diagnose the problem is to use Firefox/Konqueror/links/seamonkey and to enable wget for pacman. If this is a fresh install of Arch Linux, then you may want to consider installing {{ic|links}} through the live CD.<br />
<br />
Firstly, enable wget for pacman (since it gives us info about pacman when it is downloading packages)<br />
Open {{ic|/etc/pacman.conf}} with your favourite editor and uncomment the following line (remove the # if it is there)<br />
<br />
XferCommand=/usr/bin/wget --passive-ftp -c -O %o %u<br />
<br />
While you are editing {{ic|/etc/pacman.conf}}, check the default mirror that pacman uses to download packages.<br />
<br />
Now open up the default mirror in an Internet browser to see if the mirror actually works. If it does work, then do {{ic|pacman -Syy}} (otherwise pick another working mirror and set it to the pacman default). If you get something similar to the following (notice the 1.0.0.0),<br />
<br />
<nowiki>ftp://mirror.pacific.net.au/linux/archlinux/extra/os/i686/extra.db.tar.gz</nowiki><br />
=> '/var/lib/pacman/community.db.tar.gz.part'<br />
Resolving mirror.pacific.net.au... 1.0.0.0<br />
<br />
then you most likely have this problem. The 1.0.0.0 means it is unable to resolve DNS, so we must add it to {{ic|/etc/resolv.conf}}.<br />
<br />
==== How to fix it ====<br />
<br />
{{Out of date|{{Pkg|dhcpcd}} does not use {{ic|/etc/conf.d/dhcpcd}} any more.}}<br />
<br />
Basically what we need to do is to manually add the DNS servers to our {{ic|/etc/resolv.conf}} file. The problem is that DHCP automatically deletes and replaces this file on boot, so we need to edit {{ic|/etc/conf.d/dhcpcd}} and change the flags to stop DHCP from doing this.<br />
<br />
When you open {{ic|/etc/conf.d/dhcpcd}}, you should see something close to the following:<br />
<br />
DHCPCD_ARGS="-t 30 -h $HOSTNAME"<br />
<br />
Add the {{ic|-R}} flag to the arguments, e.g.,<br />
<br />
DHCPCD_ARGS="-R -t 30 -h $HOSTNAME"<br />
<br />
{{Note|1=If you are using {{Pkg|dhcpcd}} >= 4.0.2, the {{ic|-R}} flag has been deprecated. Please see the [[#Run DHCP at boot]] section for information on how to use a custom {{ic|/etc/resolv.conf}} file.}}<br />
<br />
Save and close the file; now open {{ic|/etc/resolv.conf}}. You should see a single nameserver (most likely 10.1.1.1). This is the gateway to your router, which we need to connect to in order to get the DNS servers of your ISP. Paste the IP address into your browser and log in to your router. Go to the DNS section, and you should see an IP address in the Primary DNS Server field; copy it and paste it as a nameserver '''ABOVE''' the current gateway one.<br />
<br />
For example, {{ic|/etc/resolv.conf}} should look something along the lines of:<br />
<br />
nameserver 10.1.1.1<br />
<br />
If my primary DNS server is 211.29.132.12, then change {{ic|/etc/resolv.conf}} to:<br />
<br />
nameserver 211.29.132.12<br />
nameserver 10.1.1.1<br />
<br />
Now restart the network daemon by running {{ic|systemctl restart dhcpcd@<interface>}} and do {{ic|pacman -Syy}}. If it syncs correctly with the server, then the problem is solved.<br />
<br />
==== More about it ====<br />
<br />
This is the whirlpool forum (Australian ISP community) which talks about and gives the same solution to the problem:<br />
<br />
http://forums.whirlpool.net.au/forum-replies-archive.cfm/461625.html<br />
<br />
=== Check DHCP problem by releasing IP first ===<br />
<br />
Problem may occur when DHCP get wrong IP assignment. For example when two routers are tied together through VPN. The router that is connected to me by VPN may assigning IP address. To fix it. On a console, as root, release IP address:<br />
<br />
# dhcpcd -k<br />
<br />
Then request a new one:<br />
<br />
# dhcpcd<br />
<br />
Maybe you had to run those two commands many times.<br />
<br />
=== No eth0 with Atheros AR8161 ===<br />
<br />
{{Note|With the 3.10.2-1-ARCH kernel update, the alx ethernet driver module is included in the package.}}<br />
<br />
With the Atheros AR8161 Gigabit Ethernet card, the ethernet connection is not working out-of-the-box (with the installation media of March 2013). The module "alx" needs to be loaded but is not present.<br />
<br />
The driver from [http://linuxwireless.org/en/users/Download/stable/#compat-wireless_stable_releases compat-wireless] (that has become [https://backports.wiki.kernel.org/index.php/Releases compat-drives] since linux 3.7) need to be installed. The "-u" postfix annotates that Qualcomm have applied a driver under a unified driver.<br />
<br />
$ wget https://www.kernel.org/pub/linux/kernel/projects/backports/2013/03/28/compat-drivers-2013-03-28-5-u.tar.bz2<br />
$ tar xjf compat*<br />
$ cd compat*<br />
$ ./scripts/driver-select alx<br />
$ make<br />
$ sudo make install<br />
$ sudo modprobe alx<br />
<br />
The alx driver has not been added to Linux kernel due to various problems. Compatibility between the different kernel versions has been spotty. For better support follow the [http://lists.infradead.org/mailman/listinfo/unified-drivers mailing list]and [http://www.linuxfoundation.org/collaborate/workgroups/networking/alx alx page]for latest working solution for alx.<br />
<br />
The driver must be built and installed after every kernel change.<br />
<br />
Alternatively you can use the AUR package for [https://aur.archlinux.org/packages/compat-drivers-patched/ compat drivers], which installs many other drivers.<br />
<br />
=== No eth0 with Atheros AR9485 ===<br />
<br />
The ethernet (eth0) for Atheros AR9485 are not working out-of-the-box (with installation media of March 2013). The working solution for this is to install the package [https://aur.archlinux.org/packages/compat-drivers-patched/ compat-drivers-patched] from AUR.<br />
<br />
=== No carrier / no connection after suspend ===<br />
After suspend to RAM no connection is found although the network cable is plugged in. <br />
This may be caused by PCI power management. What is the output of<br />
<br />
# ip link show eth0<br />
<br />
If the line contains "NO-CARRIER" even though there's a cable connected to your eth0 port, it is possible that the device was auto-suspended and the media sense feature doesn't work. To solve this, first you need to find your ethernet controllers PCI address by<br />
<br />
# lspci<br />
<br />
This should look similar to this:<br />
<br />
...<br />
00:19.0 Ethernet controller: Intel Corporation 82577LM Gigabit Network Connection (rev 06)<br />
...<br />
<br />
So the address is 00:19.0.<br />
Now check the PM status of the device by issuing<br />
<br />
# cat "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
substituting 00:19.0 with the address obtained from lspci.<br />
If the output reads "auto", you can try to bring the device out of suspend by<br />
<br />
# echo on > "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
Don't forget to substitute the address again.<br />
<br />
{{Note|1=This appears to be a bug in kernel 3.8.4.1- (3.8.8.1 is still affected): [https://bbs.archlinux.org/viewtopic.php?id=159837&p=2 Forum discussion.] It also appears a fix is [https://lkml.org/lkml/2013/1/18/147 on the way. (It will be likely fixed in 3.9.)] In the meantime, the above is a suitable workaround.}}<br />
<br />
=== Broadcom BCM57780 ===<br />
<br />
This Broadcom chipset sometimes does not behave well unless you specify the order of the modules to be loaded. The modules are {{ic|broadcom}} and {{ic|tg3}}, the former needing to be loaded first.<br />
<br />
These steps should help if your computer has this chipset:<br />
$ lspci | grep Ethernet<br />
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)<br />
<br />
If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following (as root):<br />
# modprobe -r tg3<br />
# modprobe broadcom<br />
# modprobe tg3<br />
<br />
Now plug you network cable in. If this solves your problems you can make this permanent by adding {{ic|broadcom}} and {{ic|tg3}} (in this order) to the {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}}:<br />
<br />
MODULES=".. broadcom tg3 .."<br />
<br />
Then rebuild the initramfs:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|These methods may work for other chipsets, such as BCM57760.}}</div>Binotahttps://wiki.archlinux.org/index.php?title=Network_configuration_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=293526Network configuration (正體中文)2014-01-19T08:16:28Z<p>Binota: Translating on zh_TW</p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:Networking (正體中文)]]<br />
[[Category:Getting and installing Arch (正體中文)]]<br />
<br />
[[cs:Configuring Network]]<br />
[[el:Configuring Network]]<br />
[[es:Configuring Network]]<br />
[[fr:Connexions reseau]]<br />
[[it:Configuring Network]]<br />
[[ja:Network Configuration]]<br />
[[nl:Configuring Network]]<br />
[[pt:Configuring Network]]<br />
[[ro:Configurare retea]]<br />
[[ru:Configuring Network]]<br />
[[sk:Configuring Network]]<br />
[[tr:Ağ_Yapılandırması]]<br />
[[zh-CN:Network Configuration]]<br />
[[zh-TW:Network Configuration]]<br />
{{Related articles start}}<br />
{{Related|Jumbo Frames}}<br />
{{Related|Firewalls}}<br />
{{Related|Wireless Setup}}<br />
{{Related|List of Applications#Network Managers}}<br />
{{Related articles end}}<br />
<br />
本頁將介紹如何設定'''有線'''網路連線。若您需要設定'''無線'''網路,請參考[[Wireless Setup|無線網路設定]]。<br />
<br />
== 檢查連線 ==<br />
<br />
{{注意|若您在執行 ping 時收到了類似 {{ic|ping: icmp open socket: Operation not permitted}} 這樣的錯誤訊息,請嘗試重新安裝 {{ic|iputils}} 軟體包。}} <br />
<br />
一般來說,基本的安裝過程都已經建立了可運作的網路設定。請執行下列指令以進行檢查:<br />
<br />
{{注意|{{ic|-c 3}} 選項表示將會呼叫三次。詳細請參閱 {{ic|man ping}} 。}}<br />
{{注意|您也可以嘗試使用其他的 Domain ,如 www.hinet.net 。}}<br />
<br />
{{hc|$ ping -c 3 www.google.com|<nowiki><br />
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.<br />
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms<br />
64 bytes from 74.125.224.146: icmp_req=2 ttl=50 time=385 ms<br />
64 bytes from 74.125.224.146: icmp_req=3 ttl=50 time=298 ms<br />
<br />
--- www.l.google.com ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 1999ms<br />
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms<br />
</nowiki>}}<br />
<br />
如果沒問題的話,您可能只是想以本文的下列部分來自定您的設定。<br />
<br />
若剛才的指令出現了 unknown hosts 之類的訊息,代表您的機器無法解析網域。這可能是因為您的網路服務提供商/網關造成的。您可以嘗試 ping 一個靜態 IP 以實驗您的機器可否存取網際網路。<br />
{{注意|您也可以嘗試使用其他的 IP ,如 168.95.1.1 。}}<br />
<br />
{{hc|$ ping -c 3 8.8.8.8|<nowiki><br />
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.<br />
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms<br />
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms<br />
64 bytes from 8.8.8.8: icmp_req=3 ttl=53 time=70.6 ms<br />
<br />
--- 8.8.8.8 ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 2002ms<br />
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms<br />
</nowiki>}}<br />
<br />
{{注意|{{ic|8.8.8.8}} 為一個好記的靜態 IP 位置。這是 Google 的主要 DNS 伺服器,這表示其有一定的可信度,並且通常不會被系統或代理伺服器擋下。}}<br />
<br />
若您可以 ping 通該位置,您可能需要試著在 {{ic|/etc/resolv.conf}} 檔案中加上網域名稱伺服器。<br />
<br />
== 設定主機名稱 ==<br />
<br />
[[Wikipedia:Hostname|主機名稱]]為網路中用於識別機器的唯一識別名稱:主機名稱可以通過 {{ic|/etc/hostname}} 檔案來進行設定。一般來說該檔案包含了系統的網域名稱。下面為設定主機名稱的方法:<br />
<br />
# hostnamectl set-hostname '''myhostname'''<br />
<br />
這樣會將 '''myhostname''' 寫入 {{ic|/etc/hostname}} 檔案中。<br />
<br />
詳細請參閱 {{ic|man 5 hostname}} 與 {{ic|man 1 hostnamectl}} 。<br />
<br />
{{注意|<br />
* {{ic|hostnamectl}} 支援 FQDN<br />
* 您不需要編輯 {{ic|/etc/hosts}} 檔案,{{pkg|systemd}} 會提供主機名稱解析且預設安裝於所有系統。<br />
}}<br />
<br />
使用來自 {{Pkg|inetutils}} 的 {{ic|hostname}} 指令以設定臨時主機名稱(直到重新啟動):<br />
<br />
# hostname ''myhostname''<br />
<br />
== 裝置驅動程式 ==<br />
<br />
=== 檢查驅動程式狀態 ===<br />
<br />
[[udev]] 應該會檢測您的網路介面卡([[Wikipedia:Network_interface_controller|NIC]])並自動於啟動時載入必要的模組。檢查 {{ic|lspci -v}} 輸出內容中的「Ethernet controller」 項目(或類似的)。這應該會告訴您哪些核心模組包含了網路設備的驅動程式。舉例來說:<br />
<br />
{{hc|$ lspci -v|<br />
02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)<br />
...<br />
Kernel driver in use: atl1<br />
Kernel modules: atl1<br />
}}<br />
<br />
接下來,確認該驅動程式已經通過 {{ic|dmesg <nowiki>|</nowiki> grep ''module_name''}} 載入了。舉例來說:<br />
<br />
$ dmesg | grep atl1<br />
...<br />
atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex<br />
<br />
若驅動程式已成功加載可以跳過接下來這段。否則,您會需要知道哪些模組時您的特定型號的裝置需要哪個模組。<br />
<br />
=== 載入裝置模組 ===<br />
<br />
以 Google 搜尋正確的晶片組模組/驅動程式。常見的驅動模組有 Realtek 晶片組網卡的 {{ic|8139too}} ,或是 SiS 晶片組網卡的 {{ic|sis900}}。當您知道要使用何種模組了之後,試著[[Kernel modules#Manual module handling|手動將其載入]]。若您的到了錯誤訊息告訴您找不到該模組,則該驅動可能未包含於 Arch 核心中。您可以在 [[AUR]] 中搜尋該模組名稱。<br />
<br />
若 udev 未在開機期間檢測與載入正確的模組,請參閱 [[Kernel modules#Loading]]。<br />
<br />
== 網路介面 ==<br />
<br />
=== 裝置名稱 ===<br />
<br />
對於多網路卡的電腦,固定裝置名稱非常重要。許多設定問題都是因為介面卡名稱的改動造成的。<br />
<br />
[[udev]] 負責命名裝置。Systemd v197 則有[http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames 可預測之網路介面名稱]並可自動支配靜態名稱給網路裝置。介面名稱以 {{ic|en}} (乙太網路)、 {{ic|wl}} (無線網路) 或是 {{ic|ww}} (WWAN)作為前置字串並附上一個自動產生的識別名稱,進而產生了類似 {{ic|enp0s25}} 這樣的名稱。 <br />
<br />
要禁用這種行為,可以加上一個連接:<br />
<br />
# ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules<br />
<br />
自早期版本升級 systemd 的使用者會有一自動建立的空規則檔案。因此,若您想使用一貫的裝置名稱,只需要刪除該檔案。<br />
<br />
{{提示|您可以執行 {{ic|ip link}} 或是 {{ic|ls /sys/class/net}} 以列出所有可用的介面。}}<br />
<br />
{{注意|當您更改了介面名稱規則後,別忘了更新所有跟網路有關的組態檔案與自定的 systemd unit 檔案以因應該更改。特別是當您啟用了 [[netctl#Basic method|netctl 靜態設定檔]] ,請執行 {{ic|netctl reenable ''profile''}} 以更新所有產生的服務檔案。}}<br />
<br />
==== 更改裝置名稱 ====<br />
<br />
您可以使用 udev-rule 來手動定義裝置名稱。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"<br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"<br />
</nowiki>}}<br />
<br />
請注意這兩點:<br />
<br />
* 使用這個指令以取得 MAC 位置:{{ic|cat /sys/class/net/''device_name''/address}}。<br />
* 請確定 udev 規則中使用的是小寫的十六進位數值而不是大寫。<br />
<br />
若您的網路卡為動態 MAC ,您可以使用 DEVPATH ,例如:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"<br />
</nowiki>}}<br />
<br />
{{注意|當使用了靜態的名稱時,'''應該要避免使用類似 "eth''X''" 與 "wlan''X''"''' 這樣的名稱,因為這可能會導致核心與 udev 在開機時發生衝突。而剛好相反地,最好使用核心預設不會使用的介面名稱,如 {{ic|net0}} 、 {{ic|net1}} 、 {{ic|wifi0}} 、 {{ic|wifi1}} 。詳細說明請參閱 [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames systemd] 文件。}}<br />
<br />
=== 設定裝置的 MTU 與佇列長度 ===<br />
<br />
您可以手動定義 udev 規則來更改裝置的 MTU 與佇列長度。舉例來說:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1480", ATTR{tx_queue_len}="2000"<br />
</nowiki>}}<br />
<br />
=== 取得目前的裝置名稱 ===<br />
<br />
Current NIC names can be found via sysfs<br />
<br />
{{hc|$ ls /sys/class/net|<br />
lo eth0 eth1 firewire0<br />
}}<br />
<br />
=== 啟用與禁用網路介面 ===<br />
<br />
You can activate or deactivate network interfaces using:<br />
<br />
# ip link set eth0 up<br />
# ip link set eth0 down<br />
<br />
To check the result:<br />
<br />
{{hc|$ ip link show dev eth0|<br />
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000<br />
...<br />
}}<br />
<br />
== 組態設定 IP 位址 ==<br />
<br />
You have two options: a dynamically assigned address using [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]], or an unchanging "static" address.<br />
<br />
=== 動態 IP 位址 ===<br />
<br />
==== 手動執行 DHCP 用戶端 Daemon ====<br />
<br />
{{Note|{{ic|dhcpcd}} (DHCP ''client'' daemon) is not the same as {{ic|dhcpd}} (DHCP ''(server)'' daemon).}}<br />
<br />
{{hc|# dhcpcd eth0|<br />
dhcpcd: version 5.1.1 starting<br />
dhcpcd: eth0: broadcasting for a lease<br />
...<br />
dhcpcd: eth0: leased 192.168.1.70 for 86400 seconds<br />
}}<br />
<br />
And now, {{ic|ip addr show dev eth0}} should show your inet address.<br />
<br />
For some people, {{ic|dhclient}} (from the {{Pkg|dhclient}} package) works where {{ic|dhcpcd}} fails.<br />
<br />
==== 於啟動時執行 DHCP ====<br />
<br />
If you simply want to use DHCP for your Ethernet connection, you can use {{ic|dhcpcd@.service}} (provided by the {{Pkg|dhcpcd}} package).<br />
<br />
To start DHCP for {{ic|eth0}}, simply use:<br />
<br />
# systemctl start dhcpcd@eth0.service<br />
<br />
You can enable the service to automatically start at boot with:<br />
<br />
# systemctl enable dhcpcd@eth0.service<br />
<br />
If you use DHCP and you do '''not''' want your DNS servers automatically assigned every time you start your network, be sure to add the following to the last section of {{ic|dhcpcd.conf}}:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nohook resolv.conf<br />
}}<br />
<br />
Also, if you are on a network with DHCPv4 that filters Client IDs based on MAC addresses, you may need to change the following line:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 Client ID as per RFC4361. <br />
duid<br />
}}<br />
<br />
To:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the hardware address of the interface for the Client ID (DHCPv4).<br />
clientid<br />
}}<br />
<br />
Else, you may not obtain a lease since the DHCP server may not read your [http://en.wikipedia.org/wiki/DHCPv6 DHCPv6-style] Client ID correctly. See [http://tools.ietf.org/html/rfc4361 RFC 4361] for more information.<br />
<br />
To prevent {{ic|dhcpcd}} from adding domain name servers to {{ic|/etc/resolv.conf}}, use the {{ic|nooption}} option:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nooption domain_name_servers<br />
}}<br />
<br />
Then add your own DNS name server to {{ic|/etc/resolv.conf}}.<br />
<br />
You may use the {{Pkg|openresolv}} package if several different processes want to control {{ic|/etc/resolv.conf}} (e.g. {{Pkg|dhcpcd}} and a VPN client). No additional configuration for {{Pkg|dhcpcd}} is needed to use {{Pkg|openresolv}}.<br />
<br />
==== DHCP 靜態路由 ====<br />
If you need to add a static route client-side, create a new dhcpcd hook-script in {{ic|/usr/lib/dhcpcd/dhcpcd-hooks}}. The example shows a new hook-script which adds a static route to a VPN subnet on 10.11.12.0/24 via a gateway machine at 192.168.192.5:<br />
{{hc|/usr/lib/dhcpcd/dhcpcd-hooks/40-vpnroute|<br />
ip route add 10.11.12.0/24 via 192.168.192.5<br />
}}<br />
The ''40'' prefix means that it is the final hook-script to run when dhcpcd starts.<br />
<br />
=== 靜態 IP 位址 ===<br />
<br />
There are various reasons why you may wish to assign static IP addresses on your network. For instance, one may gain a certain degree of predictability with unchanging addresses, or you may not have a DHCP server available.<br />
<br />
{{Note|If you share your Internet connection from a Windows machine without a router, be sure to use static IP addresses on both computers to avoid LAN problems.}}<br />
<br />
You need:<br />
<br />
* Static IP address<br />
* [[Wikipedia:Subnetwork|Subnet mask]]<br />
* [[Wikipedia:Broadcast_address|Broadcast address]]<br />
* [[Wikipedia:Default_gateway|Gateway]]'s IP address<br />
<br />
If you are running a private network, it is safe to use IP addresses in 192.168.*.* for your IP addresses, with a subnet mask of 255.255.255.0 and a broadcast address of 192.168.*.255. The gateway is usually 192.168.*.1 or 192.168.*.254.<br />
<br />
==== 手動指派 ====<br />
<br />
You can assign a static IP address in the console:<br />
<br />
# ip addr add <IP address>/<subnet mask> broadcast <broadcast> dev <interface><br />
<br />
For example:<br />
<br />
# ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev eth0<br />
<br />
{{Note|The subnet mask was specified using [[Wikipedia:CIDR_notation|CIDR notation]].}}<br />
<br />
For more options, see {{ic|man ip}}.<br />
<br />
Add your gateway like so:<br />
<br />
# ip route add default via <default gateway IP address><br />
<br />
For example:<br />
<br />
# ip route add default via 192.168.1.1<br />
<br />
If you the get the error "No such process", it means you have to run {{ic|ip link set dev eth0 up}} as root.<br />
<br />
==== 於啟動時通過 systemd 手動連線 ====<br />
<br />
Ensure that dhcpcd is stopped and disabled:<br />
<br />
# systemctl status dhcpcd.service<br />
<br />
Create a configuration file for the [[systemd]] service. Replace {{ic|<interface>}} with the proper network interface name:<br />
<br />
{{hc|/etc/conf.d/network@<interface>|<nowiki><br />
address=192.168.0.15<br />
netmask=24<br />
broadcast=192.168.0.255<br />
gateway=192.168.0.1<br />
</nowiki>}}<br />
<br />
Create a systemd unit file:<br />
<br />
{{hc|/etc/systemd/system/network@.service|<nowiki><br />
[Unit]<br />
Description=Network connectivity (%i)<br />
Wants=network.target<br />
Before=network.target<br />
BindsTo=sys-subsystem-net-devices-%i.device<br />
After=sys-subsystem-net-devices-%i.device<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
EnvironmentFile=/etc/conf.d/network@%i<br />
<br />
ExecStart=/usr/bin/ip link set dev %i up<br />
ExecStart=/usr/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i<br />
ExecStart=/usr/bin/ip route add default via ${gateway}<br />
<br />
ExecStop=/usr/bin/ip addr flush dev %i<br />
ExecStop=/usr/bin/ip link set dev %i down<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
Enable the unit and start it, passing the name of the interface, in this case eno1:<br />
<br />
# systemctl enable network@eno1.service<br />
# systemctl start network@eno1.service<br />
<br />
If you need to manually set the nameservers, edit {{ic|/etc/resolv.conf}}:<br />
<br />
{{hc|/etc/resolv.conf|<br />
nameserver 208.67.222.222<br />
nameserver 208.67.220.220}}<br />
<br />
If {{ic|/etc/resolv.conf}} keeps getting overwritten see [[Resolv.conf]] for more details on how to address this issue.<br />
<br />
There are several different ways to utilise systemd to start the network using similar, but different, file contents, and it is also possible to hard code the parameters that can then be picked up from the file referenced in the EnvironmentFile definition. It is therefore possible, as an alternative, to put the interface name into the EnvironmentFile in /etc/conf.d/ and then use the interface name directly instead of %i. In that case the name of the file does not need the "@". It is also useful to read the documentation on systemd service files at http://www.freedesktop.org/software/systemd/man/systemd.unit.html<br />
<br />
==== 計算位址 ====<br />
<br />
You can use {{ic|ipcalc}} provided by the {{Pkg|ipcalc}} package to calculate IP broadcast, network, netmask, and host ranges for more advanced configurations. For example, I use ethernet over firewire to connect a windows machine to arch. For security and network organization, I placed them on their own network and configured the netmask and broadcast so that they are the only 2 machines on it. To figure out the netmask and broadcast addresses for this, I used ipcalc, providing it with the IP of the arch firewire nic 10.66.66.1, and specifying ipcalc should create a network of only 2 hosts.<br />
<br />
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|<nowiki><br />
Address: 10.66.66.1<br />
<br />
Netmask: 255.255.255.252 = 30<br />
Network: 10.66.66.0/30<br />
HostMin: 10.66.66.1<br />
HostMax: 10.66.66.2<br />
Broadcast: 10.66.66.3<br />
Hosts/Net: 2 Class A, Private Internet<br />
</nowiki>}}<br />
<br />
== 載入組態設定 ==<br />
<br />
To test your settings either reboot the computer or reload the relevant systemd services:<br />
<br />
# systemctl restart dhcpcd@eth0<br />
<br />
Try pinging your gateway, DNS server, ISP provider and other Internet sites, in that order, to detect any connection problems along the way, as in this example:<br />
<br />
$ ping -c 3 www.google.com<br />
<br />
== 附加設定 ==<br />
<br />
=== 筆記型電腦之 ifplugd ===<br />
<br />
{{Tip|{{Pkg|dhcpcd}} provides the same feature out of the box.}}<br />
<br />
{{Pkg|ifplugd}} in [[Official Repositories]] is a daemon which will automatically configure your Ethernet device when a cable is plugged in and automatically unconfigure it if the cable is pulled. This is useful on laptops with onboard network adapters, since it will only configure the interface when a cable is really connected. Another use is when you just need to restart the network but do not want to restart the computer or do it from the shell.<br />
<br />
By default it is configured to work for the {{ic|eth0}} device. This and other settings like delays can be configured in {{ic|/etc/ifplugd/ifplugd.conf}}.<br />
<br />
{{Note|[[Netctl]] package includes {{ic|netctl-ifplugd@.service}}, otherwise you can use {{ic|ifplugd@.service}} from {{Pkg|ifplugd}} package. Use for example {{ic|systemctl enable ifplugd@eth0.service}}.}}<br />
<br />
=== Bonding 或 LAG ===<br />
<br />
See [[netctl#Bonding]].<br />
<br />
=== IP 別名 ===<br />
<br />
{{Expansion|Manual method using [[Core Utilities#ip|ip]] should be added; then move current example using ''netctl'' into [[netctl]].}}<br />
<br />
IP aliasing is the process of adding more than one IP address to a network interface. With this, one node on a network can have multiple connections to a network, each serving a different purpose. Typical uses are virtual hosting of Web and FTP servers, or reorganizing servers without having to update any other machines (this is especially useful for nameservers).<br />
<br />
==== 範例 ====<br />
<br />
You will need {{Pkg|netctl}} from the [[Official Repositories]].<br />
<br />
Prepare the configuration:<br />
<br />
{{hc|/etc/netctl/mynetwork|<nowiki><br />
Connection='ethernet'<br />
Description='Five different addresses on the same NIC.'<br />
Interface='eth0'<br />
IP='static'<br />
Address=('192.168.1.10' '192.168.178.11' '192.168.1.12' '192.168.1.13' '192.168.1.14' '192.168.1.15')<br />
Gateway='192.168.1.1'<br />
DNS=('192.168.1.1')<br />
</nowiki>}}<br />
<br />
Then simply execute: <br />
<br />
$ netctl start mynetwork<br />
<br />
=== 更改 MAC/硬體 位址 ===<br />
<br />
請參閱 [[MAC Address Spoofing]] 。<br />
<br />
=== Internet Sharing ===<br />
<br />
請參閱 [[Internet Sharing]] 。<br />
<br />
=== Router Configuration ===<br />
<br />
請參閱 [[Router]] 。<br />
<br />
=== 區域網路主機名稱解析 ===<br />
<br />
The pre-requisite is to [[#Set the hostname]] after which hostname resolution works on the local system itself {{hc|$ ping hostname|<br />
PING hostname <nowiki>(192.168.1.2) 56(84) bytes of data.<br />
64 bytes from hostname (192.168.1.2): icmp_seq=1 ttl=64 time=0.043 ms</nowiki>}}<br />
To enable other machines to address the host by name, either a manual configuration of the respective {{ic|/etc/hosts}} files or a service to propagate/resolve the name is required. <br />
<br />
When setting up a DNS server such as [[BIND]] or [[Unbound]] is overkill, manually editing your {{ic|/etc/hosts}} is too cumbersome, or when you want more flexibility with dynamic leaving and joining of hosts to the network, it is possible to handle hostname resolution on your local network using zero-configuration networking. There are two options available:<br />
<br />
*[[Samba]] provides hostname resolution via Microsoft's '''NetBIOS'''. It only requires installation of {{Pkg|samba}} and enabling of the {{ic|nmbd.service}} service. Computers running Windows, OS X, or Linux with {{ic|nmbd}} running, will be able to find your machine.<br />
<br />
*[[Avahi]] provides hostname resolution via '''zeroconf''', also known as Avahi or Bonjour. It requires slightly more complex configuration than Samba: see [[Avahi#Hostname resolution]] for details. Computers running OS X, or Linux with an Avahi daemon running, will be able to find your machine. Windows does not have an built-in Avahi client or daemon.<br />
<br />
== 診斷 ==<br />
<br />
=== Swapping computers on the cable modem ===<br />
<br />
Some cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.<br />
<br />
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].<br />
<br />
=== The TCP window scaling problem ===<br />
<br />
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.<br />
<br />
Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html RFC 1323] was written to improve the situation: Window Scaling. The "window" value, provided in all packets, will be modified by a Scale Factor defined once, at the very beginning of the connection.<br />
<br />
That 8-bit Scale Factor allows the Window to be up to 32 times higher than the initial 64Kb.<br />
<br />
It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts.<br />
<br />
The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.<br />
<br />
The resulting connection is at best very slow or broken.<br />
<br />
==== How to diagnose the problem ====<br />
<br />
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).<br />
<br />
When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|ip addr}} will report normal status... and actually everything appears normal.<br />
<br />
If you cannot browse any website, but you can ping some random hosts, chances are great that you're experiencing this problem: ping uses ICMP and is not affected by TCP problems.<br />
<br />
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).<br />
<br />
==== How to fix it (The bad way) ====<br />
<br />
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.<br />
<br />
# echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem<br />
<br />
==== How to fix it (The good way) ====<br />
<br />
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.d/99-disable_window_scaling.conf}} (see also [[sysctl]])<br />
<br />
net.ipv4.tcp_window_scaling = 0<br />
<br />
==== How to fix it (The best way) ====<br />
<br />
This problem is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.<br />
<br />
==== More about it ====<br />
<br />
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].<br />
<br />
There are also several relevant threads on the LKML.<br />
<br />
=== Realtek no link / WOL problem ===<br />
<br />
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice a problem where the NIC seems to be disabled on boot and has no Link light. This can usually be found on a dual boot system where Windows is also installed. It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause. These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots. You will be able to notice if this problem is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off. Normal operation should be that the link light is always on as long as the system is on, even during POST. This problem will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this problem:<br />
<br />
==== Method 1 - Rollback/change Windows driver ====<br />
<br />
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).<br />
<br />
==== Method 2 - Enable WOL in Windows driver ====<br />
<br />
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems). In Windows, under Device Manager, find your Realtek network adapter and double-click it. Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.<br />
<br />
In Windows XP (example)<br />
Right click my computer<br />
--> Hardware tab<br />
--> Device Manager<br />
--> Network Adapters<br />
--> "double click" Realtek ...<br />
--> Advanced tab<br />
--> Wake-On-Lan After Shutdown<br />
--> Enable<br />
<br />
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{ic|Disable}} has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.}}<br />
<br />
==== Method 3 - Newer Realtek Linux driver ====<br />
<br />
Any newer driver for these Realtek cards can be found for Linux on the realtek site. (untested but believed to also solve the problem).<br />
<br />
==== Method 4 - Enable ''LAN Boot ROM'' in BIOS/CMOS ====<br />
<br />
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.<br />
<br />
{{Note|This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.}}<br />
<br />
=== DLink G604T/DLink G502T DNS problem ===<br />
<br />
Users with a DLink G604T/DLink G502T router, using DHCP and have firmware v2.00+ (typically users with AUS firmware) may have problems with certain programs not resolving the DNS. One of these programs are unfortunatley pacman. The problem is basically the router in certain situations is not sending the DNS properly to DHCP, which causes programs to try and connect to servers with an IP address of 1.0.0.0 and fail with a connection timed out error<br />
<br />
==== How to diagnose the problem ====<br />
<br />
The best way to diagnose the problem is to use Firefox/Konqueror/links/seamonkey and to enable wget for pacman. If this is a fresh install of Arch Linux, then you may want to consider installing {{ic|links}} through the live CD.<br />
<br />
Firstly, enable wget for pacman (since it gives us info about pacman when it is downloading packages)<br />
Open {{ic|/etc/pacman.conf}} with your favourite editor and uncomment the following line (remove the # if it is there)<br />
<br />
XferCommand=/usr/bin/wget --passive-ftp -c -O %o %u<br />
<br />
While you are editing {{ic|/etc/pacman.conf}}, check the default mirror that pacman uses to download packages.<br />
<br />
Now open up the default mirror in an Internet browser to see if the mirror actually works. If it does work, then do {{ic|pacman -Syy}} (otherwise pick another working mirror and set it to the pacman default). If you get something similar to the following (notice the 1.0.0.0),<br />
<br />
<nowiki>ftp://mirror.pacific.net.au/linux/archlinux/extra/os/i686/extra.db.tar.gz</nowiki><br />
=> '/var/lib/pacman/community.db.tar.gz.part'<br />
Resolving mirror.pacific.net.au... 1.0.0.0<br />
<br />
then you most likely have this problem. The 1.0.0.0 means it is unable to resolve DNS, so we must add it to {{ic|/etc/resolv.conf}}.<br />
<br />
==== How to fix it ====<br />
<br />
{{Out of date|{{Pkg|dhcpcd}} does not use {{ic|/etc/conf.d/dhcpcd}} any more.}}<br />
<br />
Basically what we need to do is to manually add the DNS servers to our {{ic|/etc/resolv.conf}} file. The problem is that DHCP automatically deletes and replaces this file on boot, so we need to edit {{ic|/etc/conf.d/dhcpcd}} and change the flags to stop DHCP from doing this.<br />
<br />
When you open {{ic|/etc/conf.d/dhcpcd}}, you should see something close to the following:<br />
<br />
DHCPCD_ARGS="-t 30 -h $HOSTNAME"<br />
<br />
Add the {{ic|-R}} flag to the arguments, e.g.,<br />
<br />
DHCPCD_ARGS="-R -t 30 -h $HOSTNAME"<br />
<br />
{{Note|1=If you are using {{Pkg|dhcpcd}} >= 4.0.2, the {{ic|-R}} flag has been deprecated. Please see the [[#Run DHCP at boot]] section for information on how to use a custom {{ic|/etc/resolv.conf}} file.}}<br />
<br />
Save and close the file; now open {{ic|/etc/resolv.conf}}. You should see a single nameserver (most likely 10.1.1.1). This is the gateway to your router, which we need to connect to in order to get the DNS servers of your ISP. Paste the IP address into your browser and log in to your router. Go to the DNS section, and you should see an IP address in the Primary DNS Server field; copy it and paste it as a nameserver '''ABOVE''' the current gateway one.<br />
<br />
For example, {{ic|/etc/resolv.conf}} should look something along the lines of:<br />
<br />
nameserver 10.1.1.1<br />
<br />
If my primary DNS server is 211.29.132.12, then change {{ic|/etc/resolv.conf}} to:<br />
<br />
nameserver 211.29.132.12<br />
nameserver 10.1.1.1<br />
<br />
Now restart the network daemon by running {{ic|systemctl restart dhcpcd@<interface>}} and do {{ic|pacman -Syy}}. If it syncs correctly with the server, then the problem is solved.<br />
<br />
==== More about it ====<br />
<br />
This is the whirlpool forum (Australian ISP community) which talks about and gives the same solution to the problem:<br />
<br />
http://forums.whirlpool.net.au/forum-replies-archive.cfm/461625.html<br />
<br />
=== Check DHCP problem by releasing IP first ===<br />
<br />
Problem may occur when DHCP get wrong IP assignment. For example when two routers are tied together through VPN. The router that is connected to me by VPN may assigning IP address. To fix it. On a console, as root, release IP address:<br />
<br />
# dhcpcd -k<br />
<br />
Then request a new one:<br />
<br />
# dhcpcd<br />
<br />
Maybe you had to run those two commands many times.<br />
<br />
=== No eth0 with Atheros AR8161 ===<br />
<br />
{{Note|With the 3.10.2-1-ARCH kernel update, the alx ethernet driver module is included in the package.}}<br />
<br />
With the Atheros AR8161 Gigabit Ethernet card, the ethernet connection is not working out-of-the-box (with the installation media of March 2013). The module "alx" needs to be loaded but is not present.<br />
<br />
The driver from [http://linuxwireless.org/en/users/Download/stable/#compat-wireless_stable_releases compat-wireless] (that has become [https://backports.wiki.kernel.org/index.php/Releases compat-drives] since linux 3.7) need to be installed. The "-u" postfix annotates that Qualcomm have applied a driver under a unified driver.<br />
<br />
$ wget https://www.kernel.org/pub/linux/kernel/projects/backports/2013/03/28/compat-drivers-2013-03-28-5-u.tar.bz2<br />
$ tar xjf compat*<br />
$ cd compat*<br />
$ ./scripts/driver-select alx<br />
$ make<br />
$ sudo make install<br />
$ sudo modprobe alx<br />
<br />
The alx driver has not been added to Linux kernel due to various problems. Compatibility between the different kernel versions has been spotty. For better support follow the [http://lists.infradead.org/mailman/listinfo/unified-drivers mailing list]and [http://www.linuxfoundation.org/collaborate/workgroups/networking/alx alx page]for latest working solution for alx.<br />
<br />
The driver must be built and installed after every kernel change.<br />
<br />
Alternatively you can use the AUR package for [https://aur.archlinux.org/packages/compat-drivers-patched/ compat drivers], which installs many other drivers.<br />
<br />
=== No eth0 with Atheros AR9485 ===<br />
<br />
The ethernet (eth0) for Atheros AR9485 are not working out-of-the-box (with installation media of March 2013). The working solution for this is to install the package [https://aur.archlinux.org/packages/compat-drivers-patched/ compat-drivers-patched] from AUR.<br />
<br />
=== No carrier / no connection after suspend ===<br />
After suspend to RAM no connection is found although the network cable is plugged in. <br />
This may be caused by PCI power management. What is the output of<br />
<br />
# ip link show eth0<br />
<br />
If the line contains "NO-CARRIER" even though there's a cable connected to your eth0 port, it is possible that the device was auto-suspended and the media sense feature doesn't work. To solve this, first you need to find your ethernet controllers PCI address by<br />
<br />
# lspci<br />
<br />
This should look similar to this:<br />
<br />
...<br />
00:19.0 Ethernet controller: Intel Corporation 82577LM Gigabit Network Connection (rev 06)<br />
...<br />
<br />
So the address is 00:19.0.<br />
Now check the PM status of the device by issuing<br />
<br />
# cat "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
substituting 00:19.0 with the address obtained from lspci.<br />
If the output reads "auto", you can try to bring the device out of suspend by<br />
<br />
# echo on > "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
Don't forget to substitute the address again.<br />
<br />
{{Note|1=This appears to be a bug in kernel 3.8.4.1- (3.8.8.1 is still affected): [https://bbs.archlinux.org/viewtopic.php?id=159837&p=2 Forum discussion.] It also appears a fix is [https://lkml.org/lkml/2013/1/18/147 on the way. (It will be likely fixed in 3.9.)] In the meantime, the above is a suitable workaround.}}<br />
<br />
=== Broadcom BCM57780 ===<br />
<br />
This Broadcom chipset sometimes does not behave well unless you specify the order of the modules to be loaded. The modules are {{ic|broadcom}} and {{ic|tg3}}, the former needing to be loaded first.<br />
<br />
These steps should help if your computer has this chipset:<br />
$ lspci | grep Ethernet<br />
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)<br />
<br />
If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following (as root):<br />
# modprobe -r tg3<br />
# modprobe broadcom<br />
# modprobe tg3<br />
<br />
Now plug you network cable in. If this solves your problems you can make this permanent by adding {{ic|broadcom}} and {{ic|tg3}} (in this order) to the {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}}:<br />
<br />
MODULES=".. broadcom tg3 .."<br />
<br />
Then rebuild the initramfs:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|These methods may work for other chipsets, such as BCM57760.}}</div>Binotahttps://wiki.archlinux.org/index.php?title=Network_configuration&diff=293523Network configuration2014-01-19T07:18:18Z<p>Binota: </p>
<hr />
<div>[[Category:Networking]]<br />
[[Category:Getting and installing Arch]]<br />
[[cs:Configuring Network]]<br />
[[el:Configuring Network]]<br />
[[es:Configuring Network]]<br />
[[fr:Connexions reseau]]<br />
[[it:Configuring Network]]<br />
[[ja:Network Configuration]]<br />
[[nl:Configuring Network]]<br />
[[pt:Configuring Network]]<br />
[[ro:Configurare retea]]<br />
[[ru:Configuring Network]]<br />
[[sk:Configuring Network]]<br />
[[tr:Ağ_Yapılandırması]]<br />
[[zh-CN:Network Configuration]]<br />
[[zh-TW:Network Configuration]]<br />
{{Related articles start}}<br />
{{Related|Jumbo Frames}}<br />
{{Related|Firewalls}}<br />
{{Related|Wireless Setup}}<br />
{{Related|List of Applications#Network Managers}}<br />
{{Related articles end}}<br />
<br />
This page explains how to set up a '''wired''' connection to a network. If you need to set up '''wireless''' networking see the [[Wireless Setup]] page.<br />
<br />
== Check the connection ==<br />
<br />
{{Note|If you receive an error like {{ic|ping: icmp open socket: Operation not permitted}} when executing ping, try to re-install the {{ic|iputils}} package.}} <br />
<br />
Many times, the basic installation procedure has created a working network configuration. To check if this is so, use the following command:<br />
<br />
{{Note|The {{ic|-c 3}} option calls it three times. See {{ic|man ping}} for more information.}}<br />
<br />
{{hc|$ ping -c 3 www.google.com|<nowiki><br />
PING www.l.google.com (74.125.224.146) 56(84) bytes of data.<br />
64 bytes from 74.125.224.146: icmp_req=1 ttl=50 time=437 ms<br />
64 bytes from 74.125.224.146: icmp_req=2 ttl=50 time=385 ms<br />
64 bytes from 74.125.224.146: icmp_req=3 ttl=50 time=298 ms<br />
<br />
--- www.l.google.com ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 1999ms<br />
rtt min/avg/max/mdev = 298.107/373.642/437.202/57.415 ms<br />
</nowiki>}}<br />
<br />
If it works, then you may only wish to personalize your settings from the options below.<br />
<br />
If the previous command complains about unknown hosts, it means that your machine was unable to resolve this domain name. It might be related to your service provider or your router/gateway. You can try pinging a static IP address to prove that your machine has access to the Internet.<br />
<br />
{{hc|$ ping -c 3 8.8.8.8|<nowiki><br />
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.<br />
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=52.9 ms<br />
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=72.5 ms<br />
64 bytes from 8.8.8.8: icmp_req=3 ttl=53 time=70.6 ms<br />
<br />
--- 8.8.8.8 ping statistics ---<br />
3 packets transmitted, 3 received, 0% packet loss, time 2002ms<br />
rtt min/avg/max/mdev = 52.975/65.375/72.543/8.803 ms<br />
</nowiki>}}<br />
<br />
{{Note|{{ic|8.8.8.8}} is a static address that is easy to remember. It is the address of Google's primary DNS server, therefore it can be considered reliable, and is generally not blocked by content filtering systems and proxies.}}<br />
<br />
If you are able to ping this address, you may try adding this nameserver to your {{ic|/etc/resolv.conf}} file.<br />
<br />
== Set the hostname ==<br />
<br />
A [[Wikipedia:Hostname|hostname]] is a unique name created to identify a machine on a network: it is configured in {{ic|/etc/hostname}}. The file can contain the system's domain name, if any. To set the hostname, do:<br />
<br />
# hostnamectl set-hostname '''myhostname'''<br />
<br />
This will put '''myhostname''' in {{ic|/etc/hostname}}.<br />
<br />
See {{ic|man 5 hostname}} and {{ic|man 1 hostnamectl}} for details.<br />
<br />
{{Note|<br />
* {{ic|hostnamectl}} supports FQDNs<br />
* You no longer need to edit {{ic|/etc/hosts}}, {{pkg|systemd}} will provide host name resolution, and is installed on all systems by default.<br />
}}<br />
<br />
To set the hostname temporarily (until a reboot), use the {{ic|hostname}} command from {{Pkg|inetutils}}:<br />
<br />
# hostname ''myhostname''<br />
<br />
== Device Driver ==<br />
<br />
=== Check the driver status ===<br />
<br />
[[udev]] should detect your network interface card ([[Wikipedia:Network_interface_controller|NIC]]) and automatically load the necessary module at start up. Check the "Ethernet controller" entry (or similar) from the {{ic|lspci -v}} output. It should tell you which kernel module contains the driver for your network device. For example:<br />
<br />
{{hc|$ lspci -v|<br />
02:00.0 Ethernet controller: Attansic Technology Corp. L1 Gigabit Ethernet Adapter (rev b0)<br />
...<br />
Kernel driver in use: atl1<br />
Kernel modules: atl1<br />
}}<br />
<br />
Next, check that the driver was loaded via {{ic|dmesg <nowiki>|</nowiki> grep ''module_name''}}. For example:<br />
<br />
$ dmesg | grep atl1<br />
...<br />
atl1 0000:02:00.0: eth0 link is up 100 Mbps full duplex<br />
<br />
Skip the next section if the driver was loaded successfully. Otherwise, you will need to know which module is needed for your particular model.<br />
<br />
=== Load the device module ===<br />
<br />
Google for the right module/driver for the chipset. Some common modules are {{ic|8139too}} for cards with a Realtek chipset, or {{ic|sis900}} for cards with a SiS chipset. Once you know which module to use, try to [[Kernel modules#Manual module handling|load it manually]]. If you get an error saying that the module was not found, it's possible that the driver is not included in Arch kernel. You may search the [[AUR]] for the module name.<br />
<br />
If udev is not detecting and loading the proper module automatically during bootup, see [[Kernel modules#Loading]].<br />
<br />
== Network Interfaces ==<br />
<br />
=== Device names ===<br />
<br />
For computers with multiple NICs, it is important to have fixed device name. Many configuration problems are caused by interface name changing.<br />
<br />
[[udev]] is responsible for which device gets which name. Systemd v197 introduced [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames Predictable Network Interface Names], which automatically assigns static names to network devices. Interfaces are now prefixed with {{ic|en}} (ethernet), {{ic|wl}} (WLAN), or {{ic|ww}} (WWAN) followed by an automatically generated identifier, creating an entry such as {{ic|enp0s25}}. <br />
<br />
This behavior may be disabled by adding a symlink:<br />
<br />
# ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules<br />
<br />
Users upgrading from an earlier systemd version will have a blank rules file created automatically. So if you want to use persistent device names, just delete the file.<br />
<br />
{{Tip|You can run {{ic|ip link}} or {{ic|ls /sys/class/net}} to list all available interfaces.}}<br />
<br />
{{Note|When changing the interface naming scheme, do not forget to update all network-related configuration files and custom systemd unit files to reflect the change. Specifically, if you have [[netctl#Basic method|netctl static profiles]] enabled, run {{ic|netctl reenable ''profile''}} to update the generated service file.}}<br />
<br />
==== Change device name ====<br />
<br />
You can change the device name by defining the name manually with an udev-rule. For example:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="net1"<br />
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="net0"<br />
</nowiki>}}<br />
<br />
A couple things to note:<br />
<br />
* To get the MAC address of each card, use this command: {{ic|cat /sys/class/net/''device_name''/address}}<br />
* Make sure to use the lower-case hex values in your udev rules. It doesn't like upper-case.<br />
<br />
If you network card has dynamic MAC, you can use DEVPATH for example<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
SUBSYSTEM=="net", DEVPATH=="/devices/platform/wemac.*", NAME="int"<br />
</nowiki>}}<br />
<br />
{{Note|When choosing the static names '''it should be avoided to use names in the format of "eth''X''" and "wlan''X''"''', because this may lead to race conditions between the kernel and udev during boot. Instead, it is better to use interface names that are not used by the kernel as default, e.g.: {{ic|net0}}, {{ic|net1}}, {{ic|wifi0}}, {{ic|wifi1}}. For further details please see the [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames systemd] documentation.}}<br />
<br />
=== Set device MTU and queue Length ===<br />
<br />
You can change the device MTU and queue length by defining manually with an udev-rule. For example:<br />
<br />
{{hc|/etc/udev/rules.d/10-network.rules|<nowiki><br />
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", ATTR{mtu}="1480", ATTR{tx_queue_len}="2000"<br />
</nowiki>}}<br />
<br />
=== Get current device names ===<br />
<br />
Current NIC names can be found via sysfs<br />
<br />
{{hc|$ ls /sys/class/net|<br />
lo eth0 eth1 firewire0<br />
}}<br />
<br />
=== Enabling and disabling network interfaces ===<br />
<br />
You can activate or deactivate network interfaces using:<br />
<br />
# ip link set eth0 up<br />
# ip link set eth0 down<br />
<br />
To check the result:<br />
<br />
{{hc|$ ip link show dev eth0|<br />
2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000<br />
...<br />
}}<br />
<br />
== Configure the IP address ==<br />
<br />
You have two options: a dynamically assigned address using [[Wikipedia:Dynamic Host Configuration Protocol|DHCP]], or an unchanging "static" address.<br />
<br />
=== Dynamic IP address ===<br />
<br />
==== Manually run DHCP Client Daemon ====<br />
<br />
{{Note|{{ic|dhcpcd}} (DHCP ''client'' daemon) is not the same as {{ic|dhcpd}} (DHCP ''(server)'' daemon).}}<br />
<br />
{{hc|# dhcpcd eth0|<br />
dhcpcd: version 5.1.1 starting<br />
dhcpcd: eth0: broadcasting for a lease<br />
...<br />
dhcpcd: eth0: leased 192.168.1.70 for 86400 seconds<br />
}}<br />
<br />
And now, {{ic|ip addr show dev eth0}} should show your inet address.<br />
<br />
For some people, {{ic|dhclient}} (from the {{Pkg|dhclient}} package) works where {{ic|dhcpcd}} fails.<br />
<br />
==== Run DHCP at boot ====<br />
<br />
If you simply want to use DHCP for your Ethernet connection, you can use {{ic|dhcpcd@.service}} (provided by the {{Pkg|dhcpcd}} package).<br />
<br />
To start DHCP for {{ic|eth0}}, simply use:<br />
<br />
# systemctl start dhcpcd@eth0.service<br />
<br />
You can enable the service to automatically start at boot with:<br />
<br />
# systemctl enable dhcpcd@eth0.service<br />
<br />
If you use DHCP and you do '''not''' want your DNS servers automatically assigned every time you start your network, be sure to add the following to the last section of {{ic|dhcpcd.conf}}:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nohook resolv.conf<br />
}}<br />
<br />
Also, if you are on a network with DHCPv4 that filters Client IDs based on MAC addresses, you may need to change the following line:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 Client ID as per RFC4361. <br />
duid<br />
}}<br />
<br />
To:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
# Use the hardware address of the interface for the Client ID (DHCPv4).<br />
clientid<br />
}}<br />
<br />
Else, you may not obtain a lease since the DHCP server may not read your [http://en.wikipedia.org/wiki/DHCPv6 DHCPv6-style] Client ID correctly. See [http://tools.ietf.org/html/rfc4361 RFC 4361] for more information.<br />
<br />
To prevent {{ic|dhcpcd}} from adding domain name servers to {{ic|/etc/resolv.conf}}, use the {{ic|nooption}} option:<br />
<br />
{{hc|/etc/dhcpcd.conf|<br />
nooption domain_name_servers<br />
}}<br />
<br />
Then add your own DNS name server to {{ic|/etc/resolv.conf}}.<br />
<br />
You may use the {{Pkg|openresolv}} package if several different processes want to control {{ic|/etc/resolv.conf}} (e.g. {{Pkg|dhcpcd}} and a VPN client). No additional configuration for {{Pkg|dhcpcd}} is needed to use {{Pkg|openresolv}}.<br />
<br />
==== DHCP static route(s) ====<br />
If you need to add a static route client-side, create a new dhcpcd hook-script in {{ic|/usr/lib/dhcpcd/dhcpcd-hooks}}. The example shows a new hook-script which adds a static route to a VPN subnet on 10.11.12.0/24 via a gateway machine at 192.168.192.5:<br />
{{hc|/usr/lib/dhcpcd/dhcpcd-hooks/40-vpnroute|<br />
ip route add 10.11.12.0/24 via 192.168.192.5<br />
}}<br />
The ''40'' prefix means that it is the final hook-script to run when dhcpcd starts.<br />
<br />
=== Static IP address ===<br />
<br />
There are various reasons why you may wish to assign static IP addresses on your network. For instance, one may gain a certain degree of predictability with unchanging addresses, or you may not have a DHCP server available.<br />
<br />
{{Note|If you share your Internet connection from a Windows machine without a router, be sure to use static IP addresses on both computers to avoid LAN problems.}}<br />
<br />
You need:<br />
<br />
* Static IP address<br />
* [[Wikipedia:Subnetwork|Subnet mask]]<br />
* [[Wikipedia:Broadcast_address|Broadcast address]]<br />
* [[Wikipedia:Default_gateway|Gateway]]'s IP address<br />
<br />
If you are running a private network, it is safe to use IP addresses in 192.168.*.* for your IP addresses, with a subnet mask of 255.255.255.0 and a broadcast address of 192.168.*.255. The gateway is usually 192.168.*.1 or 192.168.*.254.<br />
<br />
==== Manual assignment ====<br />
<br />
You can assign a static IP address in the console:<br />
<br />
# ip addr add <IP address>/<subnet mask> broadcast <broadcast> dev <interface><br />
<br />
For example:<br />
<br />
# ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev eth0<br />
<br />
{{Note|The subnet mask was specified using [[Wikipedia:CIDR_notation|CIDR notation]].}}<br />
<br />
For more options, see {{ic|man ip}}.<br />
<br />
Add your gateway like so:<br />
<br />
# ip route add default via <default gateway IP address><br />
<br />
For example:<br />
<br />
# ip route add default via 192.168.1.1<br />
<br />
If you the get the error "No such process", it means you have to run {{ic|ip link set dev eth0 up}} as root.<br />
<br />
==== Manual connection at boot using systemd ====<br />
<br />
Ensure that dhcpcd is stopped and disabled:<br />
<br />
# systemctl status dhcpcd.service<br />
<br />
Create a configuration file for the [[systemd]] service. Replace {{ic|<interface>}} with the proper network interface name:<br />
<br />
{{hc|/etc/conf.d/network@<interface>|<nowiki><br />
address=192.168.0.15<br />
netmask=24<br />
broadcast=192.168.0.255<br />
gateway=192.168.0.1<br />
</nowiki>}}<br />
<br />
Create a systemd unit file:<br />
<br />
{{hc|/etc/systemd/system/network@.service|<nowiki><br />
[Unit]<br />
Description=Network connectivity (%i)<br />
Wants=network.target<br />
Before=network.target<br />
BindsTo=sys-subsystem-net-devices-%i.device<br />
After=sys-subsystem-net-devices-%i.device<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
EnvironmentFile=/etc/conf.d/network@%i<br />
<br />
ExecStart=/usr/bin/ip link set dev %i up<br />
ExecStart=/usr/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i<br />
ExecStart=/usr/bin/ip route add default via ${gateway}<br />
<br />
ExecStop=/usr/bin/ip addr flush dev %i<br />
ExecStop=/usr/bin/ip link set dev %i down<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
Enable the unit and start it, passing the name of the interface, in this case eno1:<br />
<br />
# systemctl enable network@eno1.service<br />
# systemctl start network@eno1.service<br />
<br />
If you need to manually set the nameservers, edit {{ic|/etc/resolv.conf}}:<br />
<br />
{{hc|/etc/resolv.conf|<br />
nameserver 208.67.222.222<br />
nameserver 208.67.220.220}}<br />
<br />
If {{ic|/etc/resolv.conf}} keeps getting overwritten see [[Resolv.conf]] for more details on how to address this issue.<br />
<br />
There are several different ways to utilise systemd to start the network using similar, but different, file contents, and it is also possible to hard code the parameters that can then be picked up from the file referenced in the EnvironmentFile definition. It is therefore possible, as an alternative, to put the interface name into the EnvironmentFile in /etc/conf.d/ and then use the interface name directly instead of %i. In that case the name of the file does not need the "@". It is also useful to read the documentation on systemd service files at http://www.freedesktop.org/software/systemd/man/systemd.unit.html<br />
<br />
==== Calculating addresses ====<br />
<br />
You can use {{ic|ipcalc}} provided by the {{Pkg|ipcalc}} package to calculate IP broadcast, network, netmask, and host ranges for more advanced configurations. For example, I use ethernet over firewire to connect a windows machine to arch. For security and network organization, I placed them on their own network and configured the netmask and broadcast so that they are the only 2 machines on it. To figure out the netmask and broadcast addresses for this, I used ipcalc, providing it with the IP of the arch firewire nic 10.66.66.1, and specifying ipcalc should create a network of only 2 hosts.<br />
<br />
{{hc|$ ipcalc -nb 10.66.66.1 -s 1|<nowiki><br />
Address: 10.66.66.1<br />
<br />
Netmask: 255.255.255.252 = 30<br />
Network: 10.66.66.0/30<br />
HostMin: 10.66.66.1<br />
HostMax: 10.66.66.2<br />
Broadcast: 10.66.66.3<br />
Hosts/Net: 2 Class A, Private Internet<br />
</nowiki>}}<br />
<br />
== Load configuration ==<br />
<br />
To test your settings either reboot the computer or reload the relevant systemd services:<br />
<br />
# systemctl restart dhcpcd@eth0<br />
<br />
Try pinging your gateway, DNS server, ISP provider and other Internet sites, in that order, to detect any connection problems along the way, as in this example:<br />
<br />
$ ping -c 3 www.google.com<br />
<br />
== Additional settings ==<br />
<br />
=== ifplugd for laptops ===<br />
<br />
{{Tip|{{Pkg|dhcpcd}} provides the same feature out of the box.}}<br />
<br />
{{Pkg|ifplugd}} in [[Official Repositories]] is a daemon which will automatically configure your Ethernet device when a cable is plugged in and automatically unconfigure it if the cable is pulled. This is useful on laptops with onboard network adapters, since it will only configure the interface when a cable is really connected. Another use is when you just need to restart the network but do not want to restart the computer or do it from the shell.<br />
<br />
By default it is configured to work for the {{ic|eth0}} device. This and other settings like delays can be configured in {{ic|/etc/ifplugd/ifplugd.conf}}.<br />
<br />
{{Note|[[Netctl]] package includes {{ic|netctl-ifplugd@.service}}, otherwise you can use {{ic|ifplugd@.service}} from {{Pkg|ifplugd}} package. Use for example {{ic|systemctl enable ifplugd@eth0.service}}.}}<br />
<br />
=== Bonding or LAG ===<br />
<br />
See [[netctl#Bonding]].<br />
<br />
=== IP address aliasing ===<br />
<br />
{{Expansion|Manual method using [[Core Utilities#ip|ip]] should be added; then move current example using ''netctl'' into [[netctl]].}}<br />
<br />
IP aliasing is the process of adding more than one IP address to a network interface. With this, one node on a network can have multiple connections to a network, each serving a different purpose. Typical uses are virtual hosting of Web and FTP servers, or reorganizing servers without having to update any other machines (this is especially useful for nameservers).<br />
<br />
==== Example ====<br />
<br />
You will need {{Pkg|netctl}} from the [[Official Repositories]].<br />
<br />
Prepare the configuration:<br />
<br />
{{hc|/etc/netctl/mynetwork|<nowiki><br />
Connection='ethernet'<br />
Description='Five different addresses on the same NIC.'<br />
Interface='eth0'<br />
IP='static'<br />
Address=('192.168.1.10' '192.168.178.11' '192.168.1.12' '192.168.1.13' '192.168.1.14' '192.168.1.15')<br />
Gateway='192.168.1.1'<br />
DNS=('192.168.1.1')<br />
</nowiki>}}<br />
<br />
Then simply execute: <br />
<br />
$ netctl start mynetwork<br />
<br />
=== Change MAC/hardware address ===<br />
<br />
See [[MAC Address Spoofing]].<br />
<br />
=== Internet Sharing ===<br />
<br />
See [[Internet Sharing]].<br />
<br />
=== Router Configuration ===<br />
<br />
See [[Router]].<br />
<br />
=== Local network hostname resolution ===<br />
<br />
The pre-requisite is to [[#Set the hostname]] after which hostname resolution works on the local system itself {{hc|$ ping hostname|<br />
PING hostname <nowiki>(192.168.1.2) 56(84) bytes of data.<br />
64 bytes from hostname (192.168.1.2): icmp_seq=1 ttl=64 time=0.043 ms</nowiki>}}<br />
To enable other machines to address the host by name, either a manual configuration of the respective {{ic|/etc/hosts}} files or a service to propagate/resolve the name is required. <br />
<br />
When setting up a DNS server such as [[BIND]] or [[Unbound]] is overkill, manually editing your {{ic|/etc/hosts}} is too cumbersome, or when you want more flexibility with dynamic leaving and joining of hosts to the network, it is possible to handle hostname resolution on your local network using zero-configuration networking. There are two options available:<br />
<br />
*[[Samba]] provides hostname resolution via Microsoft's '''NetBIOS'''. It only requires installation of {{Pkg|samba}} and enabling of the {{ic|nmbd.service}} service. Computers running Windows, OS X, or Linux with {{ic|nmbd}} running, will be able to find your machine.<br />
<br />
*[[Avahi]] provides hostname resolution via '''zeroconf''', also known as Avahi or Bonjour. It requires slightly more complex configuration than Samba: see [[Avahi#Hostname resolution]] for details. Computers running OS X, or Linux with an Avahi daemon running, will be able to find your machine. Windows does not have an built-in Avahi client or daemon.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Swapping computers on the cable modem ===<br />
<br />
Some cable ISPs (videotron for example) have the cable modem configured to recognize only one client PC, by the MAC address of its network interface. Once the cable modem has learned the MAC address of the first PC or equipment that talks to it, it will not respond to another MAC address in any way. Thus if you swap one PC for another (or for a router), the new PC (or router) will not work with the cable modem, because the new PC (or router) has a MAC address different from the old one. To reset the cable modem so that it will recognise the new PC, you must power the cable modem off and on again. Once the cable modem has rebooted and gone fully online again (indicator lights settled down), reboot the newly connected PC so that it makes a DHCP request, or manually make it request a new DHCP lease.<br />
<br />
If this method does not work, you will need to clone the MAC address of the original machine. See also [[Configuring Network#Change MAC/hardware address|Change MAC/hardware address]].<br />
<br />
=== The TCP window scaling problem ===<br />
<br />
TCP packets contain a "window" value in their headers indicating how much data the other host may send in return. This value is represented with only 16 bits, hence the window size is at most 64Kb. TCP packets are cached for a while (they have to be reordered), and as memory is (or used to be) limited, one host could easily run out of it.<br />
<br />
Back in 1992, as more and more memory became available, [http://www.faqs.org/rfcs/rfc1323.html RFC 1323] was written to improve the situation: Window Scaling. The "window" value, provided in all packets, will be modified by a Scale Factor defined once, at the very beginning of the connection.<br />
<br />
That 8-bit Scale Factor allows the Window to be up to 32 times higher than the initial 64Kb.<br />
<br />
It appears that some broken routers and firewalls on the Internet are rewriting the Scale Factor to 0 which causes misunderstandings between hosts.<br />
<br />
The Linux kernel 2.6.17 introduced a new calculation scheme generating higher Scale Factors, virtually making the aftermaths of the broken routers and firewalls more visible.<br />
<br />
The resulting connection is at best very slow or broken.<br />
<br />
==== How to diagnose the problem ====<br />
<br />
First of all, let's make it clear: this problem is odd. In some cases, you will not be able to use TCP connections (HTTP, FTP, ...) at all and in others, you will be able to communicate with some hosts (very few).<br />
<br />
When you have this problem, the {{ic|dmesg}}'s output is OK, logs are clean and {{ic|ip addr}} will report normal status... and actually everything appears normal.<br />
<br />
If you cannot browse any website, but you can ping some random hosts, chances are great that you're experiencing this problem: ping uses ICMP and is not affected by TCP problems.<br />
<br />
You can try to use Wireshark. You might see successful UDP and ICMP communications but unsuccessful TCP communications (only to foreign hosts).<br />
<br />
==== How to fix it (The bad way) ====<br />
<br />
To fix it the bad way, you can change the tcp_rmem value, on which Scale Factor calculation is based. Although it should work for most hosts, it is not guaranteed, especially for very distant ones.<br />
<br />
# echo "4096 87380 174760" > /proc/sys/net/ipv4/tcp_rmem<br />
<br />
==== How to fix it (The good way) ====<br />
<br />
Simply disable Window Scaling. Since Window Scaling is a nice TCP feature, it may be uncomfortable to disable it, especially if you cannot fix the broken router. There are several ways to disable Window Scaling, and it seems that the most bulletproof way (which will work with most kernels) is to add the following line to {{ic|/etc/sysctl.d/99-disable_window_scaling.conf}} (see also [[sysctl]])<br />
<br />
net.ipv4.tcp_window_scaling = 0<br />
<br />
==== How to fix it (The best way) ====<br />
<br />
This problem is caused by broken routers/firewalls, so let's change them. Some users have reported that the broken router was their very own DSL router.<br />
<br />
==== More about it ====<br />
<br />
This section is based on the LWN article [http://lwn.net/Articles/92727/ TCP window scaling and broken routers] and a Kernel Trap article: [http://kerneltrap.org/node/6723 Window Scaling on the Internet].<br />
<br />
There are also several relevant threads on the LKML.<br />
<br />
=== Realtek no link / WOL problem ===<br />
<br />
Users with Realtek 8168 8169 8101 8111(C) based NICs (cards / and on-board) may notice a problem where the NIC seems to be disabled on boot and has no Link light. This can usually be found on a dual boot system where Windows is also installed. It seems that using the offical Realtek drivers (dated anything after May 2007) under Windows is the cause. These newer drivers disable the Wake-On-LAN feature by disabling the NIC at Windows shutdown time, where it will remain disabled until the next time Windows boots. You will be able to notice if this problem is affecting you if the Link light remains off until Windows boots up; during Windows shutdown the Link light will switch off. Normal operation should be that the link light is always on as long as the system is on, even during POST. This problem will also affect other operative systems without newer drivers (eg. Live CDs). Here are a few fixes for this problem:<br />
<br />
==== Method 1 - Rollback/change Windows driver ====<br />
<br />
You can roll back your Windows NIC driver to the Microsoft provided one (if available), or roll back/install an official Realtek driver pre-dating May 2007 (may be on the CD that came with your hardware).<br />
<br />
==== Method 2 - Enable WOL in Windows driver ====<br />
<br />
Probably the best and the fastest fix is to change this setting in the Windows driver. This way it should be fixed system-wide and not only under Arch (eg. live CDs, other operative systems). In Windows, under Device Manager, find your Realtek network adapter and double-click it. Under the Advanced tab, change "Wake-on-LAN after shutdown" to Enable.<br />
<br />
In Windows XP (example)<br />
Right click my computer<br />
--> Hardware tab<br />
--> Device Manager<br />
--> Network Adapters<br />
--> "double click" Realtek ...<br />
--> Advanced tab<br />
--> Wake-On-Lan After Shutdown<br />
--> Enable<br />
<br />
{{Note|Newer Realtek Windows drivers (tested with ''Realtek 8111/8169 LAN Driver v5.708.1030.2008'', dated 2009/01/22, available from GIGABYTE) may refer to this option slightly differently, like ''Shutdown Wake-On-LAN --> Enable''. It seems that switching it to {{ic|Disable}} has no effect (you will notice the Link light still turns off upon Windows shutdown). One rather dirty workaround is to boot to Windows and just reset the system (perform an ungraceful restart/shutdown) thus not giving the Windows driver a chance to disable LAN. The Link light will remain on and the LAN adapter will remain accessible after POST - that is until you boot back to Windows and shut it down properly again.}}<br />
<br />
==== Method 3 - Newer Realtek Linux driver ====<br />
<br />
Any newer driver for these Realtek cards can be found for Linux on the realtek site. (untested but believed to also solve the problem).<br />
<br />
==== Method 4 - Enable ''LAN Boot ROM'' in BIOS/CMOS ====<br />
<br />
It appears that setting ''Integrated Peripherals --> Onboard LAN Boot ROM --> Enabled'' in BIOS/CMOS reactivates the Realtek LAN chip on system boot-up, despite the Windows driver disabling it on OS shutdown.<br />
<br />
{{Note|This was tested successfully multiple times with GIGABYTE system board GA-G31M-ES2L with BIOS version F8 released on 2009/02/05. YMMV.}}<br />
<br />
=== DLink G604T/DLink G502T DNS problem ===<br />
<br />
Users with a DLink G604T/DLink G502T router, using DHCP and have firmware v2.00+ (typically users with AUS firmware) may have problems with certain programs not resolving the DNS. One of these programs are unfortunatley pacman. The problem is basically the router in certain situations is not sending the DNS properly to DHCP, which causes programs to try and connect to servers with an IP address of 1.0.0.0 and fail with a connection timed out error<br />
<br />
==== How to diagnose the problem ====<br />
<br />
The best way to diagnose the problem is to use Firefox/Konqueror/links/seamonkey and to enable wget for pacman. If this is a fresh install of Arch Linux, then you may want to consider installing {{ic|links}} through the live CD.<br />
<br />
Firstly, enable wget for pacman (since it gives us info about pacman when it is downloading packages)<br />
Open {{ic|/etc/pacman.conf}} with your favourite editor and uncomment the following line (remove the # if it is there)<br />
<br />
XferCommand=/usr/bin/wget --passive-ftp -c -O %o %u<br />
<br />
While you are editing {{ic|/etc/pacman.conf}}, check the default mirror that pacman uses to download packages.<br />
<br />
Now open up the default mirror in an Internet browser to see if the mirror actually works. If it does work, then do {{ic|pacman -Syy}} (otherwise pick another working mirror and set it to the pacman default). If you get something similar to the following (notice the 1.0.0.0),<br />
<br />
<nowiki>ftp://mirror.pacific.net.au/linux/archlinux/extra/os/i686/extra.db.tar.gz</nowiki><br />
=> '/var/lib/pacman/community.db.tar.gz.part'<br />
Resolving mirror.pacific.net.au... 1.0.0.0<br />
<br />
then you most likely have this problem. The 1.0.0.0 means it is unable to resolve DNS, so we must add it to {{ic|/etc/resolv.conf}}.<br />
<br />
==== How to fix it ====<br />
<br />
{{Out of date|{{Pkg|dhcpcd}} does not use {{ic|/etc/conf.d/dhcpcd}} any more.}}<br />
<br />
Basically what we need to do is to manually add the DNS servers to our {{ic|/etc/resolv.conf}} file. The problem is that DHCP automatically deletes and replaces this file on boot, so we need to edit {{ic|/etc/conf.d/dhcpcd}} and change the flags to stop DHCP from doing this.<br />
<br />
When you open {{ic|/etc/conf.d/dhcpcd}}, you should see something close to the following:<br />
<br />
DHCPCD_ARGS="-t 30 -h $HOSTNAME"<br />
<br />
Add the {{ic|-R}} flag to the arguments, e.g.,<br />
<br />
DHCPCD_ARGS="-R -t 30 -h $HOSTNAME"<br />
<br />
{{Note|1=If you are using {{Pkg|dhcpcd}} >= 4.0.2, the {{ic|-R}} flag has been deprecated. Please see the [[#Run DHCP at boot]] section for information on how to use a custom {{ic|/etc/resolv.conf}} file.}}<br />
<br />
Save and close the file; now open {{ic|/etc/resolv.conf}}. You should see a single nameserver (most likely 10.1.1.1). This is the gateway to your router, which we need to connect to in order to get the DNS servers of your ISP. Paste the IP address into your browser and log in to your router. Go to the DNS section, and you should see an IP address in the Primary DNS Server field; copy it and paste it as a nameserver '''ABOVE''' the current gateway one.<br />
<br />
For example, {{ic|/etc/resolv.conf}} should look something along the lines of:<br />
<br />
nameserver 10.1.1.1<br />
<br />
If my primary DNS server is 211.29.132.12, then change {{ic|/etc/resolv.conf}} to:<br />
<br />
nameserver 211.29.132.12<br />
nameserver 10.1.1.1<br />
<br />
Now restart the network daemon by running {{ic|systemctl restart dhcpcd@<interface>}} and do {{ic|pacman -Syy}}. If it syncs correctly with the server, then the problem is solved.<br />
<br />
==== More about it ====<br />
<br />
This is the whirlpool forum (Australian ISP community) which talks about and gives the same solution to the problem:<br />
<br />
http://forums.whirlpool.net.au/forum-replies-archive.cfm/461625.html<br />
<br />
=== Check DHCP problem by releasing IP first ===<br />
<br />
Problem may occur when DHCP get wrong IP assignment. For example when two routers are tied together through VPN. The router that is connected to me by VPN may assigning IP address. To fix it. On a console, as root, release IP address:<br />
<br />
# dhcpcd -k<br />
<br />
Then request a new one:<br />
<br />
# dhcpcd<br />
<br />
Maybe you had to run those two commands many times.<br />
<br />
=== No eth0 with Atheros AR8161 ===<br />
<br />
{{Note|With the 3.10.2-1-ARCH kernel update, the alx ethernet driver module is included in the package.}}<br />
<br />
With the Atheros AR8161 Gigabit Ethernet card, the ethernet connection is not working out-of-the-box (with the installation media of March 2013). The module "alx" needs to be loaded but is not present.<br />
<br />
The driver from [http://linuxwireless.org/en/users/Download/stable/#compat-wireless_stable_releases compat-wireless] (that has become [https://backports.wiki.kernel.org/index.php/Releases compat-drives] since linux 3.7) need to be installed. The "-u" postfix annotates that Qualcomm have applied a driver under a unified driver.<br />
<br />
$ wget https://www.kernel.org/pub/linux/kernel/projects/backports/2013/03/28/compat-drivers-2013-03-28-5-u.tar.bz2<br />
$ tar xjf compat*<br />
$ cd compat*<br />
$ ./scripts/driver-select alx<br />
$ make<br />
$ sudo make install<br />
$ sudo modprobe alx<br />
<br />
The alx driver has not been added to Linux kernel due to various problems. Compatibility between the different kernel versions has been spotty. For better support follow the [http://lists.infradead.org/mailman/listinfo/unified-drivers mailing list]and [http://www.linuxfoundation.org/collaborate/workgroups/networking/alx alx page]for latest working solution for alx.<br />
<br />
The driver must be built and installed after every kernel change.<br />
<br />
Alternatively you can use the AUR package for [https://aur.archlinux.org/packages/compat-drivers-patched/ compat drivers], which installs many other drivers.<br />
<br />
=== No eth0 with Atheros AR9485 ===<br />
<br />
The ethernet (eth0) for Atheros AR9485 are not working out-of-the-box (with installation media of March 2013). The working solution for this is to install the package [https://aur.archlinux.org/packages/compat-drivers-patched/ compat-drivers-patched] from AUR.<br />
<br />
=== No carrier / no connection after suspend ===<br />
After suspend to RAM no connection is found although the network cable is plugged in. <br />
This may be caused by PCI power management. What is the output of<br />
<br />
# ip link show eth0<br />
<br />
If the line contains "NO-CARRIER" even though there's a cable connected to your eth0 port, it is possible that the device was auto-suspended and the media sense feature doesn't work. To solve this, first you need to find your ethernet controllers PCI address by<br />
<br />
# lspci<br />
<br />
This should look similar to this:<br />
<br />
...<br />
00:19.0 Ethernet controller: Intel Corporation 82577LM Gigabit Network Connection (rev 06)<br />
...<br />
<br />
So the address is 00:19.0.<br />
Now check the PM status of the device by issuing<br />
<br />
# cat "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
substituting 00:19.0 with the address obtained from lspci.<br />
If the output reads "auto", you can try to bring the device out of suspend by<br />
<br />
# echo on > "/sys/bus/pci/devices/0000:00:19.0/power/control"<br />
<br />
Don't forget to substitute the address again.<br />
<br />
{{Note|1=This appears to be a bug in kernel 3.8.4.1- (3.8.8.1 is still affected): [https://bbs.archlinux.org/viewtopic.php?id=159837&p=2 Forum discussion.] It also appears a fix is [https://lkml.org/lkml/2013/1/18/147 on the way. (It will be likely fixed in 3.9.)] In the meantime, the above is a suitable workaround.}}<br />
<br />
=== Broadcom BCM57780 ===<br />
<br />
This Broadcom chipset sometimes does not behave well unless you specify the order of the modules to be loaded. The modules are {{ic|broadcom}} and {{ic|tg3}}, the former needing to be loaded first.<br />
<br />
These steps should help if your computer has this chipset:<br />
$ lspci | grep Ethernet<br />
02:00.0 Ethernet controller: Broadcom Corporation NetLink BCM57780 Gigabit Ethernet PCIe (rev 01)<br />
<br />
If your wired networking is not functioning in some way or another, try unplugging your cable then doing the following (as root):<br />
# modprobe -r tg3<br />
# modprobe broadcom<br />
# modprobe tg3<br />
<br />
Now plug you network cable in. If this solves your problems you can make this permanent by adding {{ic|broadcom}} and {{ic|tg3}} (in this order) to the {{ic|MODULES}} array in {{ic|/etc/mkinitcpio.conf}}:<br />
<br />
MODULES=".. broadcom tg3 .."<br />
<br />
Then rebuild the initramfs:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|These methods may work for other chipsets, such as BCM57760.}}</div>Binotahttps://wiki.archlinux.org/index.php?title=Arch_Linux_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&diff=293522Arch Linux (正體中文)2014-01-19T07:15:00Z<p>Binota: /* 來源完整性 */</p>
<hr />
<div>[[Category:正體中文]]<br />
[[Category:About Arch (正體中文)]]<br />
[[ar:Arch Linux]]<br />
[[bg:Arch Linux]]<br />
[[cs:Arch Linux]]<br />
[[da:Arch Linux]]<br />
[[de:Über Arch Linux]]<br />
[[el:Arch Linux]]<br />
[[en:Arch Linux]]<br />
[[es:Arch Linux]]<br />
[[fr:Arch Linux]]<br />
[[he:Arch Linux]]<br />
[[hr:Arch Linux]]<br />
[[hu:Arch Linux]]<br />
[[id:Arch Linux]]<br />
[[it:Arch Linux]]<br />
[[ja:Arch Linux]]<br />
[[ko:Arch Linux]]<br />
[[lt:Arch Linux]]<br />
[[nl:Arch Linux]]<br />
[[pl:Arch Linux]]<br />
[[pt:Arch Linux]]<br />
[[ro:Arch Linux]]<br />
[[ru:Arch Linux]]<br />
[[sk:Arch Linux]]<br />
[[sr:Arch Linux]]<br />
[[th:Arch Linux]]<br />
[[tr:Arch_Linux]]<br />
[[uk:Arch Linux]]<br />
[[zh-CN:Arch Linux]]<br />
<br />
{{翻譯狀態|Arch_Linux|2013-09-06|260039}}<br />
<br />
Arch Linux 是一套獨立開發、支援 [[Wikipedia:P6 (microarchitecture)|i686]]/[[Wikipedia:x86-64|x86-64]] 架構的通用 GNU/Linux 發行版本,靈活度高,適合各種用途。Arch 的開發著重於簡易、最小化,以及優雅的編程。Arch 預設只會安裝一個精簡的基本系統,讓使用者組裝心目中最為理想的操作環境,只安裝所需的軟體包以達到目的。官方將不提供 GUI 配置工具,絕大多數的系統設定都將在 shell (文字介面) 和文字編輯器下進行。Arch 基於「無縫發行」 (rolling-release),致力走在最前線,並盡其所能地提供所有最新、最穩定的軟體。<br />
<br />
== 歷史 ==<br />
<br />
:''主文章:[[History of Arch Linux|Arch Linux 的歷史]]''<br />
<br />
Arch Linux 的起始作者是加拿大籍程式設計師 Judd Vinet。第一個正式版本 Arch Linux 0.1 於 2002/03/11 釋出。雖然 Arch 是完全獨立的發行版,但它也借鑑了其他發行版本講求簡潔的思想,例如 [http://slackware.com Slackware]、[http://www.crux.nu CRUX] 與 [http://en.wikipedia.org/wiki/Berkeley_Software_Distribution BSD]。2007 年,Judd Vinet 離開專案領導人的位置,由美籍程式設計師 Aaron Griffin 接手領導專案至今。<br />
<br />
== 簡潔 ==<br />
<br />
Arch Linux 盡可能地符合原本的「類 UNIX」系統:輕量、彈性加簡潔,並嚴格遵守 [[The Arch Way (正體中文)|Arch 的設計哲學]]。安裝 Arch 之後,使用者會得到一個於 i686/x86-64 架構下編譯的最小化環境 (無 GUI):Arch 不會自作聰明地提供多餘的預設軟體包,而是為使用者奠定基礎,讓使用者有個一磚一瓦打造系統的機會,不需要去剔除對自己毫無用處的軟體包。<br />
有了 Arch 的設計哲學與實作,無論是擴充、打造任何類型的系統都變得更容易。'''使用者'''可以決定自己的 Arch 系統要變成什麼樣子:從小而精簡的終端機器,到大且功能豐富的桌面環境,統統都沒問題。<br />
<br />
== 現代化 ==<br />
<br />
Arch Linux 致力將軟體保持在最新的穩定版本,若有出現系統軟體包的破損,也盡可能保持在容許範圍之內。Arch 屬於[[Wikipedia:Rolling release|無縫發行]]系統,一次安裝、持續更新即可,您不用每次為了新釋出的版本而重新安裝。升級系統也沒有太冗長的步驟,您只需要一項指令,就能讓 Arch 系統保持在最新、最前端的狀態。<br />
<br />
Arch 內含許多 GNU/Linux 下嶄新的功能供各位使用,像是 [[systemd]] 初始系統、更新的檔案系統 (Ext2/3/4, Reiser, XFS, JFS, BTRFS)、LVM2/EVMS、軟體 RAID、udev 支援,以及 initcpio (附加 [[mkinitcpio]]),當然還有最新版的核心。<br />
<br />
== 軟體打包 ==<br />
<br />
使用 Arch 不得不知 [[pacman_(正體中文)|Pacman]],這是一套容易使用的[[Wikipedia:Package manager|軟體包管理員]],升級整個系統只需一項指令。Pacman 是以 ''C'' 語言從頭開始撰寫,不僅輕量、簡潔,執行也十分快速。Arch 也提供了與 ports 類似的 [[Arch Build System|Arch 構建系統 (ABS)]],從下載程式原始碼、編譯到安裝都十分簡單,同步也只需一項指令。您甚至可以用一條指令重建整台系統。<br />
<br />
Arch 的[[Official Repositories|官方倉庫]]提供了上千種高品質的軟體包,並同時支援 i686 與 x86-64 架構,相信能夠滿足您的軟體需求。另外,Arch 為了鼓勵社群的成長與貢獻,也提供 [[Arch User Repository|Arch 使用者倉庫 (AUR)]],裡頭包含了數千種由使用者自行維護的 PKGBUILD 腳本,只要使用 ''makepkg'' 程式,從下載源碼、編譯到打包軟體一氣呵成。使用者也可以輕鬆構建、維護他們自己的客製倉庫。<br />
<br />
== 來源完整性 ==<br />
<br />
Arch 提供最乾淨的軟體,不加任何修補程式;所有軟體包都純粹來自[[Wikipedia:upstream (software development)|上游]]原始碼,並完全照軟體作者的意思發布,以避免無縫更新時因版本不符,對系統造成嚴重破壞。只有在非常罕見的情況下,我們才會使用修補程式。<br />
<br />
== 社群 ==<br />
<br />
Arch 社群非常可靠活躍,也十分歡迎各位的加入。我們鼓勵每個'''Arch 玩家'''都能夠參與其中、付出貢獻:幫忙開發核心軟體、維護軟體包、回報/修復[https://bugs.archlinux.org/ 臭蟲]、撰寫/潤飾 [[Main Page|ArchWiki 文件]],或是到[https://bbs.archlinux.org/ 論壇]、[https://mailman.archlinux.org/mailman/listinfo/ 郵遞清單]、[[IRC Channels|IRC 頻道]]幫忙解決問題、交換意見、分享知識,甚至自行研發新程式!Arch Linux 已經成為全球許多使用者的首選作業系統,有數個[[International Communities|國際社群]]提供幫助並以多國語言撰寫文件。<br />
<br />
想要成為社群中活躍的一分子嗎?請參閱[[Getting Involved|加入我們]]。<br />
<br />
== 總結 ==<br />
<br />
總歸一句話:Arch Linux 是個麻雀雖小,五臟俱全的發行版本。它主攻熟悉 Linux&reg; 的使用者,並符合他們的需求。Arch 強大又易於管理,是伺服器、工作站的理想發行版。Arch 是否跟您心目中 GNU/Linux 發行版本一模一樣呢?假如您跟我們有志一同,歡迎您盡情的使用 Arch,融入其中,並加入社群貢獻一份心力。歡迎加入 Arch 的行列!</div>Binota