Ubuntu 15,无法设置路由,请求超时

Ubuntu 15,无法设置路由,请求超时

我最近买了一台准系统电脑,想把它设置为我的家庭路由器/服务器。我试过几个教程,但没有成功,现在我放弃了。

我猜原因可能出在我的网络设计上,但我不确定。请帮忙或给我一些线索。如何配置 eth0 网关?

一般来说,我的网络设计是这样的。

ISP 路由器:

192.168.0.1是ISP的本地地址

myRouter://(我正在尝试设置)

root@gdn:~# cat /etc/os-release 
NAME="Ubuntu"
VERSION="15.04 (Vivid Vervet)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 15.04"
VERSION_ID="15.04"

root@gdn:~# cat /etc/networks 
#link-local 169.254.0.0
LAN     192.192.1.0
WLAN    192.192.2.0
OUT     192.168.0.0

配置如下:

已启用转发:

root@gdn:~# sysctl net.ipv4.conf.all.forwarding

net.ipv4.conf.all.forwarding = 1

在 /etc/网络/接口:

root@gdn:~# cat /etc/network/interfaces
auto lo
iface lo inet loopback
allow-hotplug wlan0

#"WAN"
auto eth0 
iface eth0 inet static
    address 192.168.0.2
    netmask 255.255.255.224
    network 192.168.0.0
    broadcast 192.168.0.31
    gateway 192.168.0.1

#LAN
auto eth1 
iface eth1 inet static
    address 192.192.1.1
    netmask 255.255.255.224
    network 192.192.1.0
    broadcast 192.192.1.31
    gateway 192.168.0.1
    #dns-nameservers 192.192.1.1

#wireless

auto wlan0
iface wlan0 inet static
    pre-down pkill hostapd
    address 192.192.2.1
    netmask 255.255.255.224
    network 192.192.2.0
    broadcast 192.192.2.31
    gateway 192.168.0.1
    #dns-nameservers 192.192.2.1
    sleep 1
    post-up hostapd /etc/hostapd/hostapd.conf &

dhcpd配置文件

ddns-update-style none;

option domain-name "home.network";

default-lease-time 600;
max-lease-time 7200;

authoritative;

log-facility local7;

subnet 192.192.1.0 netmask 255.255.255.224 {
  range 192.192.1.2 192.192.1.30;
  option domain-name-servers gdn.home.network;
  option domain-name "home.network";
  option subnet-mask 255.255.255.224;
  option routers 192.192.1.1;
  option broadcast-address 192.192.1.31;
}
subnet 192.192.2.0 netmask 255.255.255.224 {
    range 192.192.2.2 192.192.2.30;
    option domain-name-servers gdn.home.network;
    option domain-name "home.network";
    option subnet-mask 255.255.255.224;
    option routers 192.192.2.1;
    option broadcast-address 192.192.2.31;
}

路由:

root@gdn:~# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.0.1     0.0.0.0         UG    0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth0
192.168.0.0     0.0.0.0         255.255.255.224 U     0      0        0 eth0
192.192.1.0     0.0.0.0         255.255.255.224 U     0      0        0 eth1
192.192.2.0     0.0.0.0         255.255.255.224 U     0      0        0 wlan0

iptables(透明)

root@gdn:~# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere      

测试:我已经能够在 eth1 和 wlan0 子网之间 ping 通,但无法 ping 通 internet/192.168.0.1,但我可以 ping 通路由器上的所有接口(eth0、eth1、wlan0)。

Pinging 192.192.1.1 from 192.192.1.2 with 32 bytes of data:
Reply from 192.192.1.1: bytes=32 time=1ms TTL=64

Pinging 192.192.2.1 from 192.192.1.2 with 32 bytes of data:
Reply from 192.192.2.1: bytes=32 time=1ms TTL=64

Pinging 192.168.0.2 from 192.192.1.2 with 32 bytes of data:
Reply from 192.168.0.2: bytes=32 time=1ms TTL=64

但:

Pinging 192.168.0.1 from 192.192.1.2 with 32 bytes of data:
Request timed out.

Pinging google.com [216.58.209.46] from 192.192.1.2 with 32 bytes of data:
Request timed out.

通过路由器互联网运行良好:

root@gdn:~# ping 192.168.0.1
PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.
64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=4.86 ms
root@gdn:~# ping google.com
PING google.com (216.58.209.78) 56(84) bytes of data.
64 bytes from ldn02s06-in-f14.1e100.net (213.38.109.78): icmp_seq=1 ttl=55 time=9.66 ms

如何配置 eth0 网关?提前感谢您的任何提示...

答案1

有人可能会进一步解释,我不是网络专家,我假设,我不需要在 C 类中设置任何 nat,但是......等等,如果我将 192.192* 路由到 192.168*,那么 192.168.0.0/27 网络就无法识别该数据包!

刚刚添加 :

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

就这些。下面是带有解释的链接。

http://www.karlrupp.net/en/computer/nat_tutorial

相关内容