If you have a home network with several computers, assigning them static IP addresses can make troubleshooting easier. Today we take a look at switching from DHCP to a static IP in Ubuntu.
如果您的家庭网络中有多台计算机,则为它们分配静态IP地址可以使故障排除更加容易。 今天,我们来看看在Ubuntu中从DHCP切换到静态IP的过程。
Assign a Static IP
分配静态IP
Using Static IPs prevents address conflicts between machines and can allow easier access to them. If you have a small home network and are satisfied with the machines getting their IP address automatically via DHCP, there won’t be anything gained by using static addresses.
使用静态IP可以防止计算机之间的地址冲突,并可以更轻松地访问它们。 如果您的家庭网络很小,并且对通过DHCP自动获取IP地址的计算机感到满意,那么使用静态地址将不会有任何好处。
Using Static IPs isn’t necessarily for the average user, but if you’re a geek who wants to know the address assigned to each machine, it can allow for faster troubleshooting.
普通用户不一定要使用静态IP,但是如果您是一个极客,希望知道分配给每台计算机的地址,则可以更快地进行故障排除。
To change your Ubuntu machine to a Static IP go to System \ Preferences \ Network Connections.
要将Ubuntu计算机更改为静态IP,请转到系统\首选项\网络连接。
![1whslinux2 1whslinux2](https://i-blog.csdnimg.cn/blog_migrate/1c7471a31c09307b73fe52783d9328ec.png)
In our example, we’re on a wired system so click on the Wired tab, then select Auto eth0 and click on Edit.
在我们的示例中,我们使用的是有线系统,因此单击“有线”选项卡,然后选择“自动eth0”并单击“编辑”。
![2connectserver2 2connectserver2](https://i-blog.csdnimg.cn/blog_migrate/3defc6ae83af49ca60faa5ba690b4a29.png)
Select the IPv4 settings tab, change Method to Manual, click the Add button. Then type in the Static IP Address, Subnet Mask, DNS Servers, and Default Gateway. Then click Apply when you’re finished.
选择“ IPv4设置”选项卡,将“方法”更改为“手动”,然后单击“添加”按钮。 然后键入“静态IP地址”,“子网掩码”,“ DNS服务器”和“默认网关”。 完成后,单击“应用”。
Make sure to hit Enter after typing in the Default Gateway otherwise it will revert back to 0.0.0.0
输入默认网关后,请确保按Enter键,否则它将恢复为0.0.0.0。
![3staticip[3] 3staticip[3]](https://i-blog.csdnimg.cn/blog_migrate/325e7b4c82d10d2605190d2a3a5f36ca.png)
You’ll need to enter in your admin password before the changes go into affect.
在更改生效之前,您需要输入管理员密码。
![4static2 4static2](https://i-blog.csdnimg.cn/blog_migrate/86aa30112f138d7218d705ea2c5a2a88.png)
To verify the changes have been made successfully launch a Terminal session and type in ifconfig at the command prompt, or follow these directions. You also might want to ping the address from another machine to make sure everything is communicating.
要验证是否已成功进行更改,请启动终端会话,然后在命令提示符下键入ifconfig ,或按照以下说明进行操作 。 您可能还想从另一台计算机ping地址,以确保一切正常。
![sshot-2010-06-10-[00-52-30][2] sshot-2010-06-10-[00-52-30][2]](https://i-blog.csdnimg.cn/blog_migrate/ce237bfd2b5cd87dac5c16a0352a5269.png)
If you want to assign a Static IP to your Windows machines, check out our article on how to assign a Static IP on Windows systems (make sure to browse the comments as our readers have some good suggestions).
如果要为Windows机器分配静态IP,请查看有关如何在Windows系统上分配静态IP的文章(请确保浏览注释,因为我们的读者有很好的建议)。
Whether you have a small office or home network set up with a server and several machines, using a Static IP on each device can help you manage them easily. Again, it isn’t for everyone as it really depends on how your network is setup and the way you use it.
无论您是通过服务器还是多台计算机来安装小型办公室或家庭网络,在每台设备上使用静态IP都可以帮助您轻松管理它们。 同样,它并不适合所有人,因为它实际上取决于网络的设置方式和使用方式。
翻译自: https://www.howtogeek.com/howto/19541/how-to-assign-a-static-ip-to-an-ubuntu-10.04-desktop-computer/