一、配置IP
編輯/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 auto eth0 //指定eth0網卡 iface eth0 inet static //靜態地址(動態獲取用dhcp) address 192.168.77.133 //IP地址 netmask 255.255.255.0 //子網掩碼 gateway 192.168.77.254 //默認網關
二、配置DNS
編輯/etc/resolv.conf
nameserver 8.8.8.8 nameserver 4.4.4.4
三、重啟網絡
#/etc/init.d/networking restart
或者
#service networking restart
拓展
臨時IP地址
dhclient eth0 //指定eth0網卡dhcp模式 ifconfig eth0 192.168.1.100/24 //固定IP route add default gw 192.168.1.1 //指定網關 echo nameserver 192.168.1.1 > /etc/resolv.conf //DNS