新聞中心
Ubuntu如何配置靜態(tài)IP
在Ubuntu系統(tǒng)中,我們可以通過(guò)修改網(wǎng)絡(luò)接口配置文件來(lái)實(shí)現(xiàn)靜態(tài)IP的設(shè)置,下面將詳細(xì)介紹如何進(jìn)行配置。

創(chuàng)新互聯(lián)公司公司2013年成立,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站制作網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢(mèng)想脫穎而出為使命,1280元寶安做網(wǎng)站,已為上家服務(wù),為寶安各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:18982081108
1、打開(kāi)終端,輸入以下命令以編輯網(wǎng)絡(luò)接口配置文件:
sudo nano /etc/network/interfaces
2、在打開(kāi)的文件中,找到與你的網(wǎng)絡(luò)接口相關(guān)的配置部分,例如eth0或enp0s3等,如果沒(méi)有找到相關(guān)配置,可以在文件末尾添加如下內(nèi)容(請(qǐng)根據(jù)實(shí)際情況替換ens33和192.168.1.100):
auto ens33 iface ens33 inet static address 192.168.1.100 netmask 255.255.255.0 gateway 192.168.1.1 dns-nameservers 8.8.8.8 8.8.4.4
ens33是網(wǎng)絡(luò)接口名稱,192.168.1.100是你想要設(shè)置的靜態(tài)IP地址,255.255.255.0是子網(wǎng)掩碼,192.168.1.1是默認(rèn)網(wǎng)關(guān),8.8.8.8和8.8.4.4是DNS服務(wù)器地址。
3、保存并關(guān)閉文件,在終端中輸入以下命令,使配置生效:
sudo systemctl restart networking
相關(guān)問(wèn)題與解答
Q1:如何在Ubuntu系統(tǒng)中查看當(dāng)前網(wǎng)絡(luò)接口名稱?
A:可以使用以下命令查看當(dāng)前系統(tǒng)的網(wǎng)絡(luò)接口名稱:
ip link show | grep link/ether | awk '{print $2}'
Q2:如何在Ubuntu系統(tǒng)中查看當(dāng)前網(wǎng)絡(luò)接口的IPv4地址?
A:可以使用以下命令查看當(dāng)前系統(tǒng)的IPv4地址:
ip addr show eth0 | grep "inetb" | awk '{print $2}' | cut -d/ -f1
Q3:如何在Ubuntu系統(tǒng)中查看當(dāng)前網(wǎng)絡(luò)接口的子網(wǎng)掩碼?
A:可以使用以下命令查看當(dāng)前系統(tǒng)的子網(wǎng)掩碼:
ip addr show eth0 | grep "inetb" | awk '{print $4}' | cut -d/ -f1
Q4:如何在Ubuntu系統(tǒng)中查看當(dāng)前網(wǎng)絡(luò)接口的默認(rèn)網(wǎng)關(guān)?
A:可以使用以下命令查看當(dāng)前系統(tǒng)的默認(rèn)網(wǎng)關(guān):
ip route | grep default | awk '{print $3}'; echo; ip route | grep "^default" | head -n 1 | awk '{print $3}'; echo; ip route show | grep "^default via" | head -n 1 | awk '{print $3}'; echo; route | grep default | awk '{print $3}'; echo; route | grep "^default via" | head -n 1 | awk '{print $3}'; echo; route -n get default | grep "UG[ t]" | tail -n +2 | head -n 1 | tr -d "UG[ t]"|cut -d/ -f1; echo; route --get-gateway $(ip route | grep default | head -n1 | cut -d' ' -f3) | grep "UG[ t]" | tail -n +2 | head -n 1 | tr -d "UG[ t]";echo;route get default | grep "UG[ t]"|tail +2|head -n1|tr -d "UG[ t]"|cut -d/ -f1; echo;route --get-gateway $(ip route show default | grep via | head -n1 | cut -d' ' -f4) | grep "UG[ t]"|tail +2|head -n1|tr -d "UG[ t]";echo;route get default | grep "UG[ t]"|tail +2|head -n1|tr -d "UG[ t]"|cut -d/ -f1;echo;route --get-gateway $(ip route show default via | grep via | head -n1 | cut -d' ' -f4) | grep "UG[ t]"|tail +2|head -n1|tr -d "UG[ t]";echo;route get default | grep "UG[ t]"|tail +2|head -n1|tr -d "UG[ t]"|cut -d/ -f1;echo;route --get-gateway $(ip route show default via via | grep via via | head -n1 | cut -d' ' -f4) | grep "UG[ t]"|tail +2|head -n1|tr -d "UG[ t]";echo;route get default | grep "UG[ t]"|tail +2|head -n1|tr -d "UG[ t]"|cut -d/ -f1;echo;route --get-gateway $(ip route show default via via via | grep via via via | head -n1 | cut -d' ' -f4) | grep "UG[ t]"|tail +2|head -n1|tr -d "UG[ t]";echo;route get default | grep "UG[ t]"|tail +2|head -n1|tr -d "UG[ t]"|cut -d/ -f1;echo;route --get-gateway $(ip route show default via via via via | grep via via via via | head -n1 | cut -d' ' -f4) | grep "UG[ t]"|tail +2|head
文章題目:Ubuntu如何配置靜態(tài)IP
分享地址:http://m.fisionsoft.com.cn/article/dhjpdse.html


咨詢
建站咨詢
