우분투: 인터넷에 접속할 수 없습니다

우분투: 인터넷에 접속할 수 없습니다

Ubuntu 서버에 nodejs를 설치하려고 하는데 인터넷에 액세스할 수 없는 것 같습니다.

내 서버에는 두 개의 네트워크 인터페이스가 있습니다.

  1. eth0내 네트워크에 연결
  2. eth1때로는 두 번째 네트워크에 연결하는 데 사용되지만 일반적으로는 그렇지 않습니다.

내 게이트웨이는 일반 클래스 C 네트워크의 192.168.0.1입니다.

네트워크 내의 호스트를 ping하려고 하면 모든 것이 잘 작동하지만 게이트웨이를 ping하려고 하면 아무런 응답도 받을 수 없으며 제공된 올바른 이름 확인에 관계없이 외부 도메인을 ping하려고 할 때에도 같은 현상이 발생합니다. DNS.

내 구성은 다음과 같습니다.

구성된 경우:

root:~# ifconfig

eth0      Link encap:Ethernet  HWaddr a4:5d:36:c3:44:18
          inet addr:192.168.0.168  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::a65d:36ff:fec3:4418/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:31531 errors:0 dropped:108 overruns:0 frame:0
          TX packets:6734 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3896820 (3.8 MB)  TX bytes:930411 (930.4 KB)
          Interrupt:16

eth1      Link encap:Ethernet  HWaddr a4:5d:36:c3:44:19
          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:17

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:16 errors:0 dropped:0 overruns:0 frame:0
          TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:68235 (68.2 KB)  TX bytes:68235 (68.2 KB) 

내 경로:

root@:~# ip route show
default via 192.168.0.1 dev eth0
192.168.0.0/24 dev eth0  proto kernel  scope link  src 192.168.0.168
192.168.1.0/24 dev eth1  proto kernel  scope link  src 192.168.1.1

/etc/네트워크/인터페이스

# 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

auto eth0
        iface eth0 inet static
        metric 0
        address 192.168.0.168
        netmask 255.255.255.0
        network 192.168.0.0
        broadcast 192.168.0.255
        gateway 192.168.0.1
        dns-nameservers 192.168.0.3 192.168.0.2

auto eth1
        iface eth1 inet static
        metric 1
        address 192.168.1.1
        netmask 255.255.255.0
        gateway 192.168.0.168
        dns-nameservers 192.168.1.1 192.168.0.168

뭐가 문제 야?

답변1

다음 줄을 편집하여 /etc/sysctl.conf맨 아래에 추가하세요.

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

그런 다음 명령을 실행하십시오.

sysctl -p

sudo루트로 로그인하지 않은 경우 사용하십시오. 그러면 터미널에 다음이 표시됩니다.

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

그리고

cat /proc/sys/net/ipv6/conf/all/disable_ipv6

출력을 주어야합니다

1

192.168.0.1그런 다음 IP 주소를 다시 ping해 보십시오.

편집하다

또한 /etc/hosts파일의 IPV6 항목을 주석 처리해야 할 것 같습니다. 몇 가지 이야기를 나눈 후에 알아 냈습니다.

답변2

두 개의 기본 게이트웨이를 가질 수는 없습니다. auto eth1에서 게이트웨이 명령을 삭제합니다.

게이트웨이를 ping할 수 없고 동일한 스위치(또는 스위치)에 연결되어 있는 경우 발생한 문제는 게이트웨이와 관련이 없습니다. 다른 시스템이 게이트웨이와 통신할 수 있습니까? 아니면 이것이 문제입니까?

문제가 해결될 때까지 문제를 방지하려면 eth1에 대한 설정을 주석 처리하세요.

관련 정보