本文来自投稿,不代表Linux运维部落立场,如若转载,请注明出处:http://www.178linux.com/97446
網絡屬性配置2
一.ip命令
[root@centos7 ~]# rpm -qf /usr/sbin/ip 或[root@centos7 ~]# rpm -qf `which ip`
iproute-3.10.0-87.el7.x86_64 (查看某個文件是由哪個程序包安裝生成)
ip – show / manipulate routing, devices, policy routing and tun‐
nels (顯示/配置路由,設備,測驗路由,遂道)
ip [ OPTIONS ] OBJECT { COMMAND | help }
OBJEC :={link | addr | route}
link OBJEC:(link主要是管理二層信息的)
(1)ip link – network device configrration 主要有兩個子命令
show(顯示設備屬性)
[root@localhost dev]# ip link show up (公顯示啟用狀態的接口)
[root@localhost dev]# ip link show dev eth0 (僅顯示指定。。。)
set(改變設備屬性)
[root@localhost dev]# ip link set dev eth2 down(up) 激活或禁用
(2) ip addr
ip addr {add | del} interface dev string (添加刪除接口,設備)
[root@localhost ~]# ip addr show (能看到當前使用地址)
[root@localhost ~]# ip addr add 172.16.100.13/16 dev eth2 (往上添加地址,即不覆蓋原)
[root@localhost ~]# ip addr show dev eth2
link/ether 00:0c:29:15:95:d9 brd ff:ff:ff:ff:ff:ff
inet 172.20.110.100/16 brd 172.20.255.255 scope global eth2
inet 172.16.100.13/16 scope global eth2
inet6 fe80::20c:29ff:fe15:95d9/64 scope link
valid_lft forever preferred_lft forever
[root@localhost ~]# ip addr del 172.16.100.14/16 dev eth2
(3) ip route
添加路由:(這個是主機路由)
[root@centos7 ~]# ip route add 172.20.110.100 via 192.168.176.1 dev ens33
[root@centos7 ~]# ip route show
172.20.0.0/16 dev ens37 proto kernel scope link src 172.20.110.11
172.20.110.100 via 192.168.176.1 dev ens33
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1
192.168.176.0/24 dev ens33 proto kernel scope link src 192.168.176.129 m
添加網絡路由:
[root@centos7 ~]# ip route add 172.20.0.0/16 via 192.168.176.1 dev ens33
添加默認網關:
[root@centos7 ~]# ip route add default via 192.168.176.1 dev ens33
刪除路由:
[root@centos7 ~]# ip route del 172.20.110.100
清空路由:
ip route flush [dev IFACE]
[via PREFIX]
二.ss命令
查看網絡狀態的工具,類似于netstat
-l
-t
-u
-a
-e
-m(內存用量)
-p
-n
-o(顯示計時器信息)
TCP 的常見狀態:LISTEN監聽 ESTABLISHED已建立的連接 CLOSED已關閉狀態
常用組合: -tan -tal -uan -tanlp
[root@localhost ~]# ss -tan
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 :::22 :::*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 100 127.0.0.1:25 *:*
ESTAB 0 64 192.168.176.130:22 192.168.176.1:50220
赞 (0)