CentOS 網路配置檢視網絡卡資訊
[root@localhost ~]# ip a s 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 valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:0c:29:f9:6c:67 brd ff:ff:ff:ff:ff:ff inet 192.168.159.129/24 brd 192.168.159.255 scope global noprefixroute dynamic ens33 valid_lft 1225sec preferred_lft 1225sec inet6 fe80::2227:1ed6:6865:8578/64 scope link noprefixroute valid_lft forever preferred_lft forever
檢視網絡卡流量 [root@localhost ~]# ip -s link show ens33 2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000 link/ether 00:0c:29:f9:6c:67 brd ff:ff:ff:ff:ff:ff RX: bytes packets errors dropped overrun mcast 541259676 441861 0 0 0 0 TX: bytes packets errors dropped carrier collsns 8109079 133817 0 0 0 0
系統開機到現在總共收發字、資料包數量
netstat命令# 列印網路連線、路由表、網路介面統計 # -s 顯示各種協議資料統計資訊 # -n 使用數字形式的IP、埠號、使用者ID替代主機、協議、使用者等名稱資訊。 # -p 顯示程序名稱及對應程序ID號 # -l 僅顯示正在監聽的sockets介面資訊 # -u 檢視upd連線資訊 # -t 檢視tcp連線資訊 [root@localhost ~]# netstat -nutlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1272/sshd tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1271/cupsd tcp6 0 0 :::22 :::* LISTEN 1272/sshd tcp6 0 0 ::1:631 :::* LISTEN 1271/cupsd udp 0 0 0.0.0.0:904 0.0.0.0:* 735/rpcbind udp 0 0 0.0.0.0:50225 0.0.0.0:* 777/avahi-daemon: r udp6 0 0 :::904 :::* 735/rpcbind udp6 0 0 :::111 :::* 735/rpcbind [root@localhost ~]# netstat -s Ip: 147945 total packets received 0 forwarded 0 incoming packets discarded 147577 incoming packets delivered 134128 requests sent out 44 outgoing packets dropped 346 dropped because of missing route ... 省略 ...
命令列設定網路引數網路介面引數---ifconfig
# 顯示全量網絡卡資訊 [root@localhost ~]# ifconfig ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.159.129 netmask 255.255.255.0 broadcast 192.168.159.255 inet6 fe80::2227:1ed6:6865:8578 prefixlen 64 scopeid 0x20<link> 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> # 顯示指定網絡卡資訊 [root@localhost ~]# ifconfig ens33 ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.159.129 netmask 255.255.255.0 broadcast 192.168.159.255 inet6 fe80::2227:1ed6:6865:8578 prefixlen 64 scopeid 0x20<link> # 關閉網絡卡 [root@localhost ~]# ifconfig ens33 down # 關閉後檢視網絡卡資訊 [root@localhost ~]# ifconfig 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) # 開啟網絡卡 [root@localhost ~]# ifconfig ens33 up # 開啟後檢視網絡卡資訊 [root@localhost ~]# ifconfig ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.159.129 netmask 255.255.255.0 broadcast 192.168.159.255 inet6 fe80::2227:1ed6:6865:8578 prefixlen 64 scopeid 0x20<link> 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>
# 顯示系統主機名稱[root@localhost ~]# hostnamectl Static hostname: localhost.localdomain Icon name: computer-vm Chassis: vm Machine ID: f17c01b36a694a24ac23d87c18bcd8be Boot ID: cebdc9dbb5804db187c08c5dcbfcabf3 Virtualization: vmware Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-1160.el7.x86_64 Architecture: x86-64# 設定主機名稱[root@localhost ~]# hostnamectl set-hostname moke# 檢視主機名稱[root@localhost ~]# hostnamectl Static hostname: moke Icon name: computer-vm Chassis: vm Machine ID: f17c01b36a694a24ac23d87c18bcd8be Boot ID: cebdc9dbb5804db187c08c5dcbfcabf3 Virtualization: vmware Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-1160.el7.x86_64 Architecture: x86-64
路由引數---route
# 顯示當前路由表[root@localhost ~]# route -nKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface0.0.0.0 192.168.159.2 0.0.0.0 UG 100 0 0 ens33192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0192.168.159.0 0.0.0.0 255.255.255.0 U 100 0 0 ens33# 新增預設路由閘道器[root@localhost ~]# route add default gw 192.168.159.2# 新增指定網段閘道器[root@localhost ~]# route add -net 172.16.0.0/16 gw 192.168.159.2 dev ens33# 刪除預設閘道器[root@localhost ~]# route del default gw 192.168.159.2# 刪除指定網段閘道器[root@localhost ~]# route del -net 172.16.0.0/16
檔案修改網路引數
# 網絡卡配置修改[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33 # 重啟網路服務使新設定生效[root@localhost ~]# systemctl restart network# 主機名修改[root@localhost ~]# vim /etc/hostname# 路由資訊設定(預設檔案不存在,配置時建立)[root@localhost network-scripts]# vim /etc/sysconfig/network-scripts/route-ens33# 重啟網路服務使新設定生效[root@localhost ~]# systemctl restart network
感謝閱讀,歡迎交流
最新評論