歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Ubuntu下固定ip的網卡配置

Ubuntu下固定ip的網卡配置

日期:2017/2/28 17:09:47   编辑:Linux教程

Ubuntu下固定ip的網卡配置准備工作要先了解下vi命令,隨便google下就能了解:

1。單網卡配單IP(普遍)

vi /etc/network/interface

auto eth0

iface eth0 inet static

address IP

netmask 子網掩碼

gateway 網關

2.單網卡雙IP (情況較少,多用於區分服務或者安全隱藏)

vi /etc/network/interface

auto eth0:0

iface eth0:0 inet static

address IP

netmask 子網掩碼

gateway 網關

auto eth0:1

iface eth0:1 inet static

address IP

netmask 子網掩碼

gateway 網關

3.雙網卡雙IP(應用情況較多,一般為一個內網一個為外網)

auto eth0

iface eth0 inet static

address IP

netmask 子網掩碼

gateway 網關

auto eth1

iface eth1 inet static

address IP

netmask 子網掩碼

gateway 網關

綜上,配置後保存推出,一般需要重啟下網卡才能設置生效,方法很多,比如ifdown eth0 ,ifup eth0,最直接的方法直接在終端鍵入/etc/init.d/networking restart

至於DNS,都是一樣的,如下

vi /etc/resolv.conf(實際系統默認的並不存在resolv.conf該文件,屬於自己創建)

nameserver 主DNS

nameserver 後備DNS

Copyright © Linux教程網 All Rights Reserved