在 Ubuntu 中,您可以使用 ifconfig 命令來查看和配置網絡接口。但是,請注意,ifconfig 在較新的 Ubuntu 版本中已被棄用,建議使用 ip 命令。不過,如果您仍然想使用 ifconfig,可以按照以下步驟操作:
打開終端(快捷鍵:Ctrl + Alt + T)。
首先,使用以下命令查看所有網絡接口:
ifconfig -a
eth0 的網絡接口:sudo ifconfig eth0 down
sudo ifconfig eth0 up
sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0
將 192.168.1.100 替換為您想要的 IP 地址,將 255.255.255.0 替換為子網掩碼。
/etc/network/interfaces 文件:sudo nano /etc/network/interfaces
在文件中找到您的網絡接口(例如 eth0),然后更改 gateway 行。例如:
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
將 192.168.1.100 替換為您想要的 IP 地址,將 255.255.255.0 替換為子網掩碼,將 192.168.1.1 替換為您的網關地址。
sudo service networking restart
或者,您可以重啟計算機以使更改生效。
再次強調,建議使用 ip 命令而不是 ifconfig。如果您想使用 ip 命令,請告訴我,我可以為您提供相應的幫助。