linux設(shè)置靜態(tài)ip地址 Linux設(shè)置靜態(tài)IP地址?
Linux設(shè)置靜態(tài)IP地址?1、在Linux下設(shè)置機(jī)器的靜態(tài)IP地址:VIM/etc/sysconfig/network scripts/ifcfg-eth0修改此文件的內(nèi)容如下:#Intel Cor
Linux設(shè)置靜態(tài)IP地址?
1、在Linux下設(shè)置機(jī)器的靜態(tài)IP地址:VIM/etc/sysconfig/network scripts/ifcfg-eth0修改此文件的內(nèi)容如下:#Intel Corporation 82541gi Gigabit Ethernet controllerdevice=eth0bootproto=static#hwaddr=00:15:17:B2:DC:b5onboot=yesipaddr=10.20.134.199#netmask=255.255.254.0Gateway=10.20.134.1修改網(wǎng)關(guān)后,需要重新啟動(dòng)網(wǎng)絡(luò)。更改將生效/etc/init.d/network restart。2自動(dòng)獲取動(dòng)態(tài)IP地址模式:VIM/etc/sysconfig/network scripts/ifcfg-eth1。內(nèi)容如下:#Intel Corporation 82566dm-2 gigabit network connection device=eth1bootproto=DHCP#dynamic obtain iphwaddr=00:15:17:B2:DC:b7onboot=no運(yùn)行命令:dhclient eth1自動(dòng)獲取動(dòng)態(tài)IP地址。您可以通過(guò)ifconfig查看分配的IP地址。
如何在linux系統(tǒng)中設(shè)置靜態(tài)ip地址?
Linux需要修改配置文件/etc/network/interfaces來(lái)修改IP地址。
如果要設(shè)置靜態(tài)IP地址,您需要在配置文件中寫(xiě)入以下內(nèi)容:
auto eth0
Iface eth0 INET static
address here是靜態(tài)IP
netmask here是子網(wǎng)掩碼
gateway here是網(wǎng)關(guān)地址
network here是網(wǎng)段的網(wǎng)絡(luò)地址
broadcast here是網(wǎng)絡(luò)段的廣播地址網(wǎng)段
注意:配置文件中的eth0是網(wǎng)卡的名稱(chēng),也是您自己主機(jī)上網(wǎng)卡的名稱(chēng)(用iwconfig可以看到無(wú)線網(wǎng)卡,用ifcongfig可以看到普通有線網(wǎng)卡)。
Auto eth0表示網(wǎng)卡設(shè)置在機(jī)器開(kāi)機(jī)時(shí)生效;
Iface eth0 INET static line表示“eth0接口的網(wǎng)絡(luò)是一個(gè)靜態(tài)地址”,以下字段可以理解為字面意思;
網(wǎng)絡(luò)和廣播也可以省略。
修改后,保存并退出。您需要重新啟動(dòng)網(wǎng)絡(luò)(而不是主機(jī))才能使配置生效。重新啟動(dòng)網(wǎng)絡(luò)命令:[etc/init。重新啟動(dòng)網(wǎng)絡(luò)
重新啟動(dòng)網(wǎng)絡(luò)后,可以使用ifcongfig或iwconfig命令查看修改后的IP。