Liunx双网卡(内网、外网)同时使用

条件:#

系统:CentOS 7

网卡: eth0  内网 网关:192.168.1.1     
            eth1  外网 网关:10.0.0.1

配置: #

复制代码
先安装net-tools:yum -y install net-tools
 route del default
#删除默认路由
 route add -net 192.168.1.0/24 gw 192.168.1.1
#指定内网网关
route add -net 192.168.1.0/24 dev eth0
#指定内网网卡
route add -net 0.0.0.0/0 gw 10.0.0.1
#指定外网网关
route add -net 0.0.0.0/0 dev eth1
#指定外网网卡
复制代码

写入文件:#

复制代码
[root@dcServer003 ~]# cat /etc/rc.local 
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
route add -net 192.168.1.0/24 gw 192.168.1.1 
route add -net 192.168.1.0/24 dev eth0
route add -net 0.0.0.0/0 gw 10.0.0.1
route add -net 0.0.0.0/0 dev eth1
复制代码

 

posted @   袁与张  阅读(1382)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 25岁的心里话
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
点击右上角即可分享
微信分享提示
主题色彩