day30-第一階段知識(shí)點(diǎn)的復(fù)習(xí)

1 ifconfig:查看設(shè)置IP

1)查看網(wǎng)卡設(shè)備IP

[root@oldboy ~]# ifconfig      <===查看所有網(wǎng)卡的IP
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.0.201  netmask 255.255.255.0  broadcast 10.0.0.255
        inet6 fe80::ee8d:f3d3:c194:40b4  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:be:01:b3  txqueuelen 1000  (Ethernet)
        RX packets 31  bytes 4411 (4.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 50  bytes 6401 (6.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

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)
        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

[root@oldboy ~]# ifconfig eth0      <===查看指定網(wǎng)卡的IP
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.0.201  netmask 255.255.255.0  broadcast 10.0.0.255
        inet6 fe80::ee8d:f3d3:c194:40b4  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:be:01:b3  txqueuelen 1000  (Ethernet)
        RX packets 51  bytes 6071 (5.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 62  bytes 8571 (8.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

2)關(guān)閉網(wǎng)卡

[root@oldboy ~]# ifconfig down eth0

3)開(kāi)啟網(wǎng)卡

[root@oldboy ~]# ifconfig eth0 up

4)配置ip地址

[root@oldboy ~]# ifconfig eth0 10.0.0.201  
[root@oldboy ~]# ifconfig eth0      <===查看IP是否修改
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.0.201  netmask 255.255.255.0  broadcast 10.0.0.255
        inet6 fe80::ee8d:f3d3:c194:40b4  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:be:01:b3  txqueuelen 1000  (Ethernet)
        RX packets 315  bytes 32356 (31.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 300  bytes 35378 (34.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

5)配置ip地址和子網(wǎng)掩碼

[root@oldboy ~]# ifconfig eth0 10.0.0.201 netmask 255.255.255.0
[root@oldboy ~]# ifconfig eth0      <===查看IP和子網(wǎng)掩碼是否修改
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.0.201  netmask 255.255.255.0  broadcast 10.0.0.255
        inet6 fe80::ee8d:f3d3:c194:40b4  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:be:01:b3  txqueuelen 1000  (Ethernet)
        RX packets 315  bytes 32356 (31.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 300  bytes 35378 (34.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

6)單網(wǎng)卡添加IP地址

[root@oldboy ~]# ifconfig eth0:0 192.168.1.100  up
[root@oldboy ~]# ifconfig eth0:0   <===查看添加的IP地址
eth0:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.100  netmask 255.255.255.0  broadcast 192.168.1.255
        ether 00:0c:29:be:01:b3  txqueuelen 1000  (Ethernet)

7)刪除IP地址

[root@oldboy ~]$ ifconfig eth0 del 192.168.1.100

2. ip:查看和設(shè)置網(wǎng)絡(luò)和IP

1)查看IP地址

[root@oldboy ~]# ip a
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: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:be:01:b3 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.200/24 brd 10.0.0.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::ee8d:f3d3:c194:40b4/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

2)添加IP地址

[root@oldboy ~]#  ip addr add 192.168.17.30/24 dev eth0
[root@oldboy ~]# ip a     <===查看是否添加成功
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: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:be:01:b3 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.201/24 brd 10.0.0.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet 192.168.17.30/24 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::ee8d:f3d3:c194:40b4/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

3)刪除IP地址

[root@oldboy ~]# ip addr del 192.168.17.30/24 dev eth0
[root@oldboy ~]#  ip a     <===查看是否刪除成功
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: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:be:01:b3 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.201/24 brd 10.0.0.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::ee8d:f3d3:c194:40b4/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

3. ping:發(fā)送數(shù)據(jù)到網(wǎng)絡(luò),檢查網(wǎng)絡(luò)是否通暢

[root@oldboy ~]#  ping baidu.com   <===此時(shí)網(wǎng)絡(luò)通暢
PING baidu.com (220.181.57.216) 56(84) bytes of data.
64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=1 ttl=128 time=18.4 ms
64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=2 ttl=128 time=10.6 ms
64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=3 ttl=128 time=11.4 ms
64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=4 ttl=128 time=18.8 ms

4. traceroute:查看到達(dá)主機(jī)的網(wǎng)絡(luò)路由信息

參數(shù) 說(shuō)明
-d 不作反向解析
[root@oldboyedu ~]# traceroute -d www.baidu.com
traceroute to www.baidu.com (61.135.169.125), 30 hops max, 60 byte packets
 1  gateway (10.0.0.254)  0.172 ms  0.131 ms  0.130 ms
 2  * * *
 3  * * *
 4  * * *
 5  * * *

5. route:查看設(shè)置網(wǎng)關(guān)、路由

參數(shù) 說(shuō)明
-host 主機(jī)路由
-net 網(wǎng)絡(luò)路由
-n 查看路由信息
add 添加一個(gè)新路由
gw 指定的入口
del 刪除路由
default gw 默認(rèn)網(wǎng)關(guān)

1)查看路由信息

[root@oldboyedu ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.0.0.254      0.0.0.0         UG    100    0        0 eth0
10.0.0.0        0.0.0.0         255.255.255.0   U     100    0        0 eth0

2)添加路由信息

[root@oldboy ~]# route add -net 192.168.0.0/24 gw 10.0.0.12
[root@oldboy ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.0.0.254      0.0.0.0         UG    100    0        0 eth0
10.0.0.0        0.0.0.0         255.255.255.0   U     100    0        0 eth0
192.168.0.0     10.0.0.12       255.255.255.0   UG    0      0        0 eth0

3)刪除路由信息

[root@oldboy ~]# route del -net 192.168.0.0/24 gw 10.0.0.12
[root@oldboy ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.0.0.254      0.0.0.0         UG    100    0        0 eth0
10.0.0.0        0.0.0.0         255.255.255.0   U     100    0        0 eth0

6. telnet:檢測(cè)遠(yuǎn)程端口是否通暢

[root@oldboyedu ~]# telnet 123.125.114.144 80
Trying 123.125.114.144...      <---嘗試連接遠(yuǎn)程主機(jī)
Connected to 123.125.114.144.      <---連接成功

7. 復(fù)習(xí)第一階段的所有重要知識(shí)點(diǎn)

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容