1. 程式人生 > >linux配置靜態ip地址

linux配置靜態ip地址

本文是在root帳號下執行的
(1)獲取網絡卡名字

ip route show
在這裡插入圖片描述
(2)配置靜態IP
開啟/etc/network/interfaces

vim /etc/network/interfaces

在裡邊加上如下內容

auto eno2
iface eno2 inet static
address 218.198.32.182
netmask 255.255.255.0
gateway 218.198.32.255
dns-nameserver 8.8.8.8

PS:
address 是ip地址
netmask 是子網掩碼
gateway 是閘道器
dns-nameserver 是DNS

(3)重啟網路服務

/etc/init.d/networking restart