第九周作业

1、总结ip分类以及每个分类可以分配的IP数量

IP地址组成:网络id、主机id

IP地址分类:
A类:1-126.x.y.z
网络ID位最高8位,主机ID是后24位
网络数:126=2^7(可变是的网络ID位数)-2
每个网络中的主机数:2^24-2=16777214

B类:127-191.x.y.z
网络ID位是最高16位,主机ID是16位低位
网络数:2^14=16384
每个网络中的主机数:2^16-2=65534

C类:192-223.x.y.z
网络ID位是最高24位,主机ID是8位低位
网络数:2^21=2097152
每个网络中的主机数:2^8-2=254

D类:组(多)播,1111.X.Y.Z: 224-239.X.Y.Z

2、总结IP配置方法

centos:   
[root@centos8 ~]# ll /etc/sysconfig/network-scripts/
total 4
-rw-r--r-- 1 root root 364 Dec 23 20:12 ifcfg-eth0
[root@centos8 ~]# nmcli con modify eth0 ipv4.address 10.0.0.8/24 ipv4.gateway 10.0.0.251 ipv4.dns 233.6.6.6 ipv4.method manual
[root@centos8 ~]# nmcli con reload
[root@centos8 ~]# nmcli con up eth0
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/2)

查看ip和gateway
[root@centos8 ~]# 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 fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:7a:4b:17 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.8/24 brd 10.0.0.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::64ed:295f:cba6:8479/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

[root@centos8 ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.0.0.251      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

查看DNS:
[root@centos8 ~]# cat /etc/resolv.conf 
# Generated by NetworkManager
search yyang
nameserver 223.6.6.6



Ubuntu:
root@ubuntu1804:/etc/netplan# vim /etc/netplan/01-netcfg.yaml
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: no
      addresses: [10.0.0.12/24]
      gateway4: 10.0.0.251
      optional: true
      nameservers:
          addresses: [223.6.6.6,223.5.5.5]

root@ubuntu1804:/etc/netplan# netplan apply

查看ip和gateway:
root@ubuntu1804:/etc/netplan# 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 fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:73:be:9d brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.12/24 brd 10.0.0.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe73:be9d/64 scope link 
       valid_lft forever preferred_lft forever

root@ubuntu1804:/etc/netplan# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.0.0.251      0.0.0.0         UG    0      0        0 eth0
10.0.0.0        0.0.0.0         255.255.255.0   U     0      0        0 eth0


查看DNS :
root@ubuntu1804:/etc/netplan# systemd-resolve --status
Global
          DNSSEC NTA: 10.in-addr.arpa
                      16.172.in-addr.arpa
                      168.192.in-addr.arpa
                      17.172.in-addr.arpa
                      18.172.in-addr.arpa
                      19.172.in-addr.arpa
                      20.172.in-addr.arpa
                      21.172.in-addr.arpa
                      22.172.in-addr.arpa
                      23.172.in-addr.arpa
                      24.172.in-addr.arpa
                      25.172.in-addr.arpa
                      26.172.in-addr.arpa
                      27.172.in-addr.arpa
                      28.172.in-addr.arpa
                      29.172.in-addr.arpa
                      30.172.in-addr.arpa
                      31.172.in-addr.arpa
                      corp
                      d.f.ip6.arpa
                      home
                      internal
                      intranet
                      lan
                      local
                      private
Global
          DNSSEC NTA: 10.in-addr.arpa
                      16.172.in-addr.arpa
                      168.192.in-addr.arpa
                      17.172.in-addr.arpa
                      18.172.in-addr.arpa
                      19.172.in-addr.arpa
                      20.172.in-addr.arpa
                      21.172.in-addr.arpa
                      22.172.in-addr.arpa
                      23.172.in-addr.arpa
                      24.172.in-addr.arpa
                      25.172.in-addr.arpa
                      26.172.in-addr.arpa
                      27.172.in-addr.arpa
                      28.172.in-addr.arpa
                      29.172.in-addr.arpa
                      30.172.in-addr.arpa
                      31.172.in-addr.arpa
                      corp
                      d.f.ip6.arpa
                      home
                      internal
                      intranet
                      lan
                      local
                      private
                      test

Link 2 (eth0)
      Current Scopes: DNS
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no
         DNS Servers: 223.6.6.6
                      223.5.5.5


3、使用nmcli实现bonding

[root@centos8 ~]# 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 fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:7a:4b:17 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.8/24 brd 10.0.0.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::64ed:295f:cba6:8479/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:7a:4b:21 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::46a:6652:6179:95f1/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
9: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:7a:4b:2b brd ff:ff:ff:ff:ff:ff
[root@centos8 ~]# nmcli con
NAME                UUID                                  TYPE      DEVICE 
Wired connection 1  b8af1ac4-ff31-3bf2-9265-5fb84a960233  ethernet  eth1   
eth0                4ccf8f99-03d0-3b41-8969-b70e7810d6e3  ethernet  eth0   
Wired connection 2  e5539525-106f-3b41-8d1b-6cf4823a47ad  ethernet  --     
[root@centos8 ~]# nmcli con add type bond con-name bond0 ifname bond0 mode active-backup
Connection 'bond0' (6e7f3537-3de3-4a90-a880-03eb15eccd69) successfully added.
[root@centos8 ~]# nmcli con add type bond-slave ifname eth1 master bond0
Connection 'bond-slave-eth1' (02069f67-e801-419c-9395-03d4f41ec808) successfully added.
[root@centos8 ~]# nmcli con add type bond-slave ifname eth2 master bond0
Connection 'bond-slave-eth2' (befaaaae-174b-4158-945d-ccd5fb52d058) successfully added.
[root@centos8 ~]# nmcli con
NAME                UUID                                  TYPE      DEVICE 
bond0               6e7f3537-3de3-4a90-a880-03eb15eccd69  bond      bond0  
eth0                4ccf8f99-03d0-3b41-8969-b70e7810d6e3  ethernet  eth0   
bond-slave-eth1     02069f67-e801-419c-9395-03d4f41ec808  ethernet  eth1   
bond-slave-eth2     befaaaae-174b-4158-945d-ccd5fb52d058  ethernet  eth2   
Wired connection 1  b8af1ac4-ff31-3bf2-9265-5fb84a960233  ethernet  --     
Wired connection 2  e5539525-106f-3b41-8d1b-6cf4823a47ad  ethernet  --     
[root@centos8 ~]# nmcli con up bond0
Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/47)

[root@centos8 ~]# 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 fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:7a:4b:17 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.8/24 brd 10.0.0.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::64ed:295f:cba6:8479/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc fq_codel master bond0 state UP group default qlen 1000
    link/ether 00:0c:29:7a:4b:21 brd ff:ff:ff:ff:ff:ff
9: eth2: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc fq_codel master bond0 state UP group default qlen 1000
    link/ether 00:0c:29:7a:4b:21 brd ff:ff:ff:ff:ff:ff
12: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:0c:29:7a:4b:21 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::44e1:64e7:d0ef:c70c/64 scope link tentative noprefixroute 
       valid_lft forever preferred_lft forever

[root@centos8 network-scripts]# nmcli con modify bond0 ipv4.address 10.0.0.9/24 ipv4.gateway 10.0.0.251 ipv4.dns 233.6.6.6 ipv4.method manual
[root@centos8 network-scripts]# nmcli con reload
[root@centos8 network-scripts]# nmcli con up bond0
Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/54)

[root@centos8 ~]# 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 fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:7a:4b:17 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.8/24 brd 10.0.0.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::64ed:295f:cba6:8479/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc fq_codel master bond0 state UP group default qlen 1000
    link/ether 00:0c:29:7a:4b:21 brd ff:ff:ff:ff:ff:ff
9: eth2: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc fq_codel master bond0 state UP group default qlen 1000
    link/ether 00:0c:29:7a:4b:21 brd ff:ff:ff:ff:ff:ff
13: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:0c:29:7a:4b:21 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.9/24 brd 10.0.0.255 scope global noprefixroute bond0
       valid_lft forever preferred_lft forever
    inet6 fe80::44e1:64e7:d0ef:c70c/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
[root@centos8 ~]# nmcli con
NAME                UUID                                  TYPE      DEVICE 
eth0                4ccf8f99-03d0-3b41-8969-b70e7810d6e3  ethernet  eth0   
bond0               6e7f3537-3de3-4a90-a880-03eb15eccd69  bond      bond0  
bond-slave-eth1     02069f67-e801-419c-9395-03d4f41ec808  ethernet  eth1   
bond-slave-eth2     befaaaae-174b-4158-945d-ccd5fb52d058  ethernet  eth2   
Wired connection 1  b8af1ac4-ff31-3bf2-9265-5fb84a960233  ethernet  --     
Wired connection 2  e5539525-106f-3b41-8d1b-6cf4823a47ad  ethernet  --

[root@centos8 ~]# cat /proc/net/bonding/bond0 
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth2
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Peer Notification Delay (ms): 0

Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:7a:4b:21
Slave queue ID: 0

Slave Interface: eth2
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:7a:4b:2b
Slave queue ID: 0
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 213,558评论 6 492
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 91,002评论 3 387
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 159,036评论 0 349
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 57,024评论 1 285
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,144评论 6 385
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,255评论 1 292
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,295评论 3 412
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,068评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,478评论 1 305
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,789评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,965评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,649评论 4 336
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,267评论 3 318
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,982评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,223评论 1 267
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,800评论 2 365
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,847评论 2 351

推荐阅读更多精彩内容

  • 1、总结ip分类以及每个分类可以分配的IP数量 Internet 委员会定义了5种IP地址类型,分别是A-E类,其...
    Easy_8195阅读 695评论 1 0
  • 1、判断UID是否大于等于500,如果为真就显示为普通用户,如果为假就显示为系统或管理用户 awk -F:'{if...
    hl大宝阅读 286评论 0 0
  • 1、编写脚本,接受二个位置参数,magedu和/www,判断系统是否有magedu,如果没有则自动创建magedu...
    一心1977阅读 122评论 0 0
  • 1、判断UID是否大于等于500,如果为真就显示为普通用户,如果为假就显示为系统或管理用户 2、显示用户id为奇数...
    ritch阅读 391评论 0 0
  • 1、画出TSL链路的通信图 第一阶段:ClientHello: 支持的协议版本,比如tls 1.2 客户端生成一个...
    N37077ZZ阅读 285评论 0 0