FreeBSD: How To Start / Restart / Stop Network and Routing Service

by nixcraft · 6 comments

FreeBSD is a Unix-like free operating system. You can install to choose third party software on FreeBSD from the Ports Collection. Many services such as POP3 server daemons, IMAP, etc. could be started using the inetd.

However, networking can be stop or started using special script located in /etc/rc.d/ directory. This directory includes script to stop or start network, and other services such as SSH server.

FreeBSD 5.x/6.x and above version - start or stop network

FreeBSD 5.x/6.x and above version comes with netif script to start, restart, stop network service. You need to login as a root user. Then you can use following commands:

To start FreeBSD network service:
# /etc/rc.d/netif start
To stop FreeBSD network service:
# /etc/rc.d/netif stop
To restart FreeBSD network service:
# /etc/rc.d/netif restart

Manual method using ifconfig

To stop network card (NIC) on-fly:
# ifconfig network-interface down
To start network card (NIC) on fly:
# ifconfig network-interface up
To list down network interface:
# ifconfig -d
To list up network interface:
# ifconfig -u

FreeBSD Update / restart routing tables / service

It is also necessary to update routing table after restating networking service, enter:
# /etc/rc.d/routing restart

How do I restart network service over ssh session?

You need to type the commands as follows in order to avoid any problems:
# /etc/rc.d/netif restart && /etc/rc.d/routing restart

FreeBSD 4.x and prior version only - start, restart, stop network service

1) To start network service under FreeBSD you need to copy special
script as follows:

# cp /usr/share/examples/etc/netstart /etc/network

2) Execute script:

. /etc/network

OR

sh /etc/network

Please note that script will do all necessary work for you i.e. it will start network, routing, firewall etc.

Featured Articles:

Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our weekly newsletter here!

{ 6 comments… read them below or add one }

1 Anonymous 02.06.06 at 6:33 pm

Whats the difference between /etc/netstart and /etc/rc.d/netif for restarting networking?

2 nixcraft 02.06.06 at 7:15 pm

/etc/netstart is old method and does not support all the options (like stop, restart etc), which is now supported by /etc/rc.d/netif script. Ease of use is main difference between two.

3 ELF 05.29.07 at 1:21 pm

Thank you very mach :-)

4 tech 07.29.08 at 10:03 am

You need to type the commands as follows in order to avoid any problems:
# /etc/rc.d/networking restart && /etc/rc.d/routing restart

The right way is:
# /etc/rc.d/netif restart && /etc/rc.d/routing restart

I am right?

5 vivek 07.29.08 at 11:36 am

Yes, you are right. It was typo on my part and the post has been updated.

I appreciate your feedback and post.

6 tamas 03.20.09 at 7:24 pm

Hi!
Thank you for the easy to unterstand articles.
I try to use vlans. How can I ‘restart’ the virtual interface? The command /etc/rc.d/netif restart vlan5 not works for me.
Another vlan question: what about interfaces? Must have the external/real/physical interface an address?

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Previous post:

Next post: