linux不同网卡同一网段 路由设置
在Linux系统中,如果存在多个网卡连接至同一子网,需要对路由进行设置,否则可能会出现网络不通的情况。以下是设置路由的步骤:
- 查看系统中的网卡列表:
ifconfig -a
-
确定需要设置路由的网卡名称,例如网卡名称为eth0和eth1。
-
使用route命令添加网关路由:
route add -net 192.168.1.0 netmask 255.255.255.0 dev eth0
route add -net 192.168.1.0 netmask 255.255.255.0 dev eth1
其中,192.168.1.0为目标网络地址,255.255.255.0为子网掩码,eth0和eth1为需要添加路由的网卡名称。
- 使用route命令添加默认网关:
route add default gw 192.168.1.1 dev eth0
route add default gw 192.168.1.1 dev eth1
其中,192.168.1.1为默认网关地址,eth0和eth1为需要添加默认网关的网卡名称。
- 使用route命令查看路由表:
route -n
可以查看已经添加的路由信息。
- 修改/etc/sysctl.conf文件,启用IP转发功能:
net.ipv4.ip_forward = 1
- 重启网络服务:
service network restart
以上是在Linux系统中设置不同网卡同一网段的路由。
原文地址: https://www.cveoy.top/t/topic/bFFP 著作权归作者所有。请勿转载和采集!