Additional network configuration

From freebsd.xn--wesstrm-f1a.se

Jump to: navigation, search

Contents

Overview

The network adapter that will connect to your internal LAN has not been configured yet so you'll have to do that now.

Instructions

If you're already using a home broadband router you're probably used to having an IP address of 192.168.0.x, where x is a number between 1 and 254. There are plenty of information on the Internet describing the inner workings of IP addresses, subnet masks and private networks so it won't be repeated here. You will have to choose an IP address for the internal interface of your new router but to simplify that process I will limit your options:

  • the first two groups of numbers have to be 192.168
  • the third group can be any number between and including 0 and 255
  • the last group has to be the number 1

The obvious choice would be to use 192.168.0.1 but there are technical reasons why you should consider something else than a 0 in the third group. In any case you have to choose an IP address belonging to another subnet than the one currently bound to your external interface. If you don't, the routing will break and you won't be able to connect to your new router.

For the examples in this tutorial I will use 192.168.69.1 as the IP address of the routers internal interface.

To set the IP address of the interface, you use the following command:

# ifconfig em0 inet 192.168.69.1/24

Replace em0 with the name of the internal interface of your own router and also adjust the IP address to whatever you choose. The inet means this is an IPv4 address and the /24 is just another way to define a subnet mask of 255.255.255.0. If no errors were reported you can check afterwards that everything went well.

# ifconfig em0
em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	options=9b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM>
	ether 00:0c:29:d1:92:64
	inet 192.168.69.1 netmask 0xffffff00 broadcast 192.168.69.255
	media: Ethernet autoselect
	status: no carrier

no carrier just means there is no cable attached to that interface yet.

You probably want this configuration to happen automatically every time you boot the router and /etc/rc.conf is the file to use for that. Type the command below to add the necessary info and note that it looks a little different than when the command is entered directly in the console.

# echo 'ifconfig_em0="inet 192.168.69.1/24"' >> /etc/rc.conf

Once again, adjust the name of the interface and the IP address to match your own configuration.

Summary

  • ifconfig is the command to configure network interfaces.
  • Adding a row like ifconfig_em0="inet 192.168.69.1/24" to /etc/rc.conf will configure that interface automatically at boot time.

References


Next guide: Name resolution
Personal tools