腾讯云授权服务中心
五万用户的选择,您身边的云计算顾问
发布日:2023-02-06 阅读数:92
根据服务器配置不同绑定网卡数
# ip addr
网卡未激活状态
3. 进入网络配置目录,复制网卡eth0配置文件为eth1
# cd /etc/sysconfig/network-scr1pts/# cp ifcfg-eth0 ifcfg-eth1
# vim ifcfg-eth1
4.eth1网卡配置文件主要内容
DEVICE='eth1' # 根据实际填写,此处写步骤1中查看到的需配置的弹性网卡名称NM_CONTROLLED='yes'ONBOOT='yes'IPADDR='192.168.1.62' # 根据实际填写,此处写弹性网卡上的 IP 地址NETMASK='255.255.255.192' #根据实际填写,此处写子网掩码
#GATEWAY='192.168.1.1' #根据实际需要填写。因为eth0文件定义了网关,这里不再写网关,避免网关冲突
5. 修改配置问文件后重启网卡
# systemctl restart network
# ip addr
网卡被激活状态
6. 设置路由
echo "10 t1" >> /etc/iproute2/rt_tables
echo "20 t2" >> /etc/iproute2/rt_tables
7. 给路由表添加默认路由
# route -n # 查看本机geteway
# ip route add default dev eth0 via 192.168.1.1 table 10# ip route add default dev eth1 via 192.168.1.1 table 20
8. 配置策略路由
# ip rule add from 192.168.1.5 table 10# ip rule add from 192.168.1.62 table 20
9. 连接一下你的弹性公网试试
编辑:航网科技 来源:腾讯云
本文版权归原作者所有 转载请注明出处
Copyright © 2011-2023 www.hangw.com. All Rights Reserved 深圳航网科技有限公司 版权所有 增值电信业务经营许可证:粤B2-20201122 - 粤ICP备14085080号
微信扫一扫咨询客服
全国免费服务热线
0755-36300002