本文為大家分享了Ubuntu虛擬機(jī)多網(wǎng)卡配置,供大家參考,具體內(nèi)容如下
1、場(chǎng)景說明
系統(tǒng)平臺(tái):Ubuntu16.04
服務(wù)器:VMWare workstation 虛擬機(jī)12c
解決問題:添加4塊網(wǎng)卡(四個(gè)網(wǎng)段、四個(gè)網(wǎng)關(guān)),第4個(gè)網(wǎng)卡nat上網(wǎng),但是默認(rèn)路由有問題
2、網(wǎng)卡配置內(nèi)容
root@Ocommon:~# cat /etc/network/interfaces# This file describes the network interfaces available on your system# and how to activate them. For more information, see interfaces(5).source /etc/network/interfaces.d/*# The loopback network interfaceauto loiface lo inet loopback# The primary network interface#auto ens32iface ens32 inet staticaddress 1.1.1.2netmask 255.255.255.0gateway 1.1.1.1#auto ens33iface ens33 inet staticaddress 2.2.2.2netmask 255.255.255.0gateway 2.2.2.1#auto ens34iface ens34 inet staticaddress 3.3.3.2netmask 255.255.255.0gateway 3.3.3.1#auto ens35iface ens35 inet dhcp
注意:
但是在都添加“#auto ens3*”后啟動(dòng)就會(huì)出現(xiàn)錯(cuò)誤,所以將#auto ens3*全部去掉,但是啟動(dòng)就出現(xiàn)不能網(wǎng)卡不能正常顯示。
3、Ubuntu虛擬機(jī)多網(wǎng)卡配置補(bǔ)充內(nèi)容
按照以上配置Ubuntu16.04虛擬機(jī)網(wǎng)卡配置后,需要解決網(wǎng)卡啟動(dòng),多網(wǎng)段路由問題
cat >/etc/init.d/configNetwork<<EOF11ifup ens32ifup ens33ifup ens34ifup ens35route add -net 1.1.1.0 gw 1.1.1.1route add -net 2.2.2.0 gw 2.2.2.1route add -net 3.3.3.0 gw 3.3.3.1route del default gw 1.1.1.1 route add default gw 192.168.137.2 dev ens35EOF11chmod 111 /etc/init.d/configNetworksed -i '/exit 0/i/bash /etc/init.d/configNetwork' /etc/rc.local
以上配置實(shí)現(xiàn)了:
1)系統(tǒng)啟動(dòng)時(shí),運(yùn)行自定義的腳本(Ubuntu16.04啟動(dòng)執(zhí)行腳本略有差異)
2)系統(tǒng)啟動(dòng)時(shí)腳本執(zhí)行啟動(dòng)網(wǎng)卡動(dòng)作
3)系統(tǒng)實(shí)現(xiàn)多網(wǎng)段各自通信,每次啟動(dòng)修改默認(rèn)網(wǎng)關(guān)
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注