问题描述
我已将来宾Ubuntu的网络适配器配置为以桥接模式工作,因此可以从主机SSH到它。
问题在于来宾Ubuntu IP地址不断变化。
即使它在192.168.0.4-10的极短范围内变化,每次配置Putty和其他程序仍然需要时间。
有没有一种方法可以使来宾Ubuntu的IP地址保持静态?
我的来宾操作系统具有完整的GUI。
最佳方案
以图形方式提供静态IP地址
1.转到network connections
2.然后在有线设置中编辑连接
3.添加系统的IP地址
这是下面的图片
如果您好奇,可以从上述步骤中以/etc/NetworkManager/system-connections
的配置文件找到新创建的连接
次佳方案
编辑/etc/network/interfaces
以反映如下内容:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.0.X
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.X
dns-nameservers 192.168.0.X
然后执行:
sudo /etc/init.d/networking restart
这会让您得到解决。
第三种方案
OP发布:
Setting Static IP
sudo nano /etc/network/interfaces # I use vi instead of nano
When you open up the interfaces doc, you will see something like this:
auto lo eth0 iface lo inet loopback iface eth0 inet dynamic
You want to change it to incorporate the following:
auto lo eth0 iface lo inet loopback iface eth0 inet static address xxx.xxx.xxx.xxx (enter your ip here) netmask xxx.xxx.xxx.xxx (mine was 255.255.255.0) gateway xxx.xxx.xxx.xxx (enter gateway ip here,usually the address of the router)
Save your changes and exit.
Then I needed to add some dns info to
resolv.conf
so I opened up the file like so:sudo nano /etc/resolv.conf # I use vi instead of nano
Initially this file is empty excluding a warning of “Do not put anything in here it will be overwritten”. I added the following information none the less.
This is the format:
nameserver xxx.xxx.xxx.xxx(enter your dns server ip) nameserver xxx.xxx.xxx.xxx(enter your alt dns server ip)
This is what I entered:
nameserver 8.8.8.8 nameserver 8.8.4.4
Save your changes and exit.
At this point you can either restart networking:
sudo /etc/init.d/networking restart
or reboot which is what I did:
sudo reboot
Once I was logged back in I tried the install again of
pure-ftpd
and all is good:apt-get install pure-ftpd
I hope this helps someone, I looked around for the fix and just happened upon it by accident.