V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
rationa1cuzz
V2EX  ›  问与答

求助: vm 虚拟机更换桥接模式后, docker 服务均无法访问

  •  
  •   rationa1cuzz · 2021-08-05 13:29:14 +08:00 · 497 次点击
    这是一个创建于 1209 天前的主题,其中的信息可能已经有所发展或是发生改变。
    不好放图,网卡以及 docker 运行详情如图
    [root@localhost ~]# 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: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:1d:49:b7 brd ff:ff:ff:ff:ff:ff
    inet 192.168.4.110/24 brd 192.168.4.255 scope global noprefixroute ens33
    valid_lft forever preferred_lft forever
    inet6 fe80::473f:7d97:58c3:43c4/64 scope link noprefixroute
    valid_lft forever preferred_lft forever
    3: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    link/ether 02:42:9b:11:a3:2f brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
    valid_lft forever preferred_lft forever
    inet6 fe80::42:9bff:fe11:a32f/64 scope link
    valid_lft forever preferred_lft forever
    5: vethb5b26d3@if4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default
    link/ether fa:fc:a2:ac:1e:e3 brd ff:ff:ff:ff:ff:ff link-netnsid 1
    inet6 fe80::f8fc:a2ff:feac:1ee3/64 scope link
    valid_lft forever preferred_lft forever
    7: veth3bacdb8@if6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default
    link/ether 6a:83:4d:48:ab:08 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet6 fe80::6883:4dff:fe48:ab08/64 scope link
    valid_lft forever preferred_lft forever
    9: veth3e9d188@if8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default
    link/ether 4e:09:b9:63:b4:56 brd ff:ff:ff:ff:ff:ff link-netnsid 2
    inet6 fe80::4c09:b9ff:fe63:b456/64 scope link
    valid_lft forever preferred_lft forever
    [root@localhost ~]# systemctl stop firewalld.service
    [root@localhost ~]# docker ps
    CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
    d5ddf490a257 jenkinsci/blueocean "/sbin/tini -- /usr/…" 9 days ago Up 55 minutes 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp, 50000/tcp jenkins
    aa5facb8b0e4 redis "docker-entrypoint.s…" 2 weeks ago Up About an hour 0.0.0.0:6379->6379/tcp, :::6379->6379/tcp redis
    696c72bc1d24 mysql:5.7 "docker-entrypoint.s…" 2 weeks ago Up About an hour 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp mysql
    [root@localhost ~]# systemctl status firewalld
    ● firewalld.service - firewalld - dynamic firewall daemon
    Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
    Active: inactive (dead)
    Docs: man:firewalld(1)
    lysS
        1
    lysS  
       2021-08-05 13:50:47 +08:00
    虚拟机能正常连网吗?
    rationa1cuzz
        2
    rationa1cuzz  
    OP
       2021-08-05 13:58:25 +08:00
    @lysS 可以 ping 通百度,我的电脑也可以正常连接到宿主机
    大概网络拓扑 我 192.168.4.10 另一台物理机 192.168.4.100 [虚拟机(宿主机)192.168.4.110 ]
    均可以正常连接
    lysS
        3
    lysS  
       2021-08-05 14:37:48 +08:00
    大概记得 docker 也是桥接
    我猜:你的 VM 的虚拟机的同一端口同时和容器与主机桥接,估计是冲突了

    换成 NAT 应该可以解决

    推荐在 WSL 里装 docker
    rationa1cuzz
        4
    rationa1cuzz  
    OP
       2021-08-05 14:56:16 +08:00
    @lysS 我是从 nat 换过来的,nat 模式我就没有办法通过我的主机 ssh 到宿主机了
    rationa1cuzz
        5
    rationa1cuzz  
    OP
       2021-08-05 14:58:36 +08:00
    @lysS 你的意思是我虚拟机的 3306 既与主机桥接又和容器桥接冲突了是吗?但是我的 jenkins 8080 可以正常访问
    rationa1cuzz
        6
    rationa1cuzz  
    OP
       2021-08-05 15:17:08 +08:00
    @lysS 重新创了一个容器 4417:3306,按照冲突说法现在应该不对,此时我主机 4417---虚拟机 4417----容器 3306
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3675 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 10:41 · PVG 18:41 · LAX 02:41 · JFK 05:41
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.