我正在尝试在CentOS 7 VM(我已经拥有)中安装Jupyter,所以我可以通过我的主机Mac笔记本电脑上的端口8888访问它。但是,我无法弄清楚网络连接。
为方便起见,我将IP地址更改为200.100.x.x
来自主机
我有两个适用于该CentOS VM的适配器
$ ifconfig
给了我这个(我相信那些是相同的):
vmnet1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 00:50:56:c0:00:01
inet 200.100.42.1 netmask 0xffffff00 broadcast 200.100.42.255
vmnet8: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 00:50:56:c0:00:08
inet 200.100.40.1 netmask 0xffffff00 broadcast 200.100.40.255
从CentOS内部
[root@localhost ~]# ifconfig
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 200.100.40.145 netmask 255.255.255.0 broadcast 200.100.40.255
inet6 fe80::20c:29ff:febf:4878 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:bf:48:78 txqueuelen 1000 (Ethernet)
RX packets 645 bytes 97963 (95.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 215 bytes 24854 (24.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eno33554984: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 200.100.42.128 netmask 255.255.255.0 broadcast 200.100.42.255
inet6 fe80::250:56ff:fe3d:7210 prefixlen 64 scopeid 0x20<link>
ether 00:50:56:3d:72:10 txqueuelen 1000 (Ethernet)
RX packets 18 bytes 1884 (1.8 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 45 bytes 6130 (5.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
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 0 (Local Loopback)
RX packets 220 bytes 50398 (49.2 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 220 bytes 50398 (49.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
我的测试
我从我的主机上ping了以下IP地址,但它们都有效:
200.100.42.128
200.100.40.145
200.100.42.1
200.100.40.1
这意味着VM中存在网络连接。正确的吗?
当我执行jupyter notebook
时,我可以访问VM 中的http://localhost:8888/tree
,但我不能使用Macbook上主机操作系统的任何IP地址去那里。
我已多次重启我的虚拟机。
问题
是因为端口阻塞/不转发(8888)或其他什么,如果有,如何解决?
我是否错误地设置了网络?在CentOS内还有其他我需要做的事吗?我在这里阅读了这个博客http://twiki.org/cgi-bin/view/Blog/BlogEntry201310x2,我根本没有看到eth0
。
答案 0 :(得分:1)
问题是Jupyter默认选择127.0.0.0
或localhost
。如果你有适配器与其他IP地址,它将无法正常工作。
您需要在VM中更改Jupyter的IP
http://jupyter-notebook.readthedocs.org/en/latest/config.html
$ jupyter notebook --generate-config
编辑它:
vi /root/.jupyter/jupyter_notebook_config.py
然后改变:
c.Notebookapp.ip = '0.0.0.0'
重启jupyter notebook
,应该不错。
确保端口8888
的防火墙已关闭或打开。