歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux技術 >> linux 設置IP DNS 網關

linux 設置IP DNS 網關

日期:2017/3/3 12:50:59   编辑:Linux技術

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

設置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

Copyright © Linux教程網 All Rights Reserved