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)啟動(dòng)時(shí)就自動(dòng)啟動(dòng)網(wǎng)口,需要添加auto一行,詳見下面示例。
1. 使用動(dòng)態(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í)和支持。
標(biāo)簽:廊坊 紅河 德州 回訪 滁州 巴彥淖爾 廣安 湛江
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Linux /etc/network/interfaces配置接口方法》,本文關(guān)鍵詞 Linux,etc,network,interfaces,配置,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。