命令行下直接配置:網絡
配置IP和子網掩碼:
oop
ifconfig eth0 192.168.2.1 netmask 255.255.255.0
route add default gw 192.168.2.254
打開配置文件:/etc/network/interfacesspa
配置文件中已經有了lo本地迴環網絡的配置。再在後面加上本身要配置的網卡就能夠了,下面這個例子是靜態IP的。若是是動態自動得到IP那隻要iface eth0 inet dhcp就能夠了。
.net
# interfaces(5) file used by ifup(8) and ifdown(8) auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 192.168.2.229 gateway 192.168.2.1 netmask 255.255.255.0 dns-nameservers 8.8.8.8
配置DNS的第二個方法命令行
dns是在/etc/resolv.conf文件下配置的,可是打開這個文件會看到這樣一段話:rest
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
因此,就須要修改/etc/resolvconf/resolv.conf.d/base文件code
在裏面加入nameserver 8.8.8.8,保存完後會自動更新進resolv.conf裏server
重啓網絡的方法:/etc/init.d/networking restart
blog
轉載請註明出處:http://blog.csdn.net/redstarofsleep/article/details/77497581dns
更多內容請關注: