www.cnblogs.com/ruiyqinrui

开源、架构、Linux C/C++/python AI BI 运维开发自动化运维。 春风桃李花 秋雨梧桐叶。“力尽不知热 但惜夏日长”。夏不惜,秋不获。@ruiY--秦瑞

python爬虫,C编程,嵌入式开发.hadoop大数据,桉树,onenebula云计算架构.linux运维及驱动开发.

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
  2912 随笔 :: 9 文章 :: 51 评论 :: 185万 阅读

FreeBSD下增进静态路由的行动

1.手工添加
# route add -net 192.168.2.0/24 192.168.1.2
2. 通过rc.conf永世 设置
# Add static route
static_routes="net1 net2"
route_net1="-net 192.168.0.0/24 192.168.0.1"
route_net2="-net 192.168.1.0/24 192.168.1.1"
ifconfig_eth0="inet 192.168.1.253 netmask 255.255.255.0"
defaultrouter="192.168.1.254"

路由的属性符号 和它们的寄义 的一个简表:
U    Up: 路由处于活动状况 。
H    Host: 路由方针 是单个主机。
G    Gateway: 全部 发到方针地的网络传到这一长途 体系 上, 并由它决议 末了 发到那边。
S    Static: 这个路由是手工设置 的,不是由体系 主动 天生 的。
C    Clone: 天生 一个新的路由, 通过这个路由我们可以毗连 上这些机子。 这种范例 的路由通常用于内地 网络。
W    WasCloned: 指明一个路由——它是基于内地 区 域网络 (克隆) 路由主动 设置 的。
L    Link: 路由涉及到了以太网硬件。

Task: View / Display FreeBSD Routing Table

Use netstat command with -r option:
$ netstat -r
$ netstat -rn

Output:

Routing tables

Internet:
Destination        Gateway            Flags    Refs      Use  Netif Expire
default            61.221.xx.yy       UGS         0      247    em1
10                 10.10.110.5        UGS         0       50    em0
10.10.110/26       link#1             UC          0        0    em0
10.10.110.5        00:1b:0d:e6:58:40  UHLW        2        0    em0   1145
61.221.xx.yy/29    link#2             UC          0        0    em1
61.221.xx.yy       00:1b:0d:e6:57:c0  UHLW        2        0    em1   1055
61.221.xx/24       link#2             UC          0        0    em1
127.0.0.1          127.0.0.1          UH          0        0    lo0

The first two line displays default routes.

Task: FreeBSD Set a default route

All network packets that cannot be sent according to the previous entries of the routing table are sent through the following default gateway:
# route add default 192.168.1.254

How do I save routing information to a configuration file?

If you reboot FreeBSD box, the routing configuration will be lost i.e. the routing information will not persist. You need to edit /etc/rc.conf file to set defaultroute:
# vi /etc/rc.conf
Set default route by editing defaultrouter variable:
defaultrouter="192.168.1.254"
Save and close the file.

Task: Start and Stop FreeBSD Configured Interfaces

To apply changes to a configuration file, . The following command will also update routing information:
# /etc/rc.d/netif restart
# /etc/rc.d/netif stop
# /etc/rc.d/netif start

posted on   秦瑞It行程实录  阅读(780)  评论(0编辑  收藏  举报
编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
www.cnblogs.com/ruiyqinrui
点击右上角即可分享
微信分享提示