默认网关和桥接接口

默认网关和桥接接口

我有基于slackware的服务器openvpn 桥接,这是我的接口设置:

root@senior:/# ifconfig
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.1  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::206:4fff:fe0d:4666  prefixlen 64  scopeid 0x20<link>
        ether 00:06:4f:0d:46:66  txqueuelen 0  (Ethernet)
        RX packets 16236  bytes 2359023 (2.2 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1369  bytes 1030491 (1006.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=4419<UP,BROADCAST,RUNNING,PROMISC,MULTICAST>  mtu 1500
        inet6 fe80::206:4fff:fe0d:4666  prefixlen 64  scopeid 0x20<link>
        ether 00:06:4f:0d:46:66  txqueuelen 1000  (Ethernet)
        RX packets 18884  bytes 3383179 (3.2 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1516  bytes 1039564 (1015.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 11  base 0xc000

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 16436
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 115  bytes 7608 (7.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 115  bytes 7608 (7.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

tap0: flags=4355<UP,BROADCAST,PROMISC,MULTICAST>  mtu 1500
        inet6 fe80::2020:8ff:fee6:97b7  prefixlen 64  scopeid 0x20<link>
        ether 22:20:08:e6:97:b7  txqueuelen 100  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 2 overruns 0  carrier 0  collisions 0

我在用着OpenVPN 脚本设置 br0 和 tap0 接口。

如何设置默认网关?ip route add default via 192.168.1.254不起作用,它确实设置了默认网关,但是通过 br0 不起作用

root@senior:/home/kubi# ip route add default via 192.168.1.254
root@senior:/home/kubi# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.1.254   0.0.0.0         UG    0      0        0 br0
loopback        *               255.0.0.0       U     0      0        0 lo
localnet        *               255.255.255.0   U     0      0        0 br0
root@senior:/home/kubi# ping google.sk
PING google.sk (173.194.44.55) 56(84) bytes of data.
^C
--- google.sk ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 1999ms

如何使用 eth0 设置默认网关?

答案1

我发现我的网络没有问题。

在我的本地网络之外 ping 确实有效,但我的防火墙阻止了回复消息,因此看起来我无法连接到互联网。但是如果你看一下 ping,它能够解析主机名,因为 dns 服务器位于我的本地网络之外,这清楚地证明连接到互联网和默认网关没有问题。

很抱歉问了这个愚蠢的问题,但是我花了两天时间思考这个问题:)。

答案2

在路由添加命令的末尾包含您想要的接口。

ip route add default via 192.168.1.254 eth0

相关内容