在Ubuntu系统中,设置IP地址可以通过命令行使用ifconfig或ip命令来实现
在Ubuntu系统中,设置IP地址可以通过命令行使用ifconfig
或ip
命令来实现。以下是使用这两个命令设置IP地址的步骤:
使用ifconfig命令设置IP地址:
- 打开终端,输入以下命令查看当前网络接口的信息:
ifconfig
eth0
或enp0s3
。eth0
为你的网络接口名,192.168.1.100
为你要设置的IP地址):sudoifconfigeth0192.168.1.100
eth0
为你的网络接口名,255.255.255.0
为你的子网掩码):sudoifconfigeth0netmask255.255.255.0
192.168.1.1
为你的网关地址):sudorouteadddefaultgw192.168.1.1
/etc/resolv.conf
文件:sudonano/etc/resolv.conf
在文件中添加以下内容(替换为你的DNS服务器地址):
nameserver8.8.8.8
nameserver8.8.4.4
sudoservicenetworkingrestart
使用ip命令设置IP地址:
- 打开终端,输入以下命令查看当前网络接口的信息:
ipaddrshow
eth0
或enp0s3
。eth0
为你的网络接口名,192.168.1.100
为你要设置的IP地址):sudoipaddradd192.168.1.100/24deveth0
192.168.1.1
为你的网关地址):sudoiprouteadddefaultvia192.168.1.1
/etc/resolv.conf
文件(同上ifconfig设置步骤)。完成以上步骤后,你就成功设置了Ubuntu系统的IP地址。
版权声明
本文仅代表作者观点,不代表博信信息网立场。