Ubuntu 14.04 LAMP/SSH 端口转发问题/连接到互联网

Ubuntu 14.04 LAMP/SSH 端口转发问题/连接到互联网

我正在使用带有 LAMP、SSH 的 Ubuntu 14.04

我可以使用 192.168.0.194 的 putty 正常连接。当我使用 localhost 或 IP 地址时,它与我当前的路由器配合良好。但是一旦我转到另一个路由器或其他人尝试使用它,它要么无法连接,要么说无法连接。

我已经对其进行了端口转发,192.168.0.194 有多个端口,我已经尝试过 20-80。

这是我的 ifconfig:

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:36 errors:0 dropped:0 overruns:0 frame:0
          TX packets:36 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:2712 (2.7 KB)  TX bytes:2712 (2.7 KB)

p5p1      Link encap:Ethernet  HWaddr 14:da:e9:36:89:c8
          inet addr:192.168.0.194  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::16da:e9ff:fe36:89c8/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:219 errors:0 dropped:0 overruns:0 frame:0
          TX packets:38 errors:0 dropped:0 overruns:0 carrier:1
          collisions:0 txqueuelen:1000
          RX bytes:52259 (52.2 KB)  TX bytes:7199 (7.1 KB)

大多数 tuts 使用eth0,我已经尝试过,到现在已重新安装了 6 次,总是使用 p5p1。

这是我的netstat

Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 localhost:mysql         *:*                     LISTEN
tcp        0      0 *:ssh                   *:*                     LISTEN
tcp        0     64 192.168.0.194:ssh       192.168.0.198:57415     ESTABLISHED
tcp6       0      0 [::]:http               [::]:*                  LISTEN
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node   Path
unix  2      [ ACC ]     STREAM     LISTENING     12224    /var/run/mysqld/mysqld.sock
unix  2      [ ACC ]     SEQPACKET  LISTENING     11362    /run/udev/control
unix  5      [ ]         DGRAM                    13937    /dev/log
unix  2      [ ACC ]     STREAM     LISTENING     8160     @/com/ubuntu/upstart
unix  2      [ ACC ]     STREAM     LISTENING     12547    /var/run/dbus/system_bus_socket
unix  2      [ ACC ]     STREAM     LISTENING     9959     /var/run/acpid.socket
unix  2      [ ]         DGRAM                    9930
unix  3      [ ]         STREAM     CONNECTED     13924
unix  3      [ ]         STREAM     CONNECTED     11703
unix  3      [ ]         STREAM     CONNECTED     9747     @/com/ubuntu/upstart
unix  3      [ ]         STREAM     CONNECTED     15626
unix  2      [ ]         DGRAM                    14339
unix  3      [ ]         DGRAM                    8324
unix  3      [ ]         STREAM     CONNECTED     15630
unix  3      [ ]         STREAM     CONNECTED     9744
unix  3      [ ]         STREAM     CONNECTED     13923
unix  3      [ ]         STREAM     CONNECTED     13930    /var/run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     12537
unix  3      [ ]         STREAM     CONNECTED     12557    /var/run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     12691    /var/run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     9839
unix  3      [ ]         STREAM     CONNECTED     13918    @/com/ubuntu/upstart
unix  3      [ ]         STREAM     CONNECTED     10336
unix  3      [ ]         STREAM     CONNECTED     15625
unix  3      [ ]         DGRAM                    8325
unix  2      [ ]         DGRAM                    11687
unix  3      [ ]         STREAM     CONNECTED     9397     @/com/ubuntu/upstart

然后我的/etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto p5p1
iface p5p1 inet static
address 192.168.0.194
netmask 255.255.255.0
network 192.168.0.1
broadcast 192.168.0.255
gateway 192.168.0.1
dns nameservers 8.8.8.8.8.8.4.4

答案1

192.168.xy 等 IP 属于本地网络,因此只能在该网络内使用。如果您使用其他路由器,并且它们的 dhcp 选项设置相同,则应该会为您提供相同的内部 IP,并且连接到该路由器的每个人都应该能够连接到您的笔记本电脑。

要找出您的外部 IP,您可以访问 whatismyip.com 之类的网站,另请注意,您的外部 IP 是由您的 ISP 提供给您的,并且可能会发生变化。

相关内容