如何修改docker0网桥的IP段

关闭docker进程

systemctl stop docker

修改/etc/docker/daemon.json

{ 
  "bip": "100.96.2.1/24" #改为需要的网段。 
}

关闭docker0网桥

ip link set dev docker0 down

删除docker0网桥

brctl delbr docker0

重新加载docker的配置文件

systemctl daemon-reload

启动docker进程

systemctl start docker

查看docker0的网段

[root@lab2 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc 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: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:6c:3e:95 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic enp0s3
       valid_lft 57041sec preferred_lft 57041sec
    inet6 fe80::a00:27ff:fe6c:3e95/64 scope link 
       valid_lft forever preferred_lft forever
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:16:99:25 brd ff:ff:ff:ff:ff:ff
    inet 192.168.51.112/24 brd 192.168.51.255 scope global enp0s8
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe16:9925/64 scope link 
       valid_lft forever preferred_lft forever
6: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN 
    link/ether 02:42:8d:ae:32:a2 brd ff:ff:ff:ff:ff:ff
    inet 100.96.2.1/24 brd 100.96.2.255 scope global docker0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:8dff:feae:32a2/64 scope link 
       valid_lft forever preferred_lft forever
8: vethf240465@if7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP 
    link/ether f6:9a:e4:85:22:b0 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet6 fe80::f49a:e4ff:fe85:22b0/64 scope link 
       valid_lft forever preferred_lft forever

docker0的IP段已经修改为100.96.2.1/24

posted @ 2020-08-26 09:55  Zhai_David  阅读(1099)  评论(0编辑  收藏  举报