Ubuntu 10.10 IP 配置(使用 2 个 IP 地址)

Ubuntu 10.10 IP 配置(使用 2 个 IP 地址)

这更像是一个“是否可能的问题”以及最好的解决方法是什么。

我在台式电脑上运行 Ubuntu 10.10(64 位)。我目前使用路由器的静态 IP 地址连接到互联网。我有 2 个可用的 WAN IP 地址(xxx.xxx.xxx.101 和 xxx.xxx.xxx.102)。

我的路由器配置为使用 .101 WAN IP 地址。我的计算机是否可以同时使用路由器的静态 IP 地址和外部 .102 WAN 地址?

谢谢。

答案1

如果两个网关位于同一子网,我认为这是不可能的。

这是我在互联网上找到的一个脚本,根据您的网络设置,只需进行一些更改即可(但您必须将两个 WAN 中的一个更改为另一个子网,即 xxx.xxx.10.101 和 xxx.xxx.11.102)

#!/bin/sh

# split access
# http://lartc.org/howto/lartc.rpdb.multiple-links.html#AEN268
# http://tldp.org/HOWTO/Adv-Routing-HOWTO/lartc.rpdb.multiple-links.html
# GoneVertical.org

# 1. One creates two additional routing tables, say T1 and T2. These are added in /etc/iproute2/rt_tables. Then you set up routing in these tables as follows:
# echo 1 T1 >> /etc/iproute2/rt_tables
# echo 2 T2 >> /etc/iproute2/rt_tables

# interface
IF0=lo
IF1=eth0
IF2=eth1

# ips
IP1=192.168.12.100
IP2=192.168.10.100

# gateways
P1=192.168.12.1
P2=192.168.10.1

# ip network
P0_NET=0.0.0.0
P1_NET=192.168.12.0
P2_NET=192.168.10.0

#echo $IF0 $IF1 $IF2
#echo $IP1 $IP2
#echo $P0_NET $P1_NET $P2_NET

# create routing tables
ip route add $P1_NET dev $IF1 src $IP1 table T1
ip route add default via $P1 table T1
ip route add $P2_NET dev $IF2 src $IP2 table T2
ip route add default via $P2 table T2

# create routing for local requests
# not sure if i need this
#ip route add $P0_NET dev $IF0 table T1
#ip route add $P2_NET dev $IF2 table T1
#ip route add 127.0.0.0/8 dev lo table T1
#ip route add $P0_NET dev $IF0 table T2
#ip route add $P1_NET dev $IF1 table T2
#ip route add 127.0.0.0/8 dev lo table T2


# main routing table
ip route add $P1_NET dev $IF1 src $IP1
ip route add $P2_NET dev $IF2 src $IP2

# default route preference
ip route add default via $P1

# routing rules
ip rule add from $IP1 table T1
ip rule add from $IP2 table T2

来源:代码提示

另一个不错的 HOWTO 可以找到这里

相关内容