linux双线服务器如何配置?
网通使用第一块网卡(eth0):
IP:210。82。37。149
掩码:255。255。255。224
网关:210。82。37。158
铁通使用第二块网卡(eth1):
IP:222。35。 92。242
掩码:255。255。255。252
网关:222。35。92。241
二、配置网卡:
# vi /etc/sysconfig/networking/profiles/default/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
IPADDR=210。 82。37。149
NETMASK=255。255。255。224
GATEWAY=210。82。37。1...全部
网通使用第一块网卡(eth0):
IP:210。82。37。149
掩码:255。255。255。224
网关:210。82。37。158
铁通使用第二块网卡(eth1):
IP:222。35。
92。242
掩码:255。255。255。252
网关:222。35。92。241
二、配置网卡:
# vi /etc/sysconfig/networking/profiles/default/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
IPADDR=210。
82。37。149
NETMASK=255。255。255。224
GATEWAY=210。82。37。158
TYPE=Ethernet
# vi /etc/sysconfig/networking/profiles/default/ifcfg-eth1
DEVICE=eth1
ONBOOT=yes
IPADDR=222。
35。92。242
NETMASK=255。255。255。252
GATEWAY=222。35。92。241
TYPE=Ethernet
# vi /etc/sysconfig/networking/profiles/default/route-eth1
GATEWAY0=218。
57。200。1
NETMASK0=255。255。255。0
ADDRESS0=218。57。200。242
# vi /etc/sysconfig/networking/profiles/default/resolv。
conf
nameserver 202。102。152。3
nameserver 202。102。128。68
三、配置路由表
# vi /etc/iproute2/rt_tables,增加网通和铁通两个路由表
252 cnc
251 crtc
设置网通的路由表
ip route add 210。
82。37。128/27 via 210。82。37。149 dev eth0 table cnc
ip route add 127。0。0。0/8 dev lo table cnc
ip route add default via 210。
82。37。158 dev eth0 table cnc
设置铁通的路由表
ip route add 222。35。92。240/30 via 222。35。92。242 dev eth1 table crtc
ip route add 127。
0。0。0/8 dev lo table crtc
ip route add default via 222。35。92。241 dev eth1 table crtc
制定策略,让222。35。
92。242的回应数据包走铁通的路由表路由,210。82。37。149的回应数据包走网通的路由表路由
ip rule add from 210。82。37。149 table cnc
ip rule add from 222。
35。92。242 table crtc
修改IP转发文件
# vi /etc/sysctl。conf
net。ipv4。ip_forward = 1
net。ipv4。conf。default。
rp_filter = 1
kernel。sysrq = 0
设置静态路由表文件
# vi /etc/sysconfig/static-routes
eth0 net 210。82。37。149 netmask 255。
255。255。224 gw 210。82。37。158
eth1 net 222。35。92。242 netmask 255。255。255。252 gw 222。35。92。241
将从两个WAN口出去的数据包进行IP伪装masquerade
# /sbin/modprobe ip_conntrack_ftp
# /sbin/modprobe ip_nat_ftp
# /sbin/iptables -t nat -A postrouting -o eth0 -j masquerade
# /sbin/iptables -t nat -A postrouting -o eth1 -j masquerade
设置默认网关为网通
# route add default gw 210。
82。37。158
增加出口路由策略,客户端是铁通的走铁通线路,其余走网通线路。
CODE: ip rule add to 121。16。0。0/13 table cncip rule add to 121。
24。0。0/14 table cncip rule add to 121。28。0。0/15 table cncip rule add to 121。30。0。0/16 table cnc ip rule add to 121。
31。0。0/16 table cnc
其余省略。。。
刷新路由表
ip route flush cache。收起