![无法获取正确的默认路由](https://linux22.com/image/1464791/%E6%97%A0%E6%B3%95%E8%8E%B7%E5%8F%96%E6%AD%A3%E7%A1%AE%E7%9A%84%E9%BB%98%E8%AE%A4%E8%B7%AF%E7%94%B1.png)
我有 8 台安装了 wheezy 和 jessie 的远程 Raspberry Pi 计算机。我运行所有这些计算机,它们都是无头的,目前通过 WiFi 连接。它们都安装了 Edimax WiFi 加密狗。我同时使用 IPv4 和 IPv6。当它们启动时,我有以下输出。
$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
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: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
link/ether b8:27:eb:1d:09:50 brd ff:ff:ff:ff:ff:ff
inet 192.168.2.13/24 brd 192.168.2.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 2001:db8::2:13/64 scope global tentative
valid_lft forever preferred_lft forever
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether 80:1f:02:9b:d1:f4 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.13/24 brd 192.168.1.255 scope global wlan0
valid_lft forever preferred_lft forever
inet6 fe80::821f:2ff:fe9b:d1f4/64 scope link
valid_lft forever preferred_lft forever
$ ip route
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.13
192.168.2.0/24 dev eth0 proto kernel scope link src 192.168.2.13
/etc/network/interface 如下:
auto lo
iface lo inet loopback
# WAN wlan0 should always be ready with a server static address
auto wlan0
iface wlan0 inet static
address 192.168.1.13
netmask 255.255.255.0
gateway 192.168.1.1
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
up fixroutes.sh
up /usr/local/sbin/fixroutes.sh
iface wlan0 inet6 static
address 2001:db8::1:13
netmask 64
gateway 2001:db8::2
# Ethernet 0 interface is static for a server IPv4
auto eth0
allow-hotplug eth0
iface eth0 inet static
address 192.168.2.13
netmask 255.255.255.0
down /usr/local/sbin/fixroutes.sh
iface eth0 inet6 static
address 2001:db8::2:13
netmask 64
Fixroutes 包含:
route add default gw 192.168.1.1 dev wlan0
如何添加默认路由?我尝试过在接口文件中不使用 up 或 down,在接口文件中使用路由添加默认值,并在 /etc/network/if-up.d 目录中的 fixroutes 文件中也使用。
另外,如果我可以问第二个问题的话,为什么 wlan0 的 IPv6 地址没有出现?
谢谢