FreeBSD-11.2 routing and networks

John Johnstone jjohnstone at
Mon Jan 7 20:12:16 UTC 2019

On 1/7/19 11:15 AM, James B. Byrne via freebsd-questions wrote:
> On Mon, January 7, 2019 11:06, Odhiambo Washington wrote:
>> On Mon, 7 Jan 2019 at 19:01, James B. Byrne via freebsd-questions <
>> freebsd-questions at> wrote:
>>> I am working on a FreeBSD-11.2p17 host where I must change the IP
>>> address and gateway frequently to carry out tests.  Following making
>>> such changes I have tried resetting the network interfaces and
>>> routing tables by use of the command:
>>> service netif restart && service routing restart &
>>> However, I have discovered that this does not have the desired
>>> effect and I am reduced to restarting the host system to make
>>> such changes.

> As it happens, for the moment this case is true, I do have console
> access.  However, the configuration testing that I am doing locally
> will need to be applied to a remote host at some point, and the
> console will not be an option. Is there no way to make FreeBSD reset
> the network connection and routing tables remotely?

Might be better to give more details about your "desired effect".

Changes to IP address and gateway via ifconfig and route commands like

ifconfig bce0
route [add][change] default

take place immediately.  If you do an ifconfig and netstat -rn before 
your changes and then do them afterwards to verify you can confirm 
what's being done.

There are some consequences that aren't obvious.  One being the fact 
that the when you change the IP of an interface that is used for your 
default gateway, the default gateway is removed.  You can see this by 
doing a netstat -rn, change your IP with ifconfig, and then do the 
netstat again.

But if you were logged in remotely with IP routing taking place between 
you and your box via your default gateway, as soon as you change your 
IP, you'll orphan yourself because your box has no way to reach you 
because your default gateway is gone.

I haven't used service netif restart remotely but I would expect that 
you would loose your connection if it was going through the default 
gateway just as if you issued the ifconfig command manually.  It has the 
advantage though of taking the IP and gateway simultaneously from 
rc.conf which allows you to re-establish your connection to the box 
again after the changes are in effect.

John J.

More information about the freebsd-questions mailing list