在Ubuntu系统中,可以使用以下命令来设置子网掩码:
<interface>
为实际的网络接口名称,例如eth0):sudo nano /etc/network/interfaces
iface <interface> inet static
address <ip_address>
netmask <netmask>
gateway <gateway_address>
netmask
行中,将<netmask>
替换为所需的子网掩码。例如,如果你想要设置子网掩码为255.255.255.0,可以这样写:netmask 255.255.255.0
sudo systemctl restart networking
或者sudo service networking restart
注意:在某些Ubuntu版本中,可能需要使用ifup
命令来重新启动网络接口,例如:sudo ifup <interface>
完成上述步骤后,子网掩码将被设置为所需的值。你可以通过运行以下命令来验证设置是否成功:
ifconfig <interface>
其中,<interface>
是你想要检查的网络接口名称。在输出中,你将看到Mask
字段显示设置的子网掩码值。
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: gimp在ubuntu中运行慢吗