linux 設置IP DNS 網關

一, 一次修改,重啓後失敗

設置IP 
sudo ifconfig eth0 192.168.50.73 netmask 255.255.255.0 
設置網關
sudo route add default gw 192.168.50.1

設置DNS
修改/etc/resolv.conf,在其中加入 
nameserver DNS的地址1 
nameserver DNS的地址2 

二,永久修改
直接修改Ubuntu IP系統配置文件

Ubuntu IP的網絡配置文件是根目錄下:

sudo vi /etc/network/interfaces

# The primary network interface  

auto eth0  

iface eth0 inet static  

address 192.168.50.73  

gateway 192.168.50.1  

netmask 255.255.255.0  

重啓
sudo /etc/init.d/networking restart 

配置DNS

方法一、修改/etc/network/interfaces
dns-nameservers 8.8.8.8


方法二、修改/etc/resolvconf/resolv.conf.d/base文件,該文件默認是空的,在裏面寫入:
nameserver 8.8.8.8

修改完之後保存,然後執行resolvconf -u


重啓電腦

reboot
查看 ifconfig
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章