Linux系統(tǒng)靜態(tài)網(wǎng)絡(luò)配置
啟動Linux系統(tǒng)后,首先查看機(jī)器的網(wǎng)絡(luò)配置:
1、ifconfig了解網(wǎng)卡信息,查看ethX
2、sudo vim /etc/network/interfaces
配置網(wǎng)絡(luò)參數(shù),如:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address (ip地址)
netmask (子網(wǎng)掩碼)
geteway (網(wǎng)關(guān))
3、然后配置DNS:sudo vim /etc/resolv.conf
4、重啟網(wǎng)絡(luò)組建:sudo /etc/init.d/networking restart
重啟后,假如無法上網(wǎng),需要添加網(wǎng)關(guān)
5、sudo route add default gw 172.16.6.1
假如在拷貝其他的虛擬機(jī)直接使用的話,會出現(xiàn)無法上網(wǎng),無法ping任何ip地址的情況。這是因為直接拷貝的虛擬機(jī)也將其mac地址拷貝,導(dǎo)致在新的虛擬機(jī)中無法使用。
解決方法:
1、刪除 /etc/udev/rules.d/70-persistent-net.rules
2、重啟虛擬機(jī),linux系統(tǒng)會自動生成該文件,之后再配置下網(wǎng)絡(luò)就可以上網(wǎng)了。