小编的一个成熟的swagger,部署在配置爽网卡的ubuntu上,同局域网的其他电脑无法访问swagger的接口。闭着眼睛瞎撞一通后,用如下的方法解决掉。
第一步:检查网络配置:ifconfig,得到如下信息
eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.50.154 netmask 255.255.255.0 broadcast 192.168.50.255
inet6 2408:8207:18e0:93b0:ae1f:6bff:feea:1e64 prefixlen 64 scopeid 0x0<global>
inet6 fe80::ae1f:6bff:feea:1e64 prefixlen 64 scopeid 0x20<link>
ether ac:1f:6b:ea:1e:64 txqueuelen 1000 (以太网)
RX packets 643 bytes 166311 (166.3 KB)
RX errors 0 dropped 62 overruns 0 frame 0
TX packets 357 bytes 62183 (62.1 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device memory 0xa4600000-a467ffff
eno2: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether ac:1f:6b:ea:1e:65 txqueuelen 1000 (以太网)
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
device memory 0xa4500000-a457ffff
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 (本地环回)
RX packets 328 bytes 41029 (41.0 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 328 bytes 41029 (41.0 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
发现eno2信息有些鸡肋
第二步,闭眼执行 sudo ifconfig eno2 down
第三步,执行 ifconfig,确认网卡是否禁用
第四步,执行sudo ufw enable启动防火墙
此时,swagger访问正常