Linux下的網絡管理相關知識
阿新 • • 發佈:2018-10-12
iproute2 管理工具 ifcfg 激活 改ip 相關 pro 所有 示例 Linux下的網絡管理相關知識
down:關閉接口
addr: 地址和掩碼
link: 接口
route: 路由
ss: 狀態及統計數據查看
linux下的網絡管理工具,大致分成了三個系列,最古老的ifcfg系列、iproute2系列以及nm系列。我們會就三個命令進行分析和講解,接著會講一下更改IP地址和主機名等永久有效的方法。
一、ifcfg家族系列工具
ifconfig: 配置IP和掩碼
route: 配置路由
netstat: 網絡狀態和統計數據的查看
1. ifconfig:用於查看和配置IP地址,立即生效,但不是永久有效。
使用方法:
ifconfig [接口]
ifconfig 接口 [aftype] options | address ...
選項:
-a: 查看所有接口的IP地址
up:激活接口
(1). 查看IP地址
格式: ifconfig [接口]
示例: ~]# ifconfig -a ~]# ifconfig ~]# ifconfig eth0 [root@localhost ~]# ifconfig eth0 eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.99.20 netmask 255.255.255.0 broadcast 192.168.99.255 inet6 fe80::b107:482e:27bd:7123 prefixlen 64 scopeid 0x20<link> ether 00:15:5d:63:5a:04 txqueuelen 1000 (Ethernet) RX packets 1242117 bytes 334742873 (319.2 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 139089 bytes 15879315 (15.1 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
(2). 配置IP地址
格式:
ifconfig IFACE IP/mask [up]
ifconfig IFACE IP netmask MASK
示例:
~]# ifconfig eth0 172.16.100.11/16
# IP地址的表示方法可以使用ip/prefix的方式
~]# ifconfig eth0 172.16.100.11 netmask 255.255.255.0
#IP地址的表示方法也可以使用IP-ADDR netmask MASK的方法,IP和掩碼都可使用點分十進制的方式
2. route,可用於查看配置路由
選項及使用格式
3. netstat
二、 iproute2系列工具
ip OBJECT
link: 接口
route: 路由
ss: 狀態及統計數據查看
三、nm系列工具
network manager
nmcli: 命令行工具
nmtui: 文本窗口工具
Linux下的網絡管理相關知識