RockyLinux 8 双网卡网络配置

派派是只大橘喵
派派是只大橘喵
发布于 2023-09-26 / 217 阅读 / 0 评论 / 0 点赞

RockyLinux 8 双网卡网络配置

RockyLinux 8 双网卡网络配置

现在有一台linux电脑做all in one server,两张网卡,一张万兆连接存储(无外网),一张千兆用于连接外网

现在的需求是 只有网络存储经过万兆 其余流量全部走 千兆网卡

配置如下

ifconfig命令输出如下

[root@localhost ~]# ifconfig

eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.3.9  netmask 255.255.255.0  broadcast 192.168.3.255

        inet6 fe80::ec4:7aff:fe03:f46a  prefixlen 64  scopeid 0x20<link>

        ether 0c:c4:7a:03:f4:6a  txqueuelen 1000  (Ethernet)

        RX packets 506  bytes 40853 (39.8 KiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 875  bytes 109464 (106.8 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

        device memory 0xf7400000-f747ffff

eno2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        ether 88:88:88:88:87:88  txqueuelen 1000  (Ethernet)

        RX packets 40  bytes 6607 (6.4 KiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 0  bytes 0 (0.0 B)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

        device interrupt 20  memory 0xf5100000-f5120000  

enp6s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 10.10.10.10  netmask 255.255.255.255  broadcast 0.0.0.0

        inet6 fe80::92e2:baff:fe8c:1e1a  prefixlen 64  scopeid 0x20<link>

        ether 90:e2:ba:8c:1e:1a  txqueuelen 1000  (Ethernet)

        RX packets 167  bytes 30001 (29.2 KiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 293  bytes 32510 (31.7 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eno1 和 eno2 是主板自带千兆

enp6s0是pcie万兆网卡

在 /etc/sysconfig/network-scripts 下找到各个网卡配置文件 配置如下

[root@localhost network-scripts]# cat ifcfg-eno1

TYPE=Ethernet

PROXY_METHOD=none

BROWSER_ONLY=no

BOOTPROTO=static

IPADDR=192.168.3.9

GATEWAY=192.168.3.1

NETMASK=255.255.255.0

IPV4_FAILURE_FATAL=no

NAME=eno1

UUID=920b6ce5-4450-4a9b-b77f-06d4feb35112

DEVICE=eno1

ONBOOT=yes

万兆网卡配置如下

[root@localhost network-scripts]# cat ifcfg-enp6s0

TYPE=Ethernet

PROXY_METHOD=none

BROWSER_ONLY=no

BOOTPROTO=static

IPADDR=10.10.10.10

NETMASK=255.255.255.255

IPV4_FAILURE_FATAL=no

NAME=enp6s0

UUID=ad821f48-6f2a-4091-ba71-fffdd90ae5ec

DEVICE=enp6s0

ONBOOT=yes

这两个卡都是静态分配的地址 只不过网段略有区别

除此之外还需要配置对应路由

#在网络配置下可以看到 网卡的路由配置文件

[root@localhost network-scripts]# ll

total 20

-rw-r--r--  1 root root 223 Jul 17 01:31 ifcfg-eno1

-rw-r--r--. 1 root root 243 Jul 16 22:25 ifcfg-eno2

-rw-r--r--  1 root root 209 Jul 17 02:14 ifcfg-enp6s0

-rw-r--r--  1 root root  48 Jul 17 02:09 route-eno1

-rw-r--r--  1 root root  26 Jul 17 12:46 route-enp6s0

#查看千兆网卡路由,配置的是一个默认路由,所有流量都走 192.168.3.1这个网关 eno1这个设备

[root@localhost network-scripts]# cat route-eno1

0.0.0.0 netmask 0.0.0.0 gw 192.168.3.1 dev eno1

#查看万兆网卡配置,发现配置的是一个特殊路由 只有10.10.10.2的流量走 enp6s0

[root@localhost network-scripts]# cat route-enp6s0

10.10.10.2/32 dev enp6s0

#看一下路由

[root@localhost network-scripts]# netstat -r

Kernel IP routing table

Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface

default         _gateway        0.0.0.0         UG        0 0          0 eno1

10.10.10.2      0.0.0.0         255.255.255.255 UH        0 0          0 enp6s0

192.168.3.0     0.0.0.0         255.255.255.0   U         0 0          0 eno1

到这里就表示 所有流量都默认走eno1 也就是第一条路有,只有10.10.10.2走enp6s0,也就是万兆网卡


评论