Debian Jessie 服务器无法访问互联网

Debian Jessie 服务器无法访问互联网

我有一台运行 Debian 8 Jessie 的服务器,它经常无缘无故地失去互联网访问权限。服务器有两个有线连接,互联网访问位于 eth0 上,内部网络位于 eth1 上。内部连接工作正常。

/etc/network/interfaces 的内容是:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet static
    address 132.248.25.125
    netmask 255.255.255.0
    network 132.248.25.0
    broadcast 132.248.25.255
    gateway 132.248.25.254
    dns-nameservers 132.248.204.1 132.248.10.2


allow-hotplug eth1
iface eth1 inet static
    address 192.169.1.249
    netmask 255.255.255.0
    network 192.169.1.0
    broadcast 192.169.1.255
    gateway 192.169.1.10

如果配置:

eth0      Link encap:Ethernet  HWaddr 00:30:48:fe:a7:3c  
          inet addr:132.248.25.125  Bcast:132.248.25.255  Mask:255.255.255.0
          inet6 addr: fe80::230:48ff:fefe:a73c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4278205 errors:0 dropped:8744 overruns:0 frame:0
          TX packets:7134 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:371528685 (354.3 MiB)  TX bytes:832677 (813.1 KiB)
          Memory:f0000000-f001ffff

eth1      Link encap:Ethernet  HWaddr 00:30:48:fe:a7:3d  
          inet addr:192.169.1.249  Bcast:192.169.1.255  Mask:255.255.255.0
          inet6 addr: fe80::230:48ff:fefe:a73d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1206214 errors:0 dropped:2667 overruns:0 frame:0
          TX packets:3028234 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:75759114 (72.2 MiB)  TX bytes:4139225848 (3.8 GiB)
          Memory:f0060000-f007ffff

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:4644 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4644 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1006417 (982.8 KiB)  TX bytes:1006417 (982.8 KiB)

对于路线 -n

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.169.1.10    0.0.0.0         UG    0      0        0 eth1
132.248.25.0    0.0.0.0         255.255.255.0   U     0      0        0 eth0
192.169.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1

我对 Linux 很陌生,所以我不太确定我在寻找什么。我的猜测是默认网关出现问题,或者防火墙引起了问题。

任何建议/帮助将不胜感激。

结果ip a:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:30:48:fe:a7:3c brd ff:ff:ff:ff:ff:ff
    inet 132.248.25.125/24 brd 132.248.25.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::230:48ff:fefe:a73c/64 scope link
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:30:48:fe:a7:3d brd ff:ff:ff:ff:ff:ff
    inet6 fe80::230:48ff:fefe:a73d/64 scope link
       valid_lft forever preferred_lft forever

而对于ip r:

132.248.25.0/24 dev eth0  proto kernel  scope link  src 132.248.25.125

答案1

注释掉一个网关。没有互联网连接的:

#gateway 192.169.1.10

标准配置只能有一个,并且您的路由显示它是当前使用的内部网关。

如果此网关后面还有其他网络,请添加以下内容:

post-up /sbin/ip route add 192.169.X.0/24 via 192.169.1.10
post-down /sbin/ip route del 192.169.X.0/24 via 192.169.1.10

对于内部网关后面的每个网络。

相关内容