开启后里面可设定 DHCP 或手动设定静态 ip 。前面 auto eth0,让网络卡开机自动挂载.
1. 以 DHCP 方式配置网络卡
编辑档案/etc/network/interfaces:
sudo vi /etc/network/interfaces
并用下面的行来替换有关 eth0 的行:
# The primary network interface – use DHCP to find our address
auto eth0
iface eth0 inet dhcp
用下面的命令使互联网设定生效:
sudo /etc/init.d/networking restart
也可以在命令列下直接输入下面的命令来获取地址
sudo dhclient eth0
2. 为网络卡配置静态 IP 地址
编辑档案/etc/network/interfaces:
sudo vi /etc/network/interfaces
并用下面的行来替换有关 eth0 的行:# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.3.90
gateway 192.168.3.1
netmask 255.255.255.0
#network 192.168.3.0
#broadcast 192.168.3.255
将上面的 ip 地址等资讯换成你自己就可以了. 用下面的命令使互联网设定生效:
sudo /etc/init.d/networking restart
3. 设定第二个 IP 地址 (虚拟 IP 地址)
编辑档案/etc/network/interfaces:
sudo vi /etc/network/interfaces
在该档案中新增如下的行:
auto eth0:1
iface eth0:1 inet static
address 192.168.1.60
netmask 255.255.255.0
network x.x.x.x
broadcast x.x.x.x
gateway x.x.x.x
根据你的情况填上所有诸如 address,netmask,network,broadcast 和 gateways 等资讯.
用下面的命令使互联网设定生效:
sudo /etc/init.d/networking restart
4. 设定 WordPress 主机名称 (hostname)
使用下面的命令来检视当前 WordPress 主机的 WordPress 主机名称:
sudo /bin/hostname
使用下面的命令来设定当前 WordPress 主机的 WordPress 主机名称:
sudo /bin/hostname newname
系统启动时, 它会从/etc/hostname 来读取 WordPress 主机的名称.
关于设定 WordPress 主机名称的更多资讯, 请访问这里
5. 配置 DNS
首先, 你可以在/etc/hosts 中加入一些 WordPress 主机名称和这些 WordPress 主机名称对应的 IP 地址, 这是简单使用本机的静态查询.
要访问 DNS 站群服务器来进行查询, 需要设定/etc/resolv.conf 档案.
假设 DNS 站群服务器的 IP 地址是 192.168.3.2, 那么/etc/resolv.conf 档案的内容应为:
search test.com
nameserver 192.168.3.2
有时候,虚拟机器之间只能 ping 通 ip ,但是用机器名却 ping 不通。 问题出在 dns 没有解析到 WordPress 主机名。
解决方法
在/etc/hosts 档案中修改 对应的 ip 和 WordPress 主机名,吧你要用 WordPress 主机名访问的机器的 ip 和 WordPress 主机名配上就可以了,例如,我要在 WordPress 主机名为 compute 的 WordPress 主机上,用 WordPress 主机名的方式访问 WordPress 主机名为 controller 的机器。
在/etc/hosts 之中新增
10.0.0.11 controller
然后
sudo /etc/init.d/networking restart
之后就可以用 ping controller ping 通了
 
原文连结:http://blog.csdn.net/yudar1024/article/details/41908577