溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

網(wǎng)絡(luò)管理與配置

發(fā)布時間:2020-08-11 08:37:32 來源:網(wǎng)絡(luò) 閱讀:1435 作者:儱之殤 欄目:網(wǎng)絡(luò)管理

       網(wǎng)絡(luò)管理可分為通過命令行命令實現(xiàn)和配置文件這兩種方式來實現(xiàn)。但是大多數(shù)命令行命令配置的網(wǎng)絡(luò)都是臨時的,卻是立即有效的,而通過配置文件配置的網(wǎng)絡(luò)是永久有效的(當然意外事故就拉倒吧),卻不能立即有效,這是因為網(wǎng)絡(luò)管理是功能是由內(nèi)核提供的,通過命令配置的網(wǎng)絡(luò)能夠直接被內(nèi)核接受到,而我們知道在Linux中一切皆文件,網(wǎng)絡(luò)也不外如是,只有寫入與網(wǎng)絡(luò)配置有關(guān)的文件中才能永久有效,但是這些配置文件卻不能立即被內(nèi)核識別,所以不會立即生效,那就得讓內(nèi)核重讀配置文件才行。

     下面先說說命令行命令配置網(wǎng)絡(luò)。

     ifcfg家族:

        ifconfig:用來顯示和配置網(wǎng)絡(luò)接口卡

          ifconfig或者ifconfig -a是顯示所有網(wǎng)絡(luò)接口信息的,不同的地方在于ifconfig只能顯示已經(jīng)開啟的網(wǎng)卡信息,而ifconfig -a能真正顯示所有包括開啟的和沒有開啟的網(wǎng)卡信息

          ifconfig 網(wǎng)卡名:僅顯示指定的網(wǎng)絡(luò)接口卡的信息

          ifconfig 網(wǎng)卡名 ip地址/掩碼(這是最簡單的方式)

[root@localhost ~]# ifconfig eth2
eth2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.168.0.1  netmask 255.255.0.0  broadcast 172.168.255.255
        ether 00:0c:29:f8:b5:f8  txqueuelen 1000  (Ethernet)
        RX packets 25  bytes 3168 (3.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 10  bytes 1308 (1.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
[root@localhost ~]#

        ifconfig 網(wǎng)卡名 down或者up:關(guān)閉指定網(wǎng)卡;開啟指定網(wǎng)卡

 [root@localhost ~]# ifconfig eth2 down
[root@localhost ~]# ifconfig eth2
eth2: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        inet 172.168.0.1  netmask 255.255.0.0  broadcast 172.168.255.255
        ether 00:0c:29:f8:b5:f8  txqueuelen 1000  (Ethernet)
        RX packets 28  bytes 3348 (3.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 10  bytes 1308 (1.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
[root@localhost ~]# 
雖然還顯示有地址,但是已經(jīng)沒了UP這個標志了

        ifconfig 網(wǎng)卡名  [-]特性:開啟和關(guān)閉一些特性,如下開啟和關(guān)閉混雜模式

[root@localhost ~]# ifconfig eth2 promisc
[root@localhost ~]# ifconfig eth2
eth2: flags=4354<BROADCAST,PROMISC,MULTICAST>  mtu 1500
        ether 00:0c:29:f8:b5:f8  txqueuelen 1000  (Ethernet)
        RX packets 28  bytes 3348 (3.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 10  bytes 1308 (1.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
[root@localhost ~]# ifconfig eth2 -promisc
[root@localhost ~]# ifconfig eth2
eth2: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether 00:0c:29:f8:b5:f8  txqueuelen 1000  (Ethernet)
        RX packets 28  bytes 3348 (3.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 10  bytes 1308 (1.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
[root@localhost ~]#

       route:顯示和配置路由的

        route -n:不以反解的方式顯示路由表(建議這樣)

[root@localhost ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    100    0        0 eno16777728
192.168.1.0     0.0.0.0         255.255.255.0   U     100    0        0 eno16777728
[root@localhost ~]#  
其中Destination為0.0.0.0的表示本機默認路由,而Gateway為0.0.0.0的目的網(wǎng)絡(luò)就是本機所在的網(wǎng)絡(luò),因此不需要任何路由。

        route add  <-net|-host> <網(wǎng)絡(luò)好|主機>/掩碼 gw 嚇一跳ip [dev] [網(wǎng)卡]

[root@localhost ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    100    0        0 eno16777728
0.0.0.0         192.168.1.1     0.0.0.0         UG    101    0        0 eth2
192.168.1.0     0.0.0.0         255.255.255.0   U     100    0        0 eno16777728
192.168.1.0     0.0.0.0         255.255.255.0   U     101    0        0 eth2
[root@localhost ~]# route add -net 172.16.0.0/16 gw 192.168.1.1
[root@localhost ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    100    0        0 eno16777728
0.0.0.0         192.168.1.1     0.0.0.0         UG    101    0        0 eth2
172.16.0.0      192.168.1.1     255.255.0.0     UG    0      0        0 eno16777728
192.168.1.0     0.0.0.0         255.255.255.0   U     100    0        0 eno16777728
192.168.1.0     0.0.0.0         255.255.255.0   U     101    0        0 eth2
[root@localhost ~]#  
需要注意的是下一跳地址(網(wǎng)關(guān))必須在本機任一網(wǎng)卡的網(wǎng)絡(luò)中,因為如果連網(wǎng)關(guān)都不在本機網(wǎng)絡(luò)中那么何談路由?那么就可以通過Gateway為0.0.0.0就可以知道本機任一網(wǎng)卡的網(wǎng)絡(luò)了。

        route add default dev 網(wǎng)卡:添加默認路由

[root@localhost ~]# route add default gw 172.16.0.1 dev eth2
[root@localhost ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         172.16.0.1      0.0.0.0         UG    0      0        0 eth2
0.0.0.0         0.0.0.0         0.0.0.0         U     0      0        0 eth2
0.0.0.0         192.168.1.1     0.0.0.0         UG    100    0        0 eno16777728
0.0.0.0         192.168.1.1     0.0.0.0         UG    101    0        0 eth2
172.16.0.0      192.168.1.1     255.255.0.0     UG    0      0        0 eno16777728
192.168.1.0     0.0.0.0         255.255.255.0   U     100    0        0 eno16777728
192.168.1.0     0.0.0.0         255.255.255.0   U     101    0        0 eth2

        route del -net 路由/掩碼 dev 網(wǎng)卡

[root@localhost ~]# route del -net 0.0.0.0/0 dev eth2
[root@localhost ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    100    0        0 eno16777728
0.0.0.0         192.168.1.1     0.0.0.0         UG    101    0        0 eth2
172.16.0.0      192.168.1.1     255.255.0.0     UG    0      0        0 eno16777728
192.168.1.0     0.0.0.0         255.255.255.0   U     100    0        0 eno16777728
192.168.1.0     0.0.0.0         255.255.255.0   U     101    0        0 eth2
[root@localhost ~]#

        netstat:查看網(wǎng)絡(luò)狀態(tài)信息

         常用選項有:

            -t:顯示tcp傳輸協(xié)議的

            -u:顯示udp傳輸協(xié)議的

            -n:不以反解的方式顯示(也就是數(shù)字格式)

            -l:處于監(jiān)聽狀態(tài)的

            -p:顯示相關(guān)進程和pid

            -e:擴展的格式顯示

                   -a:顯示所有狀態(tài)

[root@localhost ~]# netstat -tunlp
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      1324/sshd           
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1425/master         
tcp6       0      0 :::22                   :::*                    LISTEN      1324/sshd           
tcp6       0      0 ::1:25                  :::*                    LISTEN      1425/master    省略。。。。
其他方式還請自行組合:比如tan,uan,tnl,unl

           ifup和ifdown命令是通過讀取/etc/sysconfig/network-scripts/ifcfg-網(wǎng)卡名這個文件來開啟關(guān)閉網(wǎng)卡的,如果沒有就會報錯

     iproute家族:

        ip link:顯示和管理網(wǎng)卡信息

            ip link show(list):顯示網(wǎng)卡信息

[root@localhost ~]# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eno16777728: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 00:0c:29:f8:b5:ee brd ff:ff:ff:ff:ff:ff
3: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 00:0c:29:f8:b5:f8 brd ff:ff:ff:ff:ff:ff

            ip link set:

                ip link set [dev] 網(wǎng)卡 up(down):開啟(關(guān)閉)網(wǎng)卡

[root@localhost ~]# ip link set eth2 down
[root@localhost ~]# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eno16777728: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 00:0c:29:f8:b5:ee brd ff:ff:ff:ff:ff:ff
3: eth2: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT qlen 1000
    link/ether 00:0c:29:f8:b5:f8 brd ff:ff:ff:ff:ff:ff
[root@localhost ~]#

                ip link set [dev] 網(wǎng)卡 mtu #:設(shè)置mtu大小的

                ip link set [dev] 網(wǎng)絡(luò) name NAME:重命名

[root@localhost ~]# ip link set eth2 down
[root@localhost ~]# ip link set eth2 name eth0
[root@localhost ~]# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eno16777728: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 00:0c:29:f8:b5:ee brd ff:ff:ff:ff:ff:ff
3: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT qlen 1000
    link/ether 00:0c:29:f8:b5:f8 brd ff:ff:ff:ff:ff:ff
[root@localhost ~]#

                ip link set [dev] 網(wǎng)卡 multicast on(off):開啟(關(guān)閉)多播

        ip netns:管理網(wǎng)絡(luò)名稱空間

                ip netns add NAME:添加網(wǎng)絡(luò)空間

                ip netns list:列出網(wǎng)絡(luò)空間名

                ip netns del NAME:刪除網(wǎng)絡(luò)空間

                ip netns exec NAME COMMAND:在指定的net空間中執(zhí)行命令

[root@localhost ~]# ip link set eth2 down
[root@localhost ~]# ip link set eth2 name eth0
[root@localhost ~]# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eno16777728: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 00:0c:29:f8:b5:ee brd ff:ff:ff:ff:ff:ff
3: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT qlen 1000
    link/ether 00:0c:29:f8:b5:f8 brd ff:ff:ff:ff:ff:ff
[root@localhost ~]# ip netns add mynet
[root@localhost ~]# ip netns list 
mynet
[root@localhost ~]# ip link set eth0 netns mynet
[root@localhost ~]# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eno16777728: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 00:0c:29:f8:b5:ee brd ff:ff:ff:ff:ff:ff
[root@localhost ~]#  放到空間中的網(wǎng)卡不能被直接顯示
[root@localhost ~]# ip netns exec mynet ip link show
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN mode DEFAULT 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
3: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000
    link/ether 00:0c:29:f8:b5:f8 brd ff:ff:ff:ff:ff:ff
[root@localhost ~]#  只有這樣才能顯示出來,但是請看下面
[root@localhost ~]# ip netns del mynet
[root@localhost ~]# ip netns list
[root@localhost ~]# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eno16777728: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 00:0c:29:f8:b5:ee brd ff:ff:ff:ff:ff:ff
3: eno33554968: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 00:0c:29:f8:b5:f8 brd ff:ff:ff:ff:ff:ff
[root@localhost ~]# 
由于為了演示方面我早些改名了第二張網(wǎng)卡名,放到網(wǎng)絡(luò)空間再出來后就還原了

        ip addr;顯示和設(shè)置網(wǎng)絡(luò)地址

            ip addr add ip/掩碼 dev 網(wǎng)卡    這里的dev不能省

            ip addr del ip/掩碼 dev 網(wǎng)卡

[root@localhost ~]# ip addr add 10.0.0.1/8 dev eth2
[root@localhost ~]# ifconfig eth2
eth2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.0.1  netmask 255.0.0.0  broadcast 0.0.0.0
        ether 00:0c:29:f8:b5:f8  txqueuelen 1000  (Ethernet)
        RX packets 197  bytes 18250 (17.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 48  bytes 5004 (4.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
[root@localhost ~]#

        ip addr可以在一個網(wǎng)卡上添加多個地址,但是只有在同一個網(wǎng)段上的才有主次之分。

[root@localhost ~]# ip addr add 172.16.0.2/16 dev eth2
[root@localhost ~]# ip addr show 
3: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:f8:b5:f8 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.1/8 scope global eth2
       valid_lft forever preferred_lft forever
    inet 172.16.0.2/16 scope global eth2
       valid_lft forever preferred_lft forever
    inet 10.0.0.2/8 scope global secondary eth2
       valid_lft forever preferred_lft forever
[root@localhost ~]# 而且ifconfig只會顯示源地址
[root@localhost ~]# ifconfig eth2
eth2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.0.1  netmask 255.0.0.0  broadcast 0.0.0.0
        ether 00:0c:29:f8:b5:f8  txqueuelen 1000  (Ethernet)
        RX packets 211  bytes 19090 (18.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 48  bytes 5004 (4.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

        要想ifconfig能顯示只能加別名

[root@localhost ~]# ip addr add 192.19.0.1/24 dev eth2 lable eth2:0
Error: either "local" is duplicate, or "lable" is a garbage.
[root@localhost ~]# ip addr add 172.16.0.3/16 dev eth2 lable eth2:0
Error: either "local" is duplicate, or "lable" is a garbage.
[root@localhost ~]# ip addr add 172.16.0.3/16 dev eth2 label eth2:0
[root@localhost ~]# ifconfig eth2:0;ip addr show eth2
eth2:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.16.0.3  netmask 255.255.0.0  broadcast 0.0.0.0
        ether 00:0c:29:f8:b5:f8  txqueuelen 1000  (Ethernet)
3: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:f8:b5:f8 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.1/8 scope global eth2
       valid_lft forever preferred_lft forever
    inet 172.16.0.2/16 scope global eth2
       valid_lft forever preferred_lft forever
    inet 10.0.0.2/8 scope global secondary eth2
       valid_lft forever preferred_lft forever
    inet 172.16.0.3/16 scope global secondary eth2:0
       valid_lft forever preferred_lft forever
[root@localhost ~]#  就是在添加地址的時候加上label 網(wǎng)卡:數(shù)字(0-9)

            ip addr flush dev 網(wǎng)卡:清空所有指定網(wǎng)卡的ip地址

[root@localhost ~]# ip addr flush dev eth2
[root@localhost ~]# ip addr show eth2
3: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:f8:b5:f8 brd ff:ff:ff:ff:ff:ff
[root@localhost ~]#

        ip route:管理路由

            ip route show(list):顯示路由信息

            ip route add 網(wǎng)絡(luò)/掩碼 via 下一跳地址 [dev] 網(wǎng)卡 [src 源ip地址]

[root@localhost ~]# ip addr add 172.16.0.1/16 dev eth2
[root@localhost ~]# ip addr add 172.16.0.2/16 dev eth2
[root@localhost ~]# ip addr list eth2
3: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:f8:b5:f8 brd ff:ff:ff:ff:ff:ff
    inet 172.16.0.1/16 scope global eth2
       valid_lft forever preferred_lft forever
    inet 172.16.0.2/16 scope global secondary eth2
       valid_lft forever preferred_lft forever
[root@localhost ~]# ip route show
default via 192.168.1.1 dev eno16777728  proto static  metric 100 
172.16.0.0/16 via 192.168.1.1 dev eno16777728 
172.16.0.0/16 dev eth2  proto kernel  scope link  src 172.16.0.1 
192.168.1.0/24 dev eno16777728  proto kernel  scope link  src 192.168.1.107  metric 100 
[root@localhost ~]# ip route add 10.0.0.0/8 via 172.16.10.1 dev eth2 src 172.16.0.1
[root@localhost ~]# ip route show
default via 192.168.1.1 dev eno16777728  proto static  metric 100 
10.0.0.0/8 via 172.16.10.1 dev eth2  src 172.16.0.1 
172.16.0.0/16 via 192.168.1.1 dev eno16777728 
172.16.0.0/16 dev eth2  proto kernel  scope link  src 172.16.0.1 
192.168.1.0/24 dev eno16777728  proto kernel  scope link  src 192.168.1.107  metric 100 
[root@localhost ~]#  當網(wǎng)卡地址較多時可指定源地址

        ip route delete 網(wǎng)絡(luò)/掩碼:刪除指定路由

[root@localhost ~]# ip route del 10.0.0.0/8
[root@localhost ~]# ip route show
default via 192.168.1.1 dev eno16777728  proto static  metric 100 
172.16.0.0/16 via 192.168.1.1 dev eno16777728 
172.16.0.0/16 dev eth2  proto kernel  scope link  src 172.16.0.1 
192.168.1.0/24 dev eno16777728  proto kernel  scope link  src 192.168.1.107  metric 100 
[root@localhost ~]#

        ip route flush 網(wǎng)絡(luò)/掩碼:清除指定的網(wǎng)絡(luò)所有路由

      ss命令:與netstat很相似,但是更加強大

            除了-t,-u,-a,-l,-p,-n,-e,還有

                -m:顯示內(nèi)存用量

                -o:顯示計時器信息

            還能顯示執(zhí)行的連接狀態(tài)

                state

                    LISTEN   

                    ESTABLISHMENT

                    FIN_WAIT1:

                    FIN_WAIT2

                    SYN_SENT

                    SYN_RECV

                    CLOSED

                port:

                    dport

                    sport

    配置文件配置網(wǎng)絡(luò):

        /etc/sysconfig/network-scripts/ifcfg-網(wǎng)卡名:這個文件可以配置大量的網(wǎng)絡(luò)接口信息。

            DEVICE=指定設(shè)備要與網(wǎng)卡名一樣

            ONBOOT:[yes|no];是否開機啟動

            IPV6INIT:[yes|no]:是否初始化IPV6

            BOOTPROTO:四種(dhcp,bootp,static,none)

            UUID:此設(shè)備的UUID號

            TYPE:網(wǎng)絡(luò)類型(比如Ehernet,Bridge)

            IPADDR:ip地址

            DNS1:第一dns

            DNS2:備用dns

            NETMASK(PREFIX);掩碼

            GATEWAY:默認網(wǎng)關(guān)

            USERCTL:是否允許普通用戶控制此設(shè)備

            PEERDNS:當BOOTPROTO為dhcp時候是否允許dhcp服務(wù)器分配的dns覆蓋手動指定的dns默認是允許

            NM_CONTROLLED:是否開啟NetworkManager來管理網(wǎng)絡(luò)

            HWADDR:MAC地址

        如果要指定除了默認路由的其他路由在/etc/sysconfig/network-scripts/route-網(wǎng)卡名這個文件中配置

        有兩種方式,這里我只寫最簡單的方式

            網(wǎng)絡(luò)/掩碼長度 via ip

        一行一個路由

        DNS配置文件在:/etc/resolv.conf:    

            nameserver:DNS

        一行一個

            在/etc/hosts設(shè)置優(yōu)先DNS映射

                ip 域名 別名1 別名2.。。

            主機名設(shè)定:

                hostname:顯示主機名

                hostname HOSTNAME:設(shè)定主機名,但是重啟就會失效

                hostnamectl set-hostname HOSTNAME:永久有效

                /etc/sysconfig/network配置文件:

                    hostname=HOSTNAME

       注意:配置文件配置的必須重讀配置文件才能有效

       還有一些工具:setup,nmtui圖形界面設(shè)置網(wǎng)絡(luò),也是永久有效的,打開就會?。?/span>

       還有nmcli和ifconfig很相似。這里就不一一演示了

            

            

            

 

            

 

 

 

 

 

 

 

 

 

        

    

         

 

    

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI