linux设置静态ip及dns

debian设置静态ip

#vim /etc/network/interfaces
 auto eth0
 iface eth0 inet static
 address 219.230.144.244
 netmask 255.255.255.192
 gateway 219.230.144.254
 dns-nameservers 8.8.8.8
    重启网络服务
/etc/init.d/networking restart

centos设置静态ip

#vim /etc/sysconfig/network-scripts/ifcfg-eth0  有时会是ifcfg-em1

DEVICE="eth0"
BOOTPROTO="static"
HWADDR="00:A5:D1:EA:23:A4"
IPV6INIT="yes"
MTU="1500"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
UUID="95fd6b2b-ecfd-4cdf-9833-e3056f22d4e8"
IPADDR=192.168.8.126
NETMASK=255.255.255.0
GATEWAY=192.168.8.1
  • 配置dns解析

echo "nameserver 211.98.1.28">> /etc/resolv.conf

弄完后,记得重启网络服务

/etc/init.d/network restart

查看网络ip

ifconfig

查看网关

netstat -rn

查看nameserver

cat /etc/resolv.conf

发表评论

电子邮件地址不会被公开。 必填项已用*标注