1、配置静态ip和网关
sudo vim /etc/network/interfaces
虚拟机的话,可以看到:
auto lo
iface lo inet loopback
现在我们要配置名为eth0的接口,加入以下代码
auto eth0
iface eth0 inet static #这里把eth0接口设置为静态ip
address xxx.xxx.xxx.xxx #这里设置eth0的静态ip
gateway yyy.yyy.yyy.yyy #这里设置网关
netmask zzz.zzz.zzz.zzz #这里设置子网掩码
dns-nameservers aaa.aaa.aaa.aaa #这里设置DNS服务器
关于auto eth0的解释:
the word "auto" are used to identify the physical interfaces to be brought up when ifup is run with the -a option. (This option is used by the system boot scripts.) Physical interface names should follow the word "auto" on the same line.
意思就是auto关键字把我们指定名字的物理接口卡在 ifup -a 执行时”挂上去”。
配置完了之后,重启networking服务:sudo service networking restart
2、未完待续~