linux双网卡永久开启,linux双网卡的配置

服务器:IBM X3650

系统    :Red Hat Enterprise Linux Server release 5.4

eth0     :  IP=10.30.10.19

NETMASK=255.255.255.0

GATEWAY=10.30.10.254

DNS1=10.30.10.1

eth1     :  IP=192.168.0.11

NETMASK=255.255.255.0

GATEWAY=192.168.0.1

DNS1=192.168.0.1

以上分别为两张网卡设置的IP地址

开启ip forward功能,并让其永久生效

# vim /etc/sysctl.conf

net.ipv4.ip_forward = 0            #将此行的0参数修改为1,表示开启

执行sysctl -p 让其生效

上述配置完成后需增加路由,具体操作如下:

route add -net 0.0.0.0 netmask 0.0.0.0 gw 10.30.10.254 dev eth0

route add -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.0.1 dev eth1

再使用route -n查看路由信息

# route -n

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

10.30.10.0      0.0.0.0         255.255.255.0   U     1      0        0 eth0

169.254.95.0    0.0.0.0         255.255.255.0   U     1      0        0 usb0

192.168.0.0    192.168.0.1    255.255.255.0   UG    0      0        0 eth1

0.0.0.0         10.30.10.254    0.0.0.0         UG    0      0        0 eth0

路由信息己设置OK了,接下来就是进行测试了

可以通过ping 这两个网卡的IP地址,测试是否能正常通讯(其它因素不在本文范围考虑)

C:\Users\fzh>ping 192.168.0.11

Pinging 192.168.0.11 with 32 bytes of data:

Reply from 192.168.0.11: bytes=32 time<1ms TTL=62

Reply from 192.168.0.11: bytes=32 time<1ms TTL=62

Reply from 192.168.0.11: bytes=32 time<1ms TTL=62

Reply from 192.168.0.11: bytes=32 time<1ms TTL=62

Ping statistics for 192.168.0.11:

Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

Minimum = 0ms, Maximum = 0ms, Average = 0ms

C:\Users\fzh>ping 10.30.10.19

Pinging 10.30.10.19 with 32 bytes of data:

Reply from 10.30.10.19: bytes=32 time=1ms TTL=63

Reply from 10.30.10.19: bytes=32 time<1ms TTL=63

Reply from 10.30.10.19: bytes=32 time<1ms TTL=63

Reply from 10.30.10.19: bytes=32 time<1ms TTL=63

Ping statistics for 10.30.10.19:

Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

Minimum = 0ms, Maximum = 1ms, Average = 0ms

两张网卡地址都能正常ping通,再将路由设置到开启启动脚本里边:

# vim /etc/rc.local

route add -net 0.0.0.0 netmask 0.0.0.0 gw 10.30.10.254 dev eth0

route add -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.0.1 dev eth1

重启下,再测试,OK!!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值