目錄
2./etc/network/interfaces設置靜態ip內容
3.etc/resolv.conf 裏面設置DNS服務器,設置gateway的地址
以麒麟服務器系統爲例,設置靜態ip需要修改兩個文件
1.首先在終端中執行命令:
ip a
查看到網卡的信息,一般是有lo和eth0網卡的,我這裏的網卡是enp7s0
如果在ifconfg中沒有看到這個網卡,則需要在啓動腳本中添加
ifconfig enp7s0 up
來加載網卡。
2./etc/network/interfaces設置靜態ip內容
添加一下內容:
auto enp7s0
#iface enp7s0 inet dhcp
iface enp7s0 inet static
address 192.168.5.30
netmask 255.255.255.0
gateway 192.168.5.1
3.etc/resolv.conf 裏面設置DNS服務器,設置gateway的地址
nameserver 192.168.5.1
4.修改完成之後需要重啓網絡服務
$etc/init.d/networking restart
若是從起這個服務不起作用則需要對整個系統進行重啓,reboot。