ubuntu設定靜態ip

2021-10-06 03:34:56 字數 1969 閱讀 9804

vmware安裝ubuntu後,可以利用xshell連線。但是連線時我們需要知道ubuntu的ip位址,這時可以通過ifconfig命令獲取。

因為我們使用xshell連線伺服器時需要知道ip位址,我們開機獲取的ip為192.168.23.128,但是我們下一次登入分配到的ip就可能不是這個,所謂我們就需要配置ubuntu系統位址為靜態位址。

如果你輸入ifconfig後報command 'ifconfig' not found, but can be installed with錯誤,則證明你系統沒有安裝net-tools工具,現在新版本的linux已經不提供net-tools工具,自然也就找不到ifconfig命令,如果你想使用ifconfig,安裝如下:

通過以下命令編輯inte***ces檔案,如果沒有安裝vim則需先安裝vim

sudo vim /etc/network/inte***ces
配置檔案內容為:

#the loopback network inte***ce

auto lo

iface lo inet loopback

auto ens33 //網絡卡名稱,通過ifconfig命令檢視

iface ens33 inet static

address 192.168.23.128 //填入自己的ip位址

netmask 255.255.255.0 //子網掩碼,一般為這個

gateway 192.168.23.2 //閘道器

dns-nameservers 8.8.8.8 //dns

因為我們在使用ifconfig命令時獲取的網絡卡名稱為ens33,所以這裡也為ens33,其中,dns-nameservers可以設定其他運營商的dns伺服器。

如何檢視gateway有如下命令:

1、route -n

2、ip route show

3、traceroute www.baidu.com -s 100 【第一行就是自己的閘道器】

通過

sudo gedit /etc/networkmanager/networkmanager.conf
修改如下:

[main]

plugins=ifupdown,keyfile,ofono

dns=dnsmasq

[ifupdown]

managed=true

以上只是進行了靜態ip的設定,並未使設定生效,可以通過下面的命令使重啟網路服務使設定生效。

sudo service network-manager restart
有的文章是使用以下命令,但是我本人使用時沒有生效,會報failed,好像是在ubuntu裡要用network-manager

sudo /etc/init.d/networking restart
此時靜態ip設定成功,使用xshell進行連線就可以了。

ubuntu設定靜態ip

ubuntu10.04設定靜態ip 2010 12 20 09 39 step1 設定ip vi etc network inte ces 檔案內容修改為 auto eth0 iface eth0 inet static address 192.168.1.2 gateway 192.168.1.1...

ubuntu設定靜態ip

ubuntu設定靜態ip 找到檔案並作如下修改 sudo vi etc network inte ces修改如下部分 auto eth0 iface eth0 inet static address 192.168.0.117 gateway 192.168.0.1 這個位址你要確認下 閘道器是不是...

ubuntu設定靜態ip

當dhcp伺服器出問題的時候,不能自動分配ip,就需要我們手動設定靜態ip 1 vim etc network inte ces 個人不是很習慣用vim,可以換成gedit就和記事本一樣操作啦 2 修改檔案內容如下 我的不叫eth0,是enp2s0,輸入ifconfig看第乙個 auto eth0 ...