centos7 默认路由顺序调整(IPV4_ROUTE_METRIC)

1、问题说明

A服务器有两张网卡,A1对应公网,A2对应私网,公网访问时,访问异常,内网访问服务则显示正常。

问题判断:数据包从公网进来时,路由无需判断,但数据包出去时,有两个网口皆可出去,如果出去的数据包走了默认路由,那就出不去。因此判断问题出现在系统的默认路由配置上。


-----数据包入---->--->--->----------|------公网----------------------------------------------
             -------<---<----<-----|------内网---------数据包出------------默认路由-----------

2、验证设想

[root@idszt-node001 ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.240.1   0.0.0.0         UG    104    0        0 ens1f1
0.0.0.0         113.98.244.1*1  0.0.0.0         UG    105    0        0 ens1f0
113.98.244.160  0.0.0.0         255.255.255.224 U     105    0        0 ens1f0
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
172.19.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-5bbdc4e99100
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0
192.168.240.0   0.0.0.0         255.255.255.0   U     104    0        0 ens1f1

cd /etc/sysconfig/network-scripts
vi ifcfg-ens1f0
# 添加以下配置,设置ens1f0优先级在ens1f1之前
IPV4_ROUTE_METRIC="103"

[root@idszt-node001 network-scripts]# ifdown enp2s0f0
用法:ifdown <设备名>
[root@idszt-node001 network-scripts]# ifdown ens1f0
成功断开设备 "ens1f0"[root@idszt-node001 network-scripts]# ifup ens1f0
连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/15)

# 路由调整后
[root@idszt-node001 network-scripts]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         113.98.244.1*1  0.0.0.0         UG    103    0        0 ens1f0
0.0.0.0         192.168.240.1   0.0.0.0         UG    104    0        0 ens1f1
113.98.244.160  0.0.0.0         255.255.255.224 U     103    0        0 ens1f0
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
172.19.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-5bbdc4e99100
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0
192.168.240.0   0.0.0.0         255.255.255.0   U     104    0        0 ens1f1

重启网卡:service network restart

3、总结

将公网的网卡路由优先级设计为最高即可。

[root@idszt-node001 network-scripts]# ifconfig
ens1f0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 113.98.244.1*0  netmask 255.255.255.224  broadcast 113.98.244.1*1
        inet6 fe80::d1bb:57a4:aa28:2dd9  prefixlen 64  scopeid 0x20<link>
        ether c4:b8:b4:b5:73:d1  txqueuelen 1000  (Ethernet)
        RX packets 506382  bytes 31938370 (30.4 MiB)
        RX errors 0  dropped 31937  overruns 0  frame 0
        TX packets 26388  bytes 2608732 (2.4 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0xab500000-ab5fffff
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
华为路由模拟软件,更换的学习路由配置 大家可以下一个华为MA5200G模拟器进行实验 具体的命令和解释我全写出来了 首先给大家收集了一些交换机的基本命令具体命令解释我已经给出了 通常命令: PCA login: root ;使用root用户 password: linux ;口令是linux # shutdown -h now ;关机 # init 0 ;关机 # logout # login # ifconfig ;显示IP地址 # ifconfig eth0 <ip address> netmask <netmask> ;设置IP地址 # ifconfig eht0 <ip address> netmask <netmask> down ; 删除IP地址 # route add 0.0.0.0 gw <ip> # route del 0.0.0.0 gw <ip> # route add default gw <ip> ;设置网关 # route del default gw <ip> ;删除网关 # route ;显示网关 # ping <ip> # telnet <ip> ;建议telnet之前先ping一下 --------------------------------------- 交换机命令 ~~~~~~~~~~ [Quidway]super password 修改特权用户密码 [Quidway]sysname 交换机命名 [Quidway]interface ethernet 0/1 进入接口视图 [Quidway]interface vlan x 进入接口视图 [Quidway-Vlan-interfacex]ip address 10.65.1.1 255.255.0.0 [Quidway]ip route-static 0.0.0.0 0.0.0.0 10.65.1.2 静态路由=网关 [Quidway]user-interface vty 0 4 [S3026-ui-vty0-4]authentication-mode password [S3026-ui-vty0-4]set authentication-mode password simple 222 [S3026-ui-vty0-4]user privilege level 3 [Quidway-Ethernet0/1]duplex {half|full|auto} 配置端口双工工作状态 [Quidway-Ethernet0/1]speed {10|100|auto} 配置端口工作速率 [Quidway-Ethernet0/1]flow-control 配置端口流控 [Quidway-Ethernet0/1]mdi {across|auto|normal} 配置端口MDI/MDIX状态平接或扭接 [Quidway-Ethernet0/1]port link-type {trunk|access|hybrid} 设置接口工作模式 [Quidway-Ethernet0/1]shutdown 关闭/重起接口 [Quidway-Ethernet0/2]quit 退出系统视图 [Quidway]vlan 3 创建/删除一个VLAN/进入VLAN模式 [Quidway-vlan3]port ethernet 0/1 to ethernet 0/4 在当前VLAN增加/删除以太网接口 [Quidway-Ethernet0/2]port access vlan 3 将当前接口加入到指定VLAN [Quidway-Ethernet0/2]port trunk permit vlan {ID|All} 设trunk允许的VLAN [Quidway-Ethernet0/2]port trunk pvid vlan 3 设置trunk端口的PVID [Quidway]monitor-port <interface_type interface_num> 指定和清除镜像端口 [Quidway]port mirror <interface_type interface_num> 指定和清除被镜像端口 [Quidway]port mirror int_list observing-port int_type int_num 指定镜像和被镜像 [Quidway]description string 指定VLAN描述字符 [Quidway]description 删除VLAN描述字符 [Quidway]display vlan [vlan_id] 查看VLAN设置 [Quidway]stp {enable|disable} 开启/关闭生成树,默认关闭 [Quidway]stp priority 4096 设置交换机的优先级 [Quidway]stp root {primary|secondary} 设置交换机为根或根的备份 [Quidway-Ethernet0/1]stp cost 200 设置交换机端口的花费 [SwitchA-vlanx]isolate-user-vlan enable 设置主vlan [SwitchA]Isolate-user-vlan <x> secondary <list> 设置主vlan包括的子vlan [Quidway-Ethernet0/2]port hybrid pvid vlan <id> 设置vlan的pvid [Quidway-Ethernet0/2]port hybrid pvid 删除vlan的pvid [Quidway-Ethernet0/2]port hybrid vlan vlan_id_list untagged 设置无标识的vlan 如果包的vlan id与PVId一致,则去掉vlan信息. 默认PVID=1。 所以设置PVID为所属vlan id, 设置可以互通的vlan为untagged. 计算机的命令: 计算机命令 ~~~~~~~~~~ PCA login: root ;使用root用户 password: linux ;口令是linux # shutdown -h now ;关机 # init 0 ;关机 # logout # login # ifconfig ;显示IP地址 # ifconfig eth0 <ip address> netmask <netmask> ;设置IP地址 # ifconfig eht0 <ip address> netmask <netmask> down ; 删除IP地址 # route add 0.0.0.0 gw <ip> # route del 0.0.0.0 gw <ip> # route add default gw <ip> ;设置网关 # route del default gw <ip> ;删除网关 # route ;显示网关 # ping <ip> # telnet <ip> ;建议telnet之前先ping一下 下面是一个小的实验具体内容做了解释 一个交换机,一个计算机,双击交换机,进入终端配置: <Quidway>system password: [Quidway]sysname S3026 ;交换机命名 [S3026]super password 111 ;设置特权密码 [S3026]user-interface vty 0 4 /*进入虚拟终端接口配置模式*/ [S3026-ui-vty0-4]authentication-mode password /*这里我使用的是aaa的认证模式,可选用none 也就是不认证,和passowrd 密码认证这三种,推荐选择aaa 和 password */ /*set auth pass cipher xxxxx 如果你选择的是password认证方式,则要设置一个密码*/ /*user privilege level 3 设置telnet登录级别为3级, */ /*这两步只要选用password时需要使用*/ local-aaa-server /*进行本地3a服务器视图*/ [S3026-ui-vty0-4]set authentication-mode password simple 222 [S3026-ui-vty0-4]user privilege level 3 [S3026-ui-vty0-4]quit [S3026]quit <S3026>sys password:111 [S3026]display currect-config /*显示当前配置*/ [S3026]dis curr /*显示当前配置*/ [S3026]vlan 2 [S3026-vlan2]port ethernet0/2 [S3026-vlan2]port e0/4 to et0/6 在当前VLAN增加/删除以太网接口 [S3026-vlan2]quit [S3026]dis vlan [S3026]int e0/3 [S3026-Ethernet1]port access vlan 2 将当前接口加入到指定VLAN [S3026-Ethernet1]quit [S3026]dis vlan 查看VLAN设置 [S3026]dis curr [S3026]interface vlan 1 [S3026-Vlan-interface1]ip address 10.65.1.8 255.255.0.0 [S3026-Vlan-interface1]quit [S3026]ip route-static 0.0.0.0 0.0.0.0 10.65.1.2 [S3026]ip default-gateway 10.65.1.2 [S3026]dis curr [S3026]save 双击小电脑: login:root password:linux [root@PCA root]#ifconfig eth0 10.65.1.35 netmask 255.255.0.0 ifconfig eth0 192.168.1.35 netmask 255.255.255.0 [root@PCA root]#ifconfig [root@PCA root]#route add default gw 10.65.1.2 [root@PCA root]#route [root@PCA root]#ping 10.65.1.8 [root@PCA root]#telnet 10.65.1.8
一个典型的Haproxy_exporter的监控metric例子 包含指标 haproxy_backend_bytes_in_total haproxy_backend_bytes_out_total haproxy_backend_client_aborts_total haproxy_backend_compressor_bytes_bypassed_total haproxy_backend_compressor_bytes_in_total haproxy_backend_compressor_bytes_out_total haproxy_backend_connection_errors_total haproxy_backend_current_queue haproxy_backend_current_server haproxy_backend_current_session_rate haproxy_backend_current_sessions haproxy_backend_http_connect_time_average_seconds haproxy_backend_http_queue_time_average_seconds haproxy_backend_http_response_time_average_seconds haproxy_backend_http_responses_compressed_total haproxy_backend_http_responses_total haproxy_backend_http_total_time_average_seconds haproxy_backend_response_errors_total haproxy_backend_retry_warnings_total haproxy_backend_server_aborts_total haproxy_backend_server_selected_total haproxy_backend_sessions_total haproxy_backend_up haproxy_backend_weight haproxy_exporter_build_info haproxy_exporter_csv_parse_failures haproxy_exporter_total_scrapes haproxy_frontend_bytes_in_total haproxy_frontend_bytes_out_total haproxy_frontend_compressor_bytes_bypassed_total haproxy_frontend_compressor_bytes_in_total haproxy_frontend_compressor_bytes_out_total haproxy_frontend_connections_total haproxy_frontend_current_session_rate haproxy_frontend_current_sessions haproxy_frontend_http_requests_total haproxy_frontend_http_responses_compressed_total haproxy_frontend_http_responses_total haproxy_frontend_limit_session_rate haproxy_frontend_limit_sessions haproxy_frontend_max_session_rate haproxy_frontend_max_sessions haproxy_frontend_request_errors_total haproxy_frontend_requests_denied_total haproxy_frontend_sessions_total haproxy_server_bytes_in_total haproxy_server_bytes_out_total haproxy_server_check_duration_seconds haproxy_server_check_failures_total haproxy_server_client_aborts_total haproxy_server_connection_errors_total haproxy_server_current_queue haproxy_server_current_session_rate haproxy_server_current_sessions haproxy_server_downtime_seconds_total haproxy_server_http_responses_total haproxy_server_max_queue haproxy_server_max_session_rate haproxy_server_max_sessions haproxy_server_redispatch_warnings_total haproxy_server_response_errors_total haproxy_server_retry_warnings_total haproxy_server_server_aborts_total haproxy_server_server_selected_total haproxy_server_sessions_total haproxy_server_up haproxy_server_weight haproxy_up process_cpu_seconds_total process_max_fds process_open_fds process_resident_memory_bytes process_start_time_seconds process_virtual_memory_bytes promhttp_metric_handler_requests_in_flight promhttp_metric_handler_requests_total

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值