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

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

CentOS7中網(wǎng)絡(luò)設(shè)置-創(chuàng)新互聯(lián)

查看網(wǎng)絡(luò)接口信息

  • 查看所有活動網(wǎng)絡(luò)接口的信息
    • ifconfig命令
[root@localhost ~]# ifconfig    //查看網(wǎng)絡(luò)接口信息
ens33: flags=4163  mtu 1500
        inet 192.168.144.133  netmask 255.255.255.0  broadcast 192.168.144.255
        inet6 fe80::a85a:c203:e2e:3f3c  prefixlen 64  scopeid 0x20
        ether 00:0c:29:5b:d3:a0  txqueuelen 1000  (Ethernet)
        RX packets 6139  bytes 3599390 (3.4 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2483  bytes 330519 (322.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 1  (Local Loopback)
        RX packets 84  bytes 7500 (7.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 84  bytes 7500 (7.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:d9:de:d2  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
  • 查看指定網(wǎng)絡(luò)接口信息
    • ifconfig 網(wǎng)絡(luò)接口
[root@localhost ~]# ifconfig ens33        //查看ens33網(wǎng)絡(luò)接口信息
ens33: flags=4163  mtu 1500
        inet 192.168.144.133  netmask 255.255.255.0  broadcast 192.168.144.255
        inet6 fe80::a85a:c203:e2e:3f3c  prefixlen 64  scopeid 0x20
        ether 00:0c:29:5b:d3:a0  txqueuelen 1000  (Ethernet)
        RX packets 6183  bytes 3602858 (3.4 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2505  bytes 334073 (326.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

查看主機名稱

  • 查看或設(shè)置當(dāng)前主機名
    • hostname命令
[root@localhost ~]# hostname //查看主機名稱
localhost.localdomain
  • 更改主機名稱
    • hostnamectl set-hostname [主機名稱]
[root@localhost ~]# hostnamectl set-hostname http01    //更改主機名
[root@localhost ~]# su                 //切換用戶,刷新主機名
[root@http01 ~]# hostname           //查看主機名稱
http01

查看路由表條目

  • 查看路由表
    • route命令
[root@http01 ~]# route    //查看路由表
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         gateway         0.0.0.0         UG    100    0        0 ens33
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0
192.168.144.0   0.0.0.0         255.255.255.0   U     100    0        0 ens33

查看網(wǎng)絡(luò)連接情況

[root@http01 ~]# netstat -antp      //查看以數(shù)字格式顯示全部TCP協(xié)議端口的網(wǎng)絡(luò)連接情況
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1/systemd           
tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN      1308/dnsmasq        
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      983/sshd            
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      985/cupsd           
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1292/master         
tcp        0      0 127.0.0.1:6010          0.0.0.0:*               LISTEN      4840/sshd: root@pts 
tcp        0      0 192.168.144.133:22      192.168.144.1:54734     ESTABLISHED 4840/sshd: root@pts 
tcp6       0      0 :::111                  :::*                    LISTEN      1/systemd           
tcp6       0      0 :::80                   :::*                    LISTEN      2373/httpd          
tcp6       0      0 :::22                   :::*                    LISTEN      983/sshd            
tcp6       0      0 ::1:631                 :::*                    LISTEN      985/cupsd           
tcp6       0      0 ::1:25                  :::*                    LISTEN      1292/master         
tcp6       0      0 ::1:6010                :::*                    LISTEN      4840/sshd: root@pts
[root@http01 ~]# netstat -nuap         //查看以數(shù)字格式顯示全部UDP協(xié)議端口的網(wǎng)絡(luò)連接情況
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
udp        0      0 0.0.0.0:36571           0.0.0.0:*                           788/dhclient        
udp        0      0 0.0.0.0:47956           0.0.0.0:*                           578/avahi-daemon: r 
udp        0      0 192.168.122.1:53        0.0.0.0:*                           1308/dnsmasq        
udp        0      0 0.0.0.0:67              0.0.0.0:*                           1308/dnsmasq        
udp        0      0 0.0.0.0:68              0.0.0.0:*                           788/dhclient        
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           578/avahi-daemon: r 
udp        0      0 127.0.0.1:323           0.0.0.0:*                           636/chronyd         
udp6       0      0 :::57996                :::*                                788/dhclient        
udp6       0      0 ::1:323                 :::*                                636/chronyd        
[root@http01 ~]# netstat -r     //查看路由信息,與route命令作用相同
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
default         gateway         0.0.0.0         UG        0 0          0 ens33
192.168.122.0   0.0.0.0         255.255.255.0   U         0 0          0 virbr0
192.168.144.0   0.0.0.0         255.255.255.0   U         0 0          0 ens33

網(wǎng)絡(luò)測試連接

  • 測試網(wǎng)絡(luò)通訊性

    • ping命令

    ping [主機名]/[IP地址]

[root@http01 ~]# ping 192.168.100.10        //測試網(wǎng)絡(luò)通訊
PING 192.168.100.10 (192.168.100.10) 56(84) bytes of data.
64 bytes from 192.168.100.10: icmp_seq=1 ttl=128 time=0.860 ms
64 bytes from 192.168.100.10: icmp_seq=2 ttl=128 time=0.530 ms
64 bytes from 192.168.100.10: icmp_seq=3 ttl=128 time=0.514 ms
64 bytes from 192.168.100.10: icmp_seq=4 ttl=128 time=0.465 ms

跟蹤數(shù)據(jù)包

  • 測試從當(dāng)前主機到目的主機之間經(jīng)過的網(wǎng)絡(luò)節(jié)點

    • traceroute命令

    traceroute 目標(biāo)主機地址

[root@http01 ~]# traceroute 192.168.100.10
traceroute to 192.168.100.10 (192.168.100.10), 30 hops max, 60 byte packets
 1  gateway (192.168.144.2)  0.320 ms  0.255 ms  0.223 ms
 2  * * *
 3  * * *
 4  * * *

域名解析

  • 測試DNS域名解析

    • nslookup命令

    nslookup [目標(biāo)主機地址]/[目標(biāo)DNS地址]

[root@http01 ~]# nslookup www.baidu.com
Server:     192.168.144.2
Address:    192.168.144.2#53

Non-authoritative answer:
www.baidu.com   canonical name = www.a.shifen.com.
Name:   www.a.shifen.com
Address: 183.232.231.172
Name:   www.a.shifen.com
Address: 183.232.231.174

設(shè)置網(wǎng)絡(luò)參數(shù)的方式

臨時配置——使用命令調(diào)整網(wǎng)絡(luò)參數(shù)

  • 簡單、快速,可直接修改運行中的網(wǎng)絡(luò)參數(shù)

  • 一般只適合在調(diào)試網(wǎng)絡(luò)的過程中使用

  • 重新啟動以后,所做的修改將會失效

固定設(shè)置——通過配置文件修改網(wǎng)絡(luò)參數(shù)

  • 修改各項網(wǎng)絡(luò)參數(shù)的配置文件
  • 適合對服務(wù)器設(shè)置固定參數(shù)時使用
  • 需要重載網(wǎng)絡(luò)服務(wù)或者重啟以后才會生效

設(shè)置網(wǎng)絡(luò)接口的參數(shù)

  • 臨時設(shè)置網(wǎng)絡(luò)接口的IP地址、子網(wǎng)掩碼

    ifconfig 接口名 IP地址 [netmask(子網(wǎng)掩碼)]

[root@http01 ~]# ifconfig ens33               //查看ens33接口IP地址
ens33: flags=4163  mtu 1500
        inet 192.168.144.133  netmask 255.255.255.0  broadcast 192.168.144.255
        inet6 fe80::a85a:c203:e2e:3f3c  prefixlen 64  scopeid 0x20
        ether 00:0c:29:5b:d3:a0  txqueuelen 1000  (Ethernet)
        RX packets 42  bytes 3966 (3.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 86  bytes 9346 (9.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@http01 ~]# ifconfig ens33 192.168.144.138/24    //設(shè)置臨時IP地址
[root@http01 ~]# ifconfig ens33                     //查看是否成功設(shè)置
ens33: flags=4163  mtu 1500
        inet 192.168.144.138  netmask 255.255.255.0  broadcast 192.168.144.255
        inet6 fe80::a85a:c203:e2e:3f3c  prefixlen 64  scopeid 0x20
        ether 00:0c:29:5b:d3:a0  txqueuelen 1000  (Ethernet)
        RX packets 2660  bytes 3613441 (3.4 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 844  bytes 57384 (56.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
[root@http01 ~]# systemctl restart network           //重啟網(wǎng)絡(luò)服務(wù)
[root@http01 ~]# ifconfig ens33                 //查看IP地址
ens33: flags=4163  mtu 1500
        inet 192.168.144.133  netmask 255.255.255.0  broadcast 192.168.144.255
        inet6 fe80::a85a:c203:e2e:3f3c  prefixlen 64  scopeid 0x20
        ether 00:0c:29:5b:d3:a0  txqueuelen 1000  (Ethernet)      //設(shè)置的IP地址失效  
        RX packets 2708  bytes 3618185 (3.4 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 894  bytes 63590 (62.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
  • 設(shè)置固定網(wǎng)絡(luò)接口的IP地址、子網(wǎng)掩碼

    設(shè)置固定的網(wǎng)絡(luò)接口IP地址、子網(wǎng)掩碼,需要在網(wǎng)絡(luò)接口的配置文件中更改配置文件來完成。

  • 網(wǎng)絡(luò)接口配置文件

    /etc/sysconfig/network-scripts/

  • 重啟network網(wǎng)絡(luò)服務(wù)

    systemctl restart network

[root@http01 ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33  //進入編輯網(wǎng)卡配置文件

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=staticl          //將DHCP更改為staticl
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=2ef6b862-5201-48c5-a450-23b3720ab3a0
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.144.138          //輸入要設(shè)定的IP地址
NETMAS=255.255.255.0         //輸入子網(wǎng)掩碼
GATEWAY=192.168.144.1        //輸入網(wǎng)關(guān)地址
[root@http01 ~]# systemctl restart network    //重啟網(wǎng)絡(luò)服務(wù)
[root@http01 ~]# ifconfig ens33  
ens33: flags=4163  mtu 1500
        inet 192.168.144.138  netmask 255.255.255.0  broadcast 192.168.144.255
        inet6 fe80::20c:29ff:fe5b:d3a0  prefixlen 64  scopeid 0x20
        ether 00:0c:29:5b:d3:a0  txqueuelen 1000  (Ethernet)   //地址設(shè)置成功
        RX packets 3832  bytes 3715216 (3.5 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1558  bytes 160876 (157.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
  • 禁用或者重新激活網(wǎng)卡

    • 禁用網(wǎng)卡

    ifconfig 網(wǎng)絡(luò)接口 down

    • 重新激活網(wǎng)卡
      ifconfig 網(wǎng)絡(luò)接口 up
[root@localhost ~]# ifconfig ens33 down              //禁用網(wǎng)卡
[root@localhost ~]# ifconfig ens33              //查看網(wǎng)卡信息,無IP地址連接
ens33: flags=4098  mtu 1500
        ether 00:0c:29:5b:d3:a0  txqueuelen 1000  (Ethernet)
        RX packets 459  bytes 495831 (484.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 240  bytes 22865 (22.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
[root@localhost ~]# ifconfig ens33 up            //重新激活網(wǎng)卡
[root@localhost ~]# ifconfig ens33            //查看網(wǎng)卡信息,成功獲取IP地址
ens33: flags=4163  mtu 1500
        inet 192.168.144.133  netmask 255.255.255.0  broadcast 192.168.144.255
        inet6 fe80::a85a:c203:e2e:3f3c  prefixlen 64  scopeid 0x20
        ether 00:0c:29:5b:d3:a0  txqueuelen 1000  (Ethernet)
        RX packets 463  bytes 496409 (484.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 264  bytes 26630 (26.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
  • 虛擬網(wǎng)絡(luò)接口

    • 虛擬網(wǎng)絡(luò)接口是指共用一個網(wǎng)卡,同一網(wǎng)卡可以配多個IP地址,不管訪問哪一個IP地址都能訪問同一服務(wù)器。(當(dāng)不想用虛擬網(wǎng)卡時直接禁用虛擬網(wǎng)卡即可)

    ifconfig 接口名:序號 IP地址

[root@localhost ~]# ifconfig ens33:0 192.168.144.140 //在ens33網(wǎng)卡上添加虛擬網(wǎng)卡,序列號為0
[root@localhost ~]# ifconfig                 //查看網(wǎng)卡信息
ens33: flags=4163  mtu 1500
        inet 192.168.144.133  netmask 255.255.255.0  broadcast 192.168.144.255
        inet6 fe80::a85a:c203:e2e:3f3c  prefixlen 64  scopeid 0x20
        ether 00:0c:29:5b:d3:a0  txqueuelen 1000  (Ethernet)
        RX packets 653  bytes 512686 (500.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 373  bytes 39897 (38.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens33:0: flags=4163  mtu 1500  //創(chuàng)建的虛擬網(wǎng)卡
        inet 192.168.144.140  netmask 255.255.255.0  broadcast 192.168.144.255
        ether 00:0c:29:5b:d3:a0  txqueuelen 1000  (Ethernet)

lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 1  (Local Loopback)
        ...//省略部分內(nèi)容...

設(shè)置路由記錄

  • 添加到指定網(wǎng)段的路由記錄

    • route add -net 網(wǎng)段地址 gw IP地址(網(wǎng)關(guān))
  • 刪除到指定網(wǎng)段的路由記錄

    • route del -net 網(wǎng)段地址
  • 刪除路由表中默認(rèn)網(wǎng)關(guān)記錄

    • route del default gw IP地址
  • 向路由表中添加默認(rèn)網(wǎng)關(guān)記錄
    • route add default gw IP地址
[root@localhost ~]# route         //查看路由表
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         gateway         0.0.0.0         UG    100    0        0 ens33
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0
192.168.144.0   0.0.0.0         255.255.255.0   U     100    0        0 ens33
[root@localhost ~]# route add -net 192.168.100.0/24 gw 192.168.144.1  //添加網(wǎng)段
[root@localhost ~]# route     //查看路由表是否添加網(wǎng)段
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         gateway         0.0.0.0         UG    100    0        0 ens33
192.168.100.0   192.168.144.1   255.255.255.0   UG    0      0        0 ens33
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0
192.168.144.0   0.0.0.0         255.255.255.0   U     100    0        0 ens33
[root@localhost ~]# route del -net 192.168.100.0/24  //刪除添加的網(wǎng)段
[root@localhost ~]# route              //查看路由表,看添加的網(wǎng)段是否刪除
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         gateway         0.0.0.0         UG    100    0        0 ens33
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0
192.168.144.0   0.0.0.0         255.255.255.0   U     100    0        0 ens33
[root@localhost ~]# route add default gw 192.168.144.1  //添加默認(rèn)網(wǎng)關(guān)
[root@localhost ~]# route          //查看是否成功添加默認(rèn)網(wǎng)關(guān)
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         gateway         0.0.0.0         UG    0      0        0 ens33
default         gateway         0.0.0.0         UG    100    0        0 ens33
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0
192.168.144.0   0.0.0.0         255.255.255.0   U     100    0        0 ens33
[root@localhost ~]# route del default gw 192.168.144.1   //刪除添加的默認(rèn)網(wǎng)關(guān)
[root@localhost ~]# route              //查看路由表是否成功刪除
Kernel IP routing table 
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         gateway         0.0.0.0         UG    100    0        0 ens33
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0
192.168.144.0   0.0.0.0         255.255.255.0   U     100    0        0 ens33

主機名稱配置文件

  • 保存全局網(wǎng)絡(luò)設(shè)置,主要包括主機名信息

    /etc/sysconfig/network//etc/hostname

    CentOS 6中若要修改主機名可以執(zhí)行“vim /etc/sysconfig/network”修改配置文件,而在CentOS 7中我們可以執(zhí)行“vim /etc/hostname”就可以去修改主機名配置文件了。

[root@localhost ~]# vim /etc/hostname   //進入編輯主機名配置文件

localhost.localdomain       //當(dāng)前主機名   如若修改可以直接在編輯器修改主機名
~                                                                                         
~                                                                                         
~                                                                                         
~                                                                                         
~                                                                                         
~

域名解析配置文件

  • 指定為本機體提供DNS解析的服務(wù)器地址(對改文件的修改將會立即生效)

    • /etc/resolv.conf
  • 格式
    • nameserver IP地址
[root@localhost ~]# vim /etc/resolv.conf 

# Generated by NetworkManager
search localdomain
nameserver 192.168.144.2
~                                                                                         
~                                                                                         
~                                                                                         
~

本地主機映射文件

在本地主機映射文件中添加映射記錄,當(dāng)訪問添加的記錄網(wǎng)站時,將會直接向添加的映射記錄IP地址發(fā)送web請求,省略了向DNS服務(wù)器解析IP地址的過程。

  • 保存主機名與IP地址的映射記錄

    • /etc/hosts
  • hosts文件和DNS服務(wù)器的比較
    • 默認(rèn)情況下,系統(tǒng)首先從hosts文件查找解析記錄
    • hosts文件只對當(dāng)前的主機有效
    • hosts文件可減少DNS查詢過程,從而加快訪問速度

補充內(nèi)容:

雙網(wǎng)卡的建立

在日常生產(chǎn)活動中難免會遇到需要建立雙網(wǎng)卡的情況,這里我們來看看如何建立雙網(wǎng)卡

1、首先在虛擬機Linux操作系統(tǒng)中添加一塊物理網(wǎng)卡,然后查看網(wǎng)絡(luò)接口信息,確定是否成功添加網(wǎng)絡(luò)

CentOS 7中網(wǎng)絡(luò)設(shè)置CentOS 7中網(wǎng)絡(luò)設(shè)置

[root@localhost ~]# ifconfig      //查看網(wǎng)接口信息
ens33: flags=4163  mtu 1500
        inet 192.168.144.133  netmask 255.255.255.0  broadcast 192.168.144.255
        inet6 fe80::a85a:c203:e2e:3f3c  prefixlen 64  scopeid 0x20
        ether 00:0c:29:5b:d3:a0  txqueuelen 1000  (Ethernet)
        RX packets 3415  bytes 740748 (723.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1725  bytes 201799 (197.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens36: flags=4163  mtu 1500    //新添加的物理網(wǎng)卡
        inet 192.168.144.141  netmask 255.255.255.0  broadcast 192.168.144.255
        inet6 fe80::deb1:3cec:3e26:5ec2  prefixlen 64  scopeid 0x20
        ether 00:0c:29:5b:d3:aa  txqueuelen 1000  (Ethernet)
        RX packets 85  bytes 6069 (5.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 30  bytes 4667 (4.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

2、這個時候我們查看網(wǎng)卡配置文件目錄,看是否有添加的網(wǎng)卡配置文件

[root@localhost ~]# cd /etc/sysconfig/network-scripts/   //進入網(wǎng)卡配置文件目錄
[root@localhost network-scripts]# ls       //查看,這個時候時沒有新添加的網(wǎng)卡ens36的配置文件的
ifcfg-ens33  ifdown-ipv6    ifdown-TeamPort  ifup-ippp   ifup-routes       network-functions
ifcfg-lo     ifdown-isdn    ifdown-tunnel    ifup-ipv6   ifup-sit          network-functions-ipv6
ifdown       ifdown-post    ifup             ifup-isdn   ifup-Team
ifdown-bnep  ifdown-ppp     ifup-aliases     ifup-plip   ifup-TeamPort
ifdown-eth   ifdown-routes  ifup-bnep        ifup-plusb  ifup-tunnel
ifdown-ib    ifdown-sit     ifup-eth         ifup-post   ifup-wireless
ifdown-ippp  ifdown-Team    ifup-ib          ifup-ppp    init.ipv6-global

3、因為沒有ens36網(wǎng)卡的配置文件,我們就沒有辦法給ens36指定固定的地址的。下面我們就把ens36與ens33這兩個網(wǎng)卡全部設(shè)為僅主機相連模式,然后再查看網(wǎng)絡(luò)接口信息。

CentOS 7中網(wǎng)絡(luò)設(shè)置

[root@localhost ~]# ifconfig            //查看網(wǎng)絡(luò)接口信息
ens33: flags=4163  mtu 1500   //無獲取IP地址
        inet6 fe80::a85a:c203:e2e:3f3c  prefixlen 64  scopeid 0x20
        ether 00:0c:29:5b:d3:a0  txqueuelen 1000  (Ethernet)
        RX packets 3578  bytes 754392 (736.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1812  bytes 215065 (210.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens36: flags=4163  mtu 1500   //無發(fā)獲取IP地址
        inet6 fe80::deb1:3cec:3e26:5ec2  prefixlen 64  scopeid 0x20
        ether 00:0c:29:5b:d3:aa  txqueuelen 1000  (Ethernet)
        RX packets 160  bytes 12321 (12.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 48  bytes 7865 (7.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

我在這里無法獲取IP地址是因為的VMware虛擬機中DHCP服務(wù)關(guān)掉了,所以無法獲取地址。

CentOS 7中網(wǎng)絡(luò)設(shè)置

4、這個時候我們就給這兩個物理網(wǎng)卡配固定地址

[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33  //編輯網(wǎng)卡信息

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static               //dhcp更改為static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=2ef6b862-5201-48c5-a450-23b3720ab3a0
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.100.10         //輸入配置IP地址
NETMAS=255.255.255.0          //輸入配置子網(wǎng)掩碼
GATEWAY=192.168.100.0         //輸入配置網(wǎng)關(guān)
~                                                                                         
~                                                                                         
~                                                                                         
~                                                                                         
~                                                                                         
~                                                                                         
~                                                                                         
:wq
[root@localhost ~]# service network restart       //重啟網(wǎng)絡(luò)服務(wù)
Restarting network (via systemctl):                        [  確定  ]
[root@localhost ~]# ifconfig          //查看網(wǎng)絡(luò)接口信息,看配置的地址是否生效
ens33: flags=4163  mtu 1500
        inet 192.168.100.10  netmask 255.255.255.0  broadcast 192.168.100.255
        inet6 fe80::a85a:c203:e2e:3f3c  prefixlen 64  scopeid 0x20
        ether 00:0c:29:5b:d3:a0  txqueuelen 1000  (Ethernet)
        RX packets 3642  bytes 771191 (753.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1948  bytes 239617 (234.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

下面我們進入網(wǎng)卡配置文件目錄,這時候時沒有ens36網(wǎng)卡的配置文件的,我們就需要把ens33的配置文件直接復(fù)制,更改為ens36的配置文件,然后把配置文件的內(nèi)容更改就可以了

[root@localhost ~]# cd /etc/sysconfig/network-scripts/    //進入網(wǎng)卡配置文件目錄
[root@localhost network-scripts]# ls     //查看
ifcfg-ens33  ifdown-isdn      ifup          ifup-plip      ifup-tunnel
ifcfg-lo     ifdown-post      ifup-aliases  ifup-plusb     ifup-wireless
ifdown       ifdown-ppp       ifup-bnep     ifup-post      init.ipv6-global
ifdown-bnep  ifdown-routes    ifup-eth      ifup-ppp       network-functions
ifdown-eth   ifdown-sit       ifup-ib       ifup-routes    network-functions-ipv6
ifdown-ib    ifdown-Team      ifup-ippp     ifup-sit
ifdown-ippp  ifdown-TeamPort  ifup-ipv6     ifup-Team
ifdown-ipv6  ifdown-tunnel    ifup-isdn     ifup-TeamPort
[root@localhost network-scripts]# cp -p ifcfg-ens33 ifcfg-ens36  //復(fù)制ens33配置文件
[root@localhost network-scripts]# ls           //查看
ifcfg-ens33  ifdown-ipv6      ifdown-tunnel  ifup-isdn    ifup-TeamPort
ifcfg-ens36  ifdown-isdn      ifup           ifup-plip    ifup-tunnel
ifcfg-lo     ifdown-post      ifup-aliases   ifup-plusb   ifup-wireless
ifdown       ifdown-ppp       ifup-bnep      ifup-post    init.ipv6-global
ifdown-bnep  ifdown-routes    ifup-eth       ifup-ppp     network-functions
ifdown-eth   ifdown-sit       ifup-ib        ifup-routes  network-functions-ipv6
ifdown-ib    ifdown-Team      ifup-ippp      ifup-sit
ifdown-ippp  ifdown-TeamPort  ifup-ipv6      ifup-Team
[root@localhost network-scripts]# vim ifcfg-ens36   //進入編輯ens36配置文件

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens36                            //更改33為36
DEVICE=ens36                          //更改33為36
ONBOOT=yes
IPADDR=192.168.10.10                  //更改IP地址網(wǎng)段
NETMAS=255.255.255.0
GATEWAY=192.168.10.0                   //更改網(wǎng)關(guān)地址
~                                                                                         
~                    注意,配置文件里面的UUID條目要刪掉,讓系統(tǒng)自動識別添加就可以了(UUID不可相同 ) 
~                                                                                         
~                                                                                         
~                                                                                         
~                                                                                         
~                                                                                         
~                                                                                         
:wq

[root@localhost network-scripts]# service network restart   //重新啟動網(wǎng)絡(luò)服務(wù)
Restarting network (via systemctl):                        [  確定  ]
[root@localhost network-scripts]# ifconfig      //查看網(wǎng)卡信息
ens33: flags=4163  mtu 1500   
        inet 192.168.100.10  netmask 255.255.255.0  broadcast 192.168.100.255
        inet6 fe80::a85a:c203:e2e:3f3c  prefixlen 64  scopeid 0x20
        ether 00:0c:29:5b:d3:a0  txqueuelen 1000  (Ethernet)
        RX packets 3705  bytes 788818 (770.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1978  bytes 243934 (238.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens36: flags=4163  mtu 1500  //成功獲取IP地址
        inet 192.168.10.10  netmask 255.255.255.0  broadcast 192.168.10.255
        inet6 fe80::f6eb:23e3:3afb:fef4  prefixlen 64  scopeid 0x20
        ether 00:0c:29:5b:d3:aa  txqueuelen 1000  (Ethernet)
        RX packets 248  bytes 33751 (32.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 280  bytes 49781 (48.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。


網(wǎng)站標(biāo)題:CentOS7中網(wǎng)絡(luò)設(shè)置-創(chuàng)新互聯(lián)
本文網(wǎng)址:http://weahome.cn/article/jehoo.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部