Linux網路配置

2021-09-08 14:59:32 字數 2132 閱讀 9552

ifconfig 命令用來檢視和配置網路裝置。

配置ip位址

#給eth0網絡卡配置ip地:192.168.120.56

ifconfig eth0 192.168.120.56

192.168.120.56 ,並加上子掩碼:255.255.255.0

ifconfig eth0 192.168.120.56 netmask 255.255.255.0

ifconfig eth0 192.168.120.56 netmask 255.255.255.0 broadcast 192.168.120.255

啟動關閉指定網絡卡

ifconfig

eth0 up

ifconfig eth0 down

在linux系統中進行網路管理,我們常常使用強大的ifconfig命令。但ifconfig命令配置的網絡卡資訊,在網絡卡重啟後機器重啟後,配置就不存在。要想將上述的配置資訊永遠的存的電腦裡,那就要修改網絡卡的配置檔案了。配置檔案中有乙個非常重要的成員:/etc/sysconfig/network-scripts/ifcfg-ethx (注:echx是指裝置名,ifcfg-eth0是預設的第乙個網路介面,如果機器中有多網路介面,那麼名字就將依 此類推ifcfg-eth1,ifcfg-eth2,ifcfg-eth3)。在ifcfg-ethx檔案配置中的網路資訊在重啟後仍然生效,在網路管理中相當有用,

#檔案路徑

/etc/sysconfig/network-scripts/ifcfg-eth0

#檔案說明

type=ethernet #網絡卡型別

device=eth0 #網絡卡介面名稱

onboot=yes #系統啟動時是否自動載入

bootproto=static #啟用位址協議 --static:靜態協議 --bootp協議 --dhcp協議

ipaddr=192.168.1.11

#網絡卡ip位址

netmask=255.255.255.0

#網絡卡網路位址

gateway=192.168.1.1

#網絡卡閘道器位址

dns1=10.203.104.41

#網絡卡dns位址

hwaddr=00:0c:29:13:5d:74

#網絡卡裝置mac位址

broadcast=192.168.1.255 #網絡卡廣播位址

方法1:重新匯入ifcfg-eth0網路配置檔案

[root@localhost ~]# /etc/init.d/network reload

shutting down inte***ce eth0: [ ok ]

shutting down loopback inte***ce: [ ok ]

bringing up loopback inte***ce: [ ok ]

bringing up inte***ce eth0: [ ok ]

方法2:重啟服務

[root@localhost ~]#service network restart

shutting down loopback inte***ce: [ ok ]

bringing up loopback inte***ce: [ ok ]

bringing up inte***ce eth0: [ ok ]

方法3:重啟服務

[root@localhost ~]# /etc/init.d/network restart

shutting down loopback inte***ce: [ ok ]

bringing up loopback inte***ce: [ ok ]

bringing up inte***ce eth0: [ ok ]

方法4:網絡卡介面關閉與啟用

[root@localhost ~]# ifdown eth0 #關閉網絡卡

[root@localhost ~]# ifup eth0 #啟動網絡卡

每天乙個linux命令(52):ifconfig命令

網路 linux網路配置

zlm ubuntu sudo ifconfig eth0 192.168.1.109 netmask 255.255.255.0 broadcast 192.168.1.255 zlm ubuntu sudo route add del default gw 192.168.1.1 新增刪除閘道器...

linux配置 網路配置

ip位址,子網掩碼,閘道器 設定ip位址,子網掩碼並啟用 ifconfig eth0 10.192.77.250 netmask 255.255.255.0 up 注 ip,掩碼,閘道器都設定到 etc sysconfig network scripts ifcfg eth0裡面了。設定多ip 可以...

linux網路管理 Linux網路配置

1.1 linux配置ip位址 1 ifconfig命令臨時配置ip位址 能不能自動獲取ip位址和dns位址,要看有沒有dhcp伺服器 win10上,輸入ipconfig all 會看到是否有dhcp伺服器 ifconfig命令 對此命令更加詳細的解說 傳送門 2 setup工具永久配置ip位址 r...