Linux /etc/network/interfaces配置接口方法
Linux下/etc/network/interfaces文件用來配置網(wǎng)絡(luò)接口。
初始化網(wǎng)口Ethernet Interface
大部分的網(wǎng)絡(luò)接口配置都可以在/etc/network/interfaces中解決。例如為網(wǎng)卡配置靜態(tài)IP(dhcp),設(shè)置路由信息,配置IP掩碼,設(shè)置默認(rèn)路由等。
PS: 如果想要在系統(tǒng)啟動時就自動啟動網(wǎng)口,需要添加auto一行,詳見下面示例。
1. 使用動態(tài)IP地址
auto eth0 iface eth0 inet dhcp
2. 使用靜態(tài)IP地址
auto eth0 iface eth0 inet static address 192.168.1.100 netmask 255.255.255.0 gateway 192.168.1.1 # network 192.168.1.0 # broadcast 192.168.1.255
network和broadcast一般使用默認(rèn)值就行。
3. 查看路由表
# route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0 192.168.1.0 * 255.255.255.0 U 0 0 0 eth0 # route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
route -n不解析名字。
以上就是本站小編給大家整理的相關(guān)內(nèi)容,感謝大家的學(xué)習(xí)和支持。
版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。