双网关互连组网

 linux这样才开启了包转发功能

# vi /etc/sysctl.conf
net.ipv4.ip_forward = 1

查看运行中的cat /proc/sys/net/ipv4/ip_forward 为1才是开启

 

gateway

二、配置网络
 
1.A,GW1,GW2,B的网络配置
 
A:
 
eth0:

 

IPADDR :192.168.1.2
 
NETMASK:255.255.255.0
 
GATEWAY:192.168.1.1
 
GW1:
 
eth0:
 
IPADDR :172.16.113.173
 
NETMASK:255.255.255.0
 
GATEWAY:172.16.113.9
 
eth1:
 
IPADDR :192.168.1.1
 
NETMASK:255.255.255.0
 
B:
 
eth0:
 
IPADDR :192.168.0.2
 
NETMASK:255.255.255.0
 
GATEWAY:192.168.0.1
 
GW2:
 
eth0:
 
IPADDR :172.16.113.163
 
NETMASK:255.255.255.0
 
GATEWAY:172.16.113.9
 
eth1:
 
IPADDR :192.168.0.1
 
NETMASK:255.255.255.0

 


 
2.GW1设置
 
(1)开启路由转发功能
 
# echo 1 > /proc/sys/net/ipv4/ip_forward
 

 
#vim /etc/sysctl.conf
 
net.ipv4.ip_forward = 0 --> net.ipv4.ip_forward = 1
 
(2)添加到192.168.0.0/24网段的路由
 
# route add -net 192.168.0.0 netmask 255.255.255.0 gw 172.16.113.163
 
3. GW2设置
 
(1)开启路由转发功能
 
# echo 1 > /proc/sys/net/ipv4/ip_forward
 

 
#vim /etc/sysctl.conf
 
net.ipv4.ip_forward = 0 --> net.ipv4.ip_forward = 1
 
(2)添加到192.168.1.0/24网段的路由
 
# route add -net 192.168.1.0 netmask 255.255.255.0 gw 172.16.113.173
 
三、测试网关
 
若A,B能相互ping通,则两个网关也配置成功了.

你可能感兴趣的:(组网,双网关)