真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

linux常用的網(wǎng)絡(luò)管理命令

網(wǎng)絡(luò)配置

rhel/Centos中常用的網(wǎng)絡(luò)管理命令:

創(chuàng)新互聯(lián)公司是專業(yè)的烏拉特前網(wǎng)站建設(shè)公司,烏拉特前接單;提供成都網(wǎng)站設(shè)計、網(wǎng)站建設(shè),網(wǎng)頁設(shè)計,網(wǎng)站設(shè)計,建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進行烏拉特前網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團隊,希望更多企業(yè)前來合作!

設(shè)置ip基本信息相關(guān)配置文件

5,6版本:system-config-network(setup)

          配置文件位置:/etc/sysconfig/network-scripts/ifcfg-eth[0-n]

7版本:nmcil nmtui(圖形界面)

          配置文件位置:/etc/sysconfig/network-scripts/ifcfg-en*****

 ifcfg-eth0,ifcfg-en******網(wǎng)絡(luò)配置文件信息

TYPE=Ethernet       #接口類型為以太網(wǎng)卡

BOOTPROTO=none   #獲取地址協(xié)議dhcp(自動獲取),static(手動配置),none

HWADDR=00:0C:29:75:A1:89  #網(wǎng)卡MAC

UUID=be9d332f-ae79-42b6-8040-d2d431e4e195 #網(wǎng)卡標(biāo)識

#DEVICE=eno16777736  #7系列的網(wǎng)卡名稱

DEVICE=eth0           #5,6系列的網(wǎng)卡名

ONBOOT=yes          #開機自動激活網(wǎng)卡,no不激活

IPADDR=10.76.249.91

GATEWAY=10.76.249.2

NETMASK=255.255.255.0

DNS=8.8.4.4

配置IP地址

 臨時添加IP地址,重啟后失效

ip addr add  192.168.1.150/24 dev eth0

或者

# ifconfig eth0 192.168.1.150/24 up   #重啟后會失效,第一張網(wǎng)卡為eth0,第二張為eth2依此類推

# ifconfig   

eth0     1.1 Link  encap:Ethernet  HWaddr  00:0C:29:75:A1:89 

          inet  addr:192.168.1.150   Bcast:192.168.1.255  Mask:255.255.255.0

          inet6 addr:  fe80::20c:29ff:fe75:a189/64 Scope:Link

          UP BROADCAST RUNNING  MULTICAST  MTU:1500  Metric:1

          RX packets:5682  errors:0 dropped:0 overruns:0 frame:0

          TX packets:4136  errors:0 dropped:0 overruns:0 carrier:0

          collisions:0  txqueuelen:1000

          RX bytes:412252  (402.5 KiB)  TX bytes:4464715 (4.2 MiB)

配置默認路由

# ip route add default via 192.168.1.1

#default  via192.168.1.1devinterface

 

網(wǎng)卡相關(guān)狀態(tài)查看

1.查看IP

# ip addr show

1: lo: mtu 65536 disc noqueue state  UNKNOWN

    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: eno16777736: 1UP,LOWER_UP> mtu 1500 qdisc  pfifo_fast state UP qlen 1000

    link/ether 200:0c:29:e1:c5:8a  brd ff:ff:ff:ff:ff:ff

    inet 310.76.249.91/24  brd 10.76.249.255 scope global eno16777736

       valid_lft forever  preferred_lft forever

    inet6  fe80::20c:29ff:fee1:c58a/64 scope link

       valid_lft forever  preferred_lft forever

1:網(wǎng)卡狀態(tài)已經(jīng)啟動

2:網(wǎng)卡的mac地址

3:網(wǎng)卡”eno16777736”地址

或者

# ifconfig

eth0      Link  encap:Ethernet  HWaddr  00:0C:29:75:A1:89 

          inet  addr:192.168.1.150   Bcast:192.168.1.255   Mask:255.255.255.0

          inet6 addr:  fe80::20c:29ff:fe75:a189/64 Scope:Link

          UP BROADCAST RUNNING  MULTICAST  MTU:1500  Metric:1

          RX packets:6386  errors:0 dropped:0 overruns:0 frame:0

          TX packets:4436  errors:0 dropped:0 overruns:0 carrier:0

          collisions:0  txqueuelen:1000

          RX bytes:467110  (456.1 KiB)  TX bytes:4502451 (4.2 MiB)

 

lo        Link encap:Local  Loopback 

          inet  addr:127.0.0.1  Mask:255.0.0.0

          inet6 addr: ::1/128  Scope:Host

          UP LOOPBACK  RUNNING  MTU:65536  Metric:1

          RX packets:66  errors:0 dropped:0 overruns:0 frame:0

          TX packets:66  errors:0 dropped:0 overruns:0 carrier:0

          collisions:0  txqueuelen:0

          RX bytes:3482 (3.4  KiB)  TX bytes:3482 (3.4 KiB)

或者

#nmcli dev show eth0

GENERAL.設(shè)備:                           eth0

GENERAL.類型:                           ethernet

GENERAL.硬盤:                           00:0C:29:E1:C5:8A

GENERAL.MTU:                            1500

GENERAL.狀態(tài):                           100 (連接的)

GENERAL.CONNECTION:                     eno16777736

GENERAL.CON-PATH:                        /org/freedesktop/NetworkManager/ActiveConnection/1

WIRED-PROPERTIES.容器:                 開

IP4.地址[1]:                            10.76.249.91/24

IP4.網(wǎng)關(guān):                               10.76.249.2

IP6.地址[1]:                             fe80::20c:29ff:fee1:c58a/64

IP6.網(wǎng)關(guān):                              


2.查看收發(fā)包狀態(tài)

# ip -s link show eth0

2: eth0: mtu 1500 qdisc  pfifo_fast state UP qlen 1000

    link/ether  00:0c:29:75:a1:89 brd ff:ff:ff:ff:ff:ff

    RX: bytes  packets   errors  dropped overrun  mcast  

    477844     6528      0       0       0        0     

    TX: bytes  packets   errors  dropped carrier collsns

4508951    4492     0        0       0       0     

或者

# ifconfig –s eth0

Iface   MTU Met    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg

eth0       1500   0      6459      0      0       0     4455      0       0      0 BMRU

 

3.顯示顯示主機默認路由

         

#ip route

default via 10.76.249.2 dev eth0   proto static  metric 100

10.76.249.0/24 dev eth0  proto  kernel  scope link  src 10.76.249.91  metric 100

 4.顯示連接狀態(tài)

常用到的選項

 ss和netstat使用方法相似,但是ss效率要比較高,消耗性能比較少。

選項

功能

-l

監(jiān)聽狀態(tài)的連接

-n

不解析服務(wù)名以數(shù)字顯示

-t

顯示TCP連接

-u

顯示UDP連接

-a

顯示所有狀態(tài)

-p

顯示以哪個進程發(fā)起的連接

常用的組合

-tan,-tanl, -tanlp, -uan

幾種狀態(tài)信息

 State: LISTEN(監(jiān)聽),ESTAB(已建立的鏈接)

# ss  -tna

State       Recv-Q Send-Q                       Local Address:Port本地端口                          Peer Address:Port客戶端端口

LISTEN      0       128                                      :::22                                     :::*    

LISTEN      0       128                                      *:22                                       *:*    

LISTEN      0       128                               127.0.0.1:6010                                    *:*    

LISTEN      0       128                                     ::1:6010                                   :::*    

LISTEN      0       128                               127.0.0.1:6011                                    *:*    

LISTEN      0       128                                     ::1:6011                                   :::*    

LISTEN      0       128                               127.0.0.1:6012                                    *:*    

LISTEN      0       128                                     ::1:6012                                   :::*    

LISTEN      0       128                              127.0.0.1:6013                                    *:*    

LISTEN      0       128                                     ::1:6013                                   :::*    

ESTAB       0       0                             192.168.1.106:22                          192.168.1.103:63167

ESTAB       0       0                             192.168.1.150:22                          192.168.1.103:63753  

ESTAB       0       52                            192.168.1.150:22                          192.168.1.103:54953  

ESTAB       0       0                             192.168.1.106:22                          192.168.1.103:63134

 

 

Centos/Redhat 7系列回歸傳統(tǒng)網(wǎng)卡命名

  1. 修改網(wǎng)卡文件內(nèi)容

# cat  /etc/sysconfig/network-scripts/ifcfg- eno16777736

TYPE=Ethernet

BOOTPROTO=none

DEFROUTE=yes

PEERDNS=yes

PEERROUTES=yes

NAME=eno16777736

UUID=be9d332f-ae79-42b6-8040-d2d431e4e195

#DEVICE=eno16777736   #注釋掉原來的命名

DEVICE=eth0           #傳統(tǒng)命名

ONBOOT=yes

IPADDR=10.76.249.91

GATEWAY=10.76.249.2

NETMASK=255.255.255.0

 

  1. 重命名網(wǎng)卡文件

# mv  /etc/sysconfig/network-scripts/ifcfg-eno16777736  /etc/sysconfig/network-scripts/ifcfg-eth0

  1. 編輯/etc/default/grub配置文件

# vim /etc/default/grub

GRUB_TIMEOUT=5

GRUB_DEFAULT=saved

GRUB_DISABLE_SUBMENU=true

GRUB_TERMINAL_OUTPUT="console"

#GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root  rd.lvm.lv=centos/swap rhgb quiet"  #修改前

GRUB_CMDLINE_LINUX="net.ifnames=0  rhgb quiet"  #修改后

GRUB_DISABLE_RECOVERY="true"

  1. 為grub2生成其配置文件

 

# grub2-mkconfig -o /etc/grub2.cfg

Generating grub configuration file ...

Found linux p_w_picpath: /boot/vmlinuz-3.10.0-229.el7.x86_64

Found initrd p_w_picpath: /boot/initramfs-3.10.0-229.el7.x86_64.img

Found linux p_w_picpath:  /boot/vmlinuz-0-rescue-16de415bcbd643d886010c2fe954d9cb

Found initrd p_w_picpath:  /boot/initramfs-0-rescue-16de415bcbd643d886010c2fe954d9cb.img

done

 

  1. 重啟系統(tǒng)

  2. 驗證結(jié)果

 

# ip addr show eth0

2: eth0:   mtu 1500 qdisc pfifo_fast state UP  qlen 1000

    link/ether  00:0c:29:e1:c5:8a brd ff:ff:ff:ff:ff:ff

    inet  10.76.249.91/24 brd 10.76.249.255 scope global eth0

        valid_lft forever preferred_lft forever

    inet6  fe80::20c:29ff:fee1:c58a/64 scope link

        valid_lft forever preferred_lft  forever

nmcli

nmcli:網(wǎng)絡(luò)管理命令行接口:NetworkManagerCommand-Line Interface

nmtui:網(wǎng)絡(luò)管理文本用戶接口:NetworkManager Text-User Interface

RHEL7之后的網(wǎng)絡(luò)配置命令

 

[root@localhost conf.d]# nmcli --help

Usage: nmcli [OPTIONS] OBJECT { COMMAND | help }

 

OPTIONS

  -t[erse]                                   terse  output

  -p[retty]                                  pretty  output

  -m[ode]  tabular|multiline                   output mode

  -f[ields]  |all|common    specify fields to output

  -e[scape] yes|no                           escape columns  separators in values

  -n[ocheck]                                 don't check  nmcli and NetworkManager versions

  -a[sk]                                     ask for  missing parameters

  -w[ait]                           set timeout waiting  for finishing operations

  -v[ersion]                                 show program  version

  -h[elp]                                    print this help

 

OBJECT

  g[eneral]       NetworkManager's general status and  operations

  n[etworking]    overall networking control

  r[adio]         NetworkManager radio switches

  c[onnection]    NetworkManager's connections  簡寫為c

  d[evice]        devices managed by NetworkManager簡寫為d

  a[gent]         NetworkManager secret agent or  polkit agent

 

重新加載網(wǎng)絡(luò)配置文件

[root@localhost ~]# nmcli c reload

[root@localhost ~]# nmcli c load/etc/sysconfig/network-scripts/ifcfg-eth0

配置IP地址

 

[root@localhost ~]# nmcli con mod eno16777736 ipv4.addresses '192.168.1.119/24'

                                 網(wǎng)卡名使用查看# nmcli con show

配置DNS

[root@localhost ~]# nmcli  con  mod  eno16777736  ipv4.dns  '8.8.4.4'

配置網(wǎng)關(guān)

[root@localhost ~]# nmcli  con  mod  eno16777736   ipv4.gateway  '192.168.1.1'

 

停啟用網(wǎng)卡

[root@localhost ~]# nmcli dev dis eth0

                         dis 為 disconnect 

[root@localhost ~]# nmcli con up  eth0

 

查看相關(guān)信息

[root@localhost ~]# nmcli device status

DEVICE  TYPE      STATE      CONNECTION 

eth0    ethernet  connected   eno16777736

lo      loopback  unmanaged  --        

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

 

nmtui 圖形配置界面比較簡潔

[root@localhost ~]# nmtui

linux常用的網(wǎng)絡(luò)管理命令

 

 


分享文章:linux常用的網(wǎng)絡(luò)管理命令
網(wǎng)站URL:http://weahome.cn/article/jgpdsi.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部