FreeBSD Set a Default route/gateway

Source: Internet
Author: User

FreeBSD Set a Default route/gateway

by Nixcraft on January 13, 2008 • 7 COMMENTS· Last UPDATED October,

In FREEBSD, NETWORKING, troubleshooting

Q. How does I modify or set a default route for my FreeBSD server? How does I make default route configuration persistent?

A. the route command is used under FreeBSD to manually manipulate the network routing tables. It provides six commands:
= = Add : Add a route.

= = Flush : Remove all routes.

= = Delete : Delete a specific route.

= Change: Change aspects of a route (such as its gateway).

= = Get : Lookup and display the route for a destination.

= = Monitor : Continuously report no changes to the routing information base, routing lookup misses, or Suspec Ted Network Partitionings.

Task:view/display FreeBSD Routing Table

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

Output:

Routing tablesinternet:destination        Gateway            flags    Refs      use  netif expiredefault            61.221. Xx.yy       ugs         0      247    em110                 10.10.110.5        ugs         0    em010.10.110/26       link# 1             UC          0        0    em010.10.110.5        00:1b:0d:e6:58:40  uhlw        2        0    em0   114561.221.xx.yy/29    link#2             UC          0        0    em161.221.xx.yy       00:1b:0d:e6:57:c0  UHLW        2        0    em1   105561.221.xx/24       link#2             UC          0        0    em1127.0.0.1          127.0.0.1          UH          0        0    lo0

The first and the line displays default routes.

Task:freebsd Set a default route

All network packets cannot is sent according to the previous entries of the routing table is sent through the follow ing default gateway:
# route add default 192.168.1.254

How does I save routing information to a configuration file?

If You reboot FreeBSD box, the routing configuration would be lost i.e. the routing information would 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, you need to stop and restart the corresponding FreeBSD networking interface. The following command would also update routing information:
# /etc/rc.d/netif restart
# /etc/rc.d/routing stop
# /etc/rc.d/routing start

Source: >  



From for notes (Wiz)

FreeBSD Set a Default route/gateway

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.