Npm служить от бродячей машины и окна хоста

426
Andrea Nisticò

Я пытаюсь работать с бродячей машины, которая соединена мостом, и я хотел бы получить доступ к веб-странице с любого устройства, подключенного к этой общедоступной сети (в экспериментальных целях). Я получаю доступ к машине сvagrant ssh

Проблема в том, что когда я бегу serve -s buildс машины, я вижу следующее:

 Serving!  - Local: http://localhost:5000  - On Your Network: http://127.0.0.1:5000 

что странно, потому что «В вашей сети» должен отображать общедоступную сеть, к которой я подключен (?)

Мой бродячий файл выглядит следующим образом:

Vagrant.configure("2") do |config|  config.vm.box = "generic/ubuntu1804" config.vm.network "public_network"  config.vm.synced_folder "./shared", "/home/vagrant/shared", owner: "vagrant", create: true, nfs: true, nfs_udp: false  config.vm.provider "virtualbox" do |v| host = RbConfig::CONFIG['host_os']  # Setup hardware config, host-os specific. Your host should have at least 6GB memory if host =~ /darwin/ # mac cpus = `sysctl -n hw.ncpu`.to_i # sysctl returns Bytes and we need to convert to MB # mem = `sysctl -n hw.memsize`.to_i / 1024 / 1024 / 2 mem = 10000 elsif host =~ /linux/ # linux cpus = `nproc`.to_i # meminfo shows KB and we need to convert to MB # mem = `grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal://' -e 's/ kB//'`.to_i / 1024 / 4 mem = 10000 else # windows cpus = 2 mem = 10000 end v.customize ["modifyvm", :id, "--nictype1", "virtio"] v.customize ["modifyvm", :id, "--memory", mem] v.customize ["modifyvm", :id, "--cpus", cpus] v.customize ["guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold", 1000] v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"] end  # React server config.vm.network :forwarded_port, guest: 3000, host: 3000 config.vm.network :forwarded_port, guest: 5000, host: 5000  # Webpack server config.vm.network :forwarded_port, guest: 8000, host: 8000  # Eth node config.vm.network :forwarded_port, guest: 8545, host: 8545  # IPFS config.vm.network :forwarded_port, guest: 4001, host: 4001 config.vm.network :forwarded_port, guest: 5001, host: 5001 config.vm.network :forwarded_port, guest: 8080, host: 8080  config.vm.provision :shell, path: "bootstrap.sh" end 

И когда я начинаю с, vagrant upя получаю:

$ vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Checking if box 'generic/ubuntu1804' is up to date... ==> default: Clearing any previously set forwarded ports... ==> default: Clearing any previously set network interfaces... ==> default: Preparing network interfaces based on configuration... default: Adapter 1: nat default: Adapter 2: bridged ==> default: Forwarding ports... default: 3000 (guest) => 3000 (host) (adapter 1) default: 5000 (guest) => 5000 (host) (adapter 1) default: 8000 (guest) => 8000 (host) (adapter 1) default: 8545 (guest) => 8545 (host) (adapter 1) default: 4001 (guest) => 4001 (host) (adapter 1) default: 5001 (guest) => 5001 (host) (adapter 1) default: 8080 (guest) => 8080 (host) (adapter 1) default: 22 (guest) => 2222 (host) (adapter 1) ==> default: Running 'pre-boot' VM customizations... ==> default: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2222 default: SSH username: vagrant default: SSH auth method: private key ==> default: Machine booted and ready! [default] GuestAdditions 5.2.16 running --- OK. ==> default: Checking for guest additions in VM... ==> default: Configuring and enabling network interfaces... ==> default: Mounting shared folders... default: /home/vagrant/shared => D:/Devel/Vagrant/VagrantTest/shared ==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision` ==> default: flag to force provisioning. Provisioners marked to run always will still run. 

пока ifconfigотображает:

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255 inet6 fe80::a00:27ff:fe2a:6801 prefixlen 64 scopeid 0x20<link> ether 08:00:27:2a:68:01 txqueuelen 1000 (Ethernet) RX packets 1371 bytes 611042 (611.0 KB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 860 bytes 98984 (98.9 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0  eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 172.20.41.109 netmask 255.255.255.0 broadcast 172.20.41.255 inet6 fe80::a00:27ff:fe12:4c8 prefixlen 64 scopeid 0x20<link> ether 08:00:27:12:04:c8 txqueuelen 1000 (Ethernet) RX packets 1310 bytes 330793 (330.7 KB) RX errors 0 dropped 68 overruns 0 frame 0 TX packets 38 bytes 5349 (5.3 KB) 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 loop txqueuelen 1000 (Local Loopback) RX packets 196 bytes 16340 (16.3 KB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 196 bytes 16340 (16.3 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 

Я хотел бы обслуживать eth1таким образом на IP связан с. Я начинаю сейчас с бродячей сети, поэтому немного борюсь с ней. Заранее спасибо!

0

0 ответов на вопрос