![如何更改我的网络服务器侦听的主机地址?](https://linux22.com/image/202056/%E5%A6%82%E4%BD%95%E6%9B%B4%E6%94%B9%E6%88%91%E7%9A%84%E7%BD%91%E7%BB%9C%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%BE%A6%E5%90%AC%E7%9A%84%E4%B8%BB%E6%9C%BA%E5%9C%B0%E5%9D%80%EF%BC%9F.png)
我正在我的 Ubuntu 主机上设置一个 Web 服务器。具体来说,就是gdbgui
。根据它的帮助信息,我可以用来--host
指定它监听的主机IP。在我的主机上,我有以下 IP 配置:
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.18.0.1 netmask 255.255.0.0 broadcast 172.18.255.255
ether 02:42:9f:02:c9:97 txqueuelen 0 (Ethernet)
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
enp89s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 1c:69:7a:a5:c2:e0 txqueuelen 1000 (Ethernet)
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 0x6a200000-6a2fffff
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 163716 bytes 56247108 (56.2 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 163716 bytes 56247108 (56.2 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlo1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet **192.168.50.69** netmask 255.255.255.0 broadcast 192.168.50.255 <========= HERE
inet6 fe80::3fd:752e:5ded:467f prefixlen 64 scopeid 0x20<link>
ether 70:9c:d1:21:c5:f0 txqueuelen 1000 (Ethernet)
RX packets 270277 bytes 117510355 (117.5 MB)
RX errors 0 dropped 15 overruns 0 frame 0
TX packets 93011 bytes 45155962 (45.1 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
我想使用 192.168.50.69,以便同一 LAN 中的其他计算机可以访问它。
但它始终监听 127.0.0.1。即使我明确指定--host
了gdbgui
.
gdbgui --host 192.168.50.69 ...
我怎样才能改变它?我想这个问题不是特定于 gdbgui 的。
谢谢!
答案1
gdbgui 的问题已解决。
我需要为该选项指定主机名而不是主机 IP --host
。就像下面这样:
gdbgui --host myBox ...
然后我需要修改该/etc/hosts
文件以指定主机名的IP地址。就像下面这样:
192.168.50.69 myBox