ubuntu shell下设置网卡ip地址,网关,dns的方法
一般ubuntu server在安装的时候,都会在ui中让你输入vip地址和网关dns等信息。
一般搬迁服务器的时候,都会重新配置服务器的ip信息。那么,在shell下怎么修改呢。今天,正好给宠物导航搬迁服务器,顺便整理记录一下。
打开/etc/network/interfaces,如果没有配置过ip,比如安装过程中跳过,则会看到
auth lo
iface lo inet loopback
auth eth0
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
broadcast 192.168.1.255
gateway 192.168.1.254
dns-nameservers 202.106.0.20
如果,已经配置过,会看到类似如下的eth0 或 eth1配置
#from iu1u.com
修改其中的信息为自己的,修改dns还要同时修改/etc/resolv.conf文件里面的dns地址。
然后重启机器,或者执行命令sudo /etc/init.d/networking restart,刷新网络接口信息即可。