迴路介面 loopback interface
----------------------------------------------------------------------------------------------------------
//ifconfig 替換為 ip addr
[kk@rocky ~]$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
...
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:0c:29:a8:fc:5a brd ff:ff:ff:ff:ff:ff
altname enp3s0
inet 163.32.145.69/24 brd 163.32.145.255 scope global noprefixroute ens160
valid_lft forever preferred_lft forever
...
[kk@rocky ~]$ cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
[kk@rocky ~]$ ping localhost
PING localhost(localhost (::1)) 56 data bytes
64 bytes from localhost (::1): icmp_seq=1 ttl=64 time=0.052 ms
...
IP 修改網路設定
----------------------------------------------------------------------------------------------------------
>>>>>>>>>>>>>>Tool based:
//nmcli - command-line tool for controlling NetworkManager
[kk@rocky ~]$ nmcli device status
DEVICE TYPE STATE CONNECTION
ens160 ethernet 已連線 ens160
lo loopback connected (externally) lo
[kk@rocky ~]$ nmcli device show ens160
GENERAL.DEVICE: ens160
GENERAL.TYPE: ethernet
GENERAL.HWADDR: 00:0C:29:A8:FC:5A
GENERAL.MTU: 1500
GENERAL.STATE: 100 (已連線)
GENERAL.CONNECTION: ens160
GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveC>
WIRED-PROPERTIES.CARRIER: 開
IP4.ADDRESS[1]: 163.32.145.69/24
IP4.GATEWAY: 163.32.145.254
IP4.ROUTE[1]: dst = 163.32.145.0/24, nh = 0.0.0.0, mt>
IP4.ROUTE[2]: dst = 0.0.0.0/0, nh = 163.32.145.254, m>
IP4.DNS[1]: 168.95.1.1
...
[kk@rocky ~]$ sudo nmcli connect modify ens160 ipv4.address 163.32.145.70/24
[sudo] kk 的密碼:
[kk@rocky ~]$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
...
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:0c:29:a8:fc:5a brd ff:ff:ff:ff:ff:ff
altname enp3s0
inet 163.32.145.69/24 brd 163.32.145.255 scope global noprefixroute ens160
...
[kk@rocky ~]$ sudo nmcli device connect ens160
裝置「ens160」已成功以「f8db373b-ebf8-3475-ac32-88976ada7f40」啟用。
-----------------------------
[kk@rocky ~]$ sudo nmcli connect down ens160
[kk@rocky ~]$ sudo nmcli connect up ens160
-----------------------------
[kk@rocky ~]$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
...
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:0c:29:a8:fc:5a brd ff:ff:ff:ff:ff:ff
altname enp3s0
inet 163.32.145.70/24 brd 163.32.145.255 scope global noprefixroute ens160
...
>>>>>>>>>>>>>>File based:
[kk@rocky ~]$ sudo vi /etc/NetworkManager/system-connections/ens160.nmconnection
[sudo] kk 的密碼:
[connection]
id=ens160
uuid=f8db373b-ebf8-3475-ac32-88976ada7f40
type=ethernet
autoconnect-priority=-999
interface-name=ens160
timestamp=1714117009
[ethernet]
[ipv4]
address1=163.32.145.70/24,163.32.145.254
dns=168.95.1.1;
method=manual
[ipv6]
addr-gen-mode=eui64
method=auto
[proxy]
~
~
~
[kk@rocky ~]$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
...
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
...
inet 163.32.145.69/24 brd 163.32.145.255 scope global noprefixroute ens160
[kk@rocky ~]$ sudo nmcli connect load /etc/NetworkManager/system-connections/ens160.nmconnection
[kk@rocky ~]$ sudo nmcli connect up /etc/NetworkManager/system-connections/ens160.nmconnection
>>>>>>>>>>>>>>CLI 下的圖形設計工具:
[kk@rocky ~]$ systemctl status NetworkManager
● NetworkManager.service - Network Manager
Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled; p>
Active: active (running) since Fri 2024-04-26 14:28:37 CST; 7min ago
Docs: man:NetworkManager(8)
Main PID: 755 (NetworkManager)
Tasks: 3 (limit: 48646)
Memory: 11.3M
CPU: 348ms
CGroup: /system.slice/NetworkManager.service
└─755 /usr/sbin/NetworkManager --no-daemon
[kk@rocky ~]$ ls /usr/lib/systemd/system
...
NetworkManager.service
...
#Nmtui is a part of the NetworkManager package in Linux and provides a text-based user interface to manage your network settings.
[kk@rocky ~]$ nmtui edit ens160
[kk@rocky ~]$ sudo systemctl restart NetworkManager.service
網路測試工具 ----------------------------------------------------------------------------------------------------------
>>>>>>>>>>>>>>hostnamectl 取替 hostname
[kk@rocky ~]$ hostnamectl
Static hostname: rocky.kk
...
[kk@rocky ~]$ sudo hostnamectl set-hostname BigRocky.kk
[sudo] kk 的密碼:
[kk@rocky ~]$ hostnamectl
Static hostname: BigRocky.kk
...
>>>>>>>>>>>>>>ss 取替 netstat
//ss is used to dump socket statistics. It allows showing information similar to netstat. It can display more TCP and state information than other tools.
//t:tcp協定 u:udp協定 n:不用名稱以port顯示 p:連線由哪個行程處理 l:在傾聽的連線
[kk@BigRocky ~]$ ss -tunpl
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
udp UNCONN 0 0 127.0.0.1:323 0.0.0.0:*
udp UNCONN 0 0 [::1]:323 [::]:*
udp UNCONN 0 0 [fe80::20c:29ff:fea8:fc5a]%ens160:546 [::]:*
tcp LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
tcp LISTEN 0 128 [::]:22 [::]:*
//檢視tcp連線
[kk@BigRocky ~]$ ss -t
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
ESTAB 0 64 163.32.145.69:ssh 163.32.145.99:61321
// -u, --udp Display UDP sockets.
[kk@BigRocky ~]$ ss -u
Recv-Q Send-Q Local Address:Port Peer Address:Port Process
>>>>>>>>>>>>>>tracepath 取替 traceroute/traceroute6
//tracepath, tracepath6 - traces path to a network host discovering MTU along this path
[kk@BigRocky ~]$ tracepath 168.95.1.1
1?: [LOCALHOST] pmtu 1500
1: _gateway 0.903ms
1: _gateway 0.975ms
2: 10.241.3.153 1.531ms
3:
^C
>>>>>>>>>>>>>>ip route 取替 route
[kk@BigRocky ~]$ ip route | column -t
default via 163.32.145.254 dev ens160 proto static metric 100
163.32.145.0/24 dev ens160 proto kernel scope link src 163.32.145.69 metric 100
[kk@BigRocky ~]$ ip -6 route | column -t > RouteTable.text
[kk@BigRocky ~]$ cat RouteTable.text
::1 dev lo proto kernel metric 256 pref medium
2001:288:8241:1::23c dev ens160 proto kernel metric 100 pref medium
2001:288:8241:1::/64 dev ens160 proto ra metric 100 pref medium
fe80::/64 dev ens160 proto kernel metric 1024 pref medium
default via fe80::ea1c:baff:fec9:968 dev ens160 proto ra metric 100 pref medium
>>>>>>>>>>>>>>ip neighbor 取替 arp
//ARP
//Address Resolution Protocol 位址解析協定,由已知的 IP 位址查問其相對應的網路實體位址MAC
//RARP
//Reverse Address Resolution Protocol 反向位址解析協定,由已知的網路實體位址(MAC 位址)查詢其相對應的 IP 位址
[kk@BigRocky ~]$ ip neighbor show
163.32.145.254 dev ens160 lladdr e8:1c:ba:c9:09:68 STALE
163.32.145.253 dev ens160 lladdr 4c:ae:a3:29:75:10 STALE
163.32.145.99 dev ens160 lladdr 00:e0:4c:23:07:3a REACHABLE
fe80::ea1c:baff:fec9:968 dev ens160 lladdr e8:1c:ba:c9:09:68 router STALE
>>>>>>>>>>>>>>yum、dnf
////
被淘汰的工具只是不在預設安裝所包含的,所以是可以利用 yum 把他安裝回來
Note:在 yum 中不知道套件的名稱,可以用 provides 和 list 直接搜尋 package 裡面的工具
////
//DNF is the next upcoming major version of YUM
[kk@BigRocky ~]$ dnf provides */ifconfig
Rocky Linux 9 - BaseOS 1.1 MB/s | 2.2 MB 00:02
Rocky Linux 9 - AppStream 1.6 MB/s | 7.4 MB 00:04
Rocky Linux 9 - Extras 15 kB/s | 14 kB 00:00
net-tools-2.0-0.62.20160912git.el9.x86_64 : Basic networking tools
軟體庫 :baseos
符合來源:
檔案名稱:/usr/sbin/ifconfig
[kk@BigRocky ~]$ dnf list */ifconfig
上次中介資料過期檢查:0:01:08 前,時間點為西元2024年04月29日 (週一) 13時45分38秒。
可用的軟體包
net-tools.x86_64
[kk@BigRocky ~]$ sudo dnf -y install net-tools
上次中介資料過期檢查:0:05:22 前,時間點為西元2024年04月29日 (週一) 13時54分50秒。
[kk@BigRocky ~]$ ifconfig
ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 163.32.145.69 netmask 255.255.255.0 broadcast 163.32.145.255
inet6 2001:288:8241:1:20c:29ff:fea8:fc5a prefixlen 64 scopeid 0x0<global>
inet6 2001:288:8241:1::23c prefixlen 128 scopeid 0x0<global>
inet6 fe80::20c:29ff:fea8:fc5a prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:a8:fc:5a txqueuelen 1000 (Ethernet)
RX packets 22125 bytes 14068960 (13.4 MiB)
RX errors 0 dropped 1089 overruns 0 frame 0
TX packets 6588 bytes 640794 (625.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 4 bytes 156 (156.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 4 bytes 156 (156.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[kk@BigRocky ~]$ dnf provides */dig
上次中介資料過期檢查:0:07:08 前,時間點為西元2024年04月29日 (週一) 13時45分38秒。
bind-utils-32:9.16.23-14.el9_3.4.x86_64 : Utilities for querying DNS name servers
軟體庫 :appstream
符合來源:
檔案名稱:/usr/bin/dig
[kk@BigRocky ~]$ dnf list */dig
上次中介資料過期檢查:0:09:19 前,時間點為西元2024年04月29日 (週一) 13時45分38秒。
可用的軟體包
bind-utils.x86_64
[kk@BigRocky ~]$ sudo dnf -y install bind-utils.x86_64
[sudo] kk 的密碼:
上次中介資料過期檢查:0:01:39 前,時間點為西元2024年04月29日 (週一) 13時54分50秒。
依賴關係解析完畢。
[kk@BigRocky ~]$ dig 168.95.1.1
; <<>> DiG 9.16.23-RH <<>> 168.95.1.1
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 20856
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;168.95.1.1. IN A
;; AUTHORITY SECTION:
. 2562 IN SOA a.root-servers.net. nstld.verisign-grs.com. 2024042900 1800 900 604800 86400
;; Query time: 7 msec
;; SERVER: 168.95.1.1#53(168.95.1.1)
;; WHEN: Mon Apr 29 13:58:46 CST 2024
;; MSG SIZE rcvd: 114
----------------------------------------------------------------------------------------------------------