linux下的網絡管理工具,大體分紅了三個系列,最古老的ifcfg系列、iproute2系列以及nm系列。咱們會就三個命令進行分析和講解,接着會講一下更改IP地址和主機名等永久有效的方法。linux
ifconfig: 配置IP和掩碼
route: 配置路由
netstat: 網絡狀態和統計數據的查看網絡
使用方法:
ifconfig [接口]
ifconfig 接口 [aftype] options | address ...
選項:
-a: 查看全部接口的IP地址
up:激活接口
down:關閉接口ide
(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 MASKui
示例: ~]# 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和掩碼均可使用點分十進制的方式
選項及使用格式命令行
ip OBJECT
addr: 地址和掩碼
link: 接口
route: 路由
ss: 狀態及統計數據查看code
network manager
nmcli: 命令行工具
nmtui: 文本窗口工具接口