BSD Newsletter.com
   Front | Info | Lists | Newsfeeds | Study Guide | What is BSD?
Advertisement: The OpenBSD PF Packet Filter Book: PF for NetBSD, FreeBSD, DragonFly and OpenBSD

BSD Links
·New Links
·Advocacy
·Drivers
·Events
·Flavours
·FAQs
·Guides
·Programming
·Security
·Software
·User Groups

This is the BSDA Study Guide Book written via a wiki collaboration. This is a work in progress. You may contribute to or discuss this specific page at http://bsdwiki.reedmedia.net/wiki/Set_a_system__39__s_TCP--IP_settings.html.

Set a system's TCP/IP settings

Concept

Be able to modify required TCP/IP settings both temporarily and permanently in order to remain after a reboot.

Introduction

This chapter one of the most important because you as network administrator must know how to convert your hardware into real server. In this part you know how to set network settings in BSD box.

Examples

You can update IP on the fly manually and via DHCP server. You must be a root user for change IP and other network settings.

TODO: briefly mention DHCP and refer to section View and renew a DHCP lease. TODO: maybe move some of this to there?

# dhclient fxp0
DHCPREQUEST on fxp0 to 255.255.255.255 port 67
DHCPACK from 192.168.1.1
bound to 192.168.1.162 -- renewal in 302400 seconds.

Now we update our fxp0 interface IP via DHCP server. You may override default dhclient options in /etc/dhclient.conf. In environments where a static IP or DHCP is not available, you must manually configure a network interface:

# ifconfig fxp0 192.168.1.162 netmask 255.255.255.0

And check the status of this interface:

# ifconfig fxp0
fxp0: flags=8843 mtu 1500
       options=8
       inet 192.168.1.162 netmask 0xffffff00 broadcast 192.168.1.255
       ether 00:09:6b:13:42:9f
       media: Ethernet autoselect (100baseTX )
       status: active

The -a switch may be used to check the status of all interfaces.

You may save these settings on xBSD, yBSD and FreeBSD by adding an entry to /etc/rc.conf:

ifconfig_rl1="inet 192.168.51.50 netmask 255.255.255.0"
ifconfig_rl0_alias1="inet 192.168.231.2 netmask 255.255.255.0"
ifconfig_rl0_alias0="inet 10.1.1.1  netmask 255.255.255.252"

For OpenBSD, create an /etc/hostname.rl0 for the rl0 interface in OpenBSD:

192.168.51.50 netmask 255.255.255.0 up""
inet alias 192.168.231.2 255.255.255.0""
inet alias 10.1.1.1 255.255.255.252""

To configure xBSD, yBSD, and FreeBSD to use dhcp on startup:

??

And in OpenBSD, simply use the following entry in /etc/hostname.if:

"dhcp NONE NONE NONE

To bring up an interface according to the configuration files, use netstart:

# sh /etc/netstart rl0

DHCP servers often provide a default route. If dhcp is not in use, or a default route is not provided by the DHCP server, you must configure one manually. In xBSD, yBSD and FreeBSD, add:

defaultrouter="192.168.1.1"

to rc.conf. Similarly, in OpenBSD, add an entry to /etc/mygate:

echo 192.168.1.1 > /etc/mygate

you may check the routing table by using

# route -n show

The -n option discarding name resolution preventing long delays. You may add a default entry by keying in:

# route add default 192.168.1.1

For update DNS servers list you must update your resolv.conf file. This is typical file

# cat /etc/resolv.conf
nameserver 192.168.10.1
nameserver 10.10.10.13

TODO: don't cover DNS too much here.

For more information about DNS, see section Change the order of name resolution and ...TODO.

Firstly system try to resolve address with 192.168.10.1 and then with 10.10.10.13 (truly firstly with hosts file)

Practice Exercises

  1. Try to change your IP address
  2. Create alias for network interface
  3. Add DNS server.

More information

hostname (1), ifconfig(8), route(8), resolv.conf(5), rc.conf(5), hosts(5), hostname.if(5), myname(5), mygate(5), netstart(8)



Front | Information | Lists | Newsfeeds