Custom Search

Network Settings for Linux Basics + samples (6)

18. Debian / Ubuntu Network Configuration

Many of the core Fedora / Redhat commands and configuration files covered in this chapter can be used in Debian based operating systems, but there are some key differences.

The /etc/network/interfaces File
The main network configuration file is the /etc/network/interfaces file in which all the network interface parameters are defined. The file is divided into stanzas:

The auto Stanza
The auto stanza defines the interfaces that should be automatically initialized when the system boots up.

The mapping Stanza
This stanza maps configuration parameters for an interface depending on the output of a script. For example, on booting the script could prompt you as to whether your laptop Linux system is at home or work with the mapping statement using the answer to configure the appropriate IP address.
By default the much simpler hotplug system is used which assumes that the interfaces will have only one purpose. Typical hotplug configurations simply assign each physical interface with a matching logical interface name (nick name).
mapping hotplug
        script grep
        map eth0 eth0
        map eth1
In this case interface eth0 is specifically given the logical name eth0, while the logical name for eth1 is implied to be the same.

The iface Stanza
The iface stanza defines the characteristics of a logical interface. Typically the first line of these stanzas starts with the word iface, followed by the logical name of the interface, the protocol used, and finally the type of addressing scheme to be used, such as DHCP or static. Protocol keywords include inet for regular TCP/IP, inet6 for IPv6, ipx for the older IPX protocol used by Novell, and loopback for loopback addresses.
Subsequent lines in the stanza define protocol characteristics such as addresses, subnet masks, and default gateways. In this example, interface eth1 is given the IP address 216.10.119.240/27 while interface eth0 gets its IP address using DHCP.
# The primary network interface
auto eth1
iface eth1 inet static
        address 216.10.119.240
        netmask 255.255.255.224
        network 216.10.119.224
        broadcast 216.10.119.255
        gateway 216.10.119.241
        dns-nameservers 216.10.119.241

# The secondary network interface
auto eth0
iface eth0 inet dhcp
Note: When static IP addresses are used, a default gateway usually needs to be defined. Remember to place the gateway statement in the correct stanza with the appropriate router IP address.

Creating Interface Aliases
IP aliases can be easily created in the /etc/network/interfaces file once the main interface has already been defined. A modified duplicate of the main interfaces' iface stanza is required. A colon followed by the sub interface number needs to be added to the first line, and only the subnet mask and the new IP address needs to follow as can be seen in this example for interface eth1:1 with the IP address 216.10.119.239.
auto eth1:1
iface eth1:1 inet static
       address 216.10.119.239
       netmask 255.255.255.224

Adding Permanent Static Routes
The up option in the appropriate iface stanza of the /etc/network/interfaces file allows you to selectively run commands once the specified interface becomes activated with the ifup command. This makes it useful when adding permanent static routes.
In this example, a route to the 10.0.0.0/8 network via router address 216.10.119.225 has been added. Remember, the up option and the command must reside on the same line of the stanza.
# The primary network interface
auto eth1
iface eth1 inet static
        ...
        ...
        ...
        up route add -net 10.0.0.0 netmask 255.0.0.0 gw 216.10.119.225 eth1

A complete /etc/network/interfaces file
We can now construct a complete file based on the previous examples we discussed. Just like in Fedora, interfaces can be activated with the ifup and ifdown commands.
#
# Debian / Ubuntu
#

#
# File: /etc/network/interfaces
#

# The loopback network interface
auto lo
iface lo inet loopback

# This is a list of hotpluggable network interfaces.
# They will be activated automatically by the hotplug subsystem.
mapping hotplug
        script grep
        map eth0 eth0
        map eth1 eth1

# The primary network interface
auto eth1
iface eth1 inet static
        address 216.10.119.240
        netmask 255.255.255.224
        network 216.10.119.224
        broadcast 216.10.119.255
        gateway 216.10.119.241
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 216.10.119.241
        wireless-key 98d126d5ac
        wireless-essid schaaffe

        up route add -net 10.0.0.0 netmask 255.0.0.0 gw 216.10.119.225 eth1

auto eth1:1
iface eth1:1 inet static
        address 216.10.119.239
        netmask 255.255.255.224

# The secondary network interface
auto eth0
iface eth0 inet dhcp

For more information on the /etc/network/interfaces file just issue the command man interfaces from the command line.
dmesg shows the following:
[17189761.636000] e1000: eth0: e1000_watchdog: NIC Link is Down
[17189763.292000] e1000: eth0: e1000_watchdog: NIC Link is Up 100 Mbps Full Duplex

19. NTP Configuration


This section provides the configuration steps in each of the Unified Wireless Network devices that must be completed in order to configure NTP.
Note: Use the Command Lookup Tool ( registered customers only) to obtain more information on the commands used in this section.
Set Up NTP on the Location Appliance
Complete these steps in order to set up NTP on the Location Appliance, using the Linux resources that are already in the box:
Stop the Location Appliance service.
/etc/rc.d/init.d/locserverd stop

[root@loc-server root]#/etc/rc.d/init.d/locserverd stop
Shutting down locserverd: Request server shutdown now...
Waiting for server...2 secs
Waiting for server...4 secs
Server shutdown complete.
Set the time zone.
cp /usr/share/zoneinfo// /etc/localtime

[root@loc-server root]#cp /usr/share/zoneinfo/US/Eastern /etc/localtime
cp: overwrite `/etc/localtime'? y
[root@loc-server root]#
Add your NTP server in /etc/ntp.conf using a text editor. This example shows the vi editor.
[root@loc-server root]#vi /etc/ntp.conf
/ puts you in search mode. Enter server and press Enter in order to go to that location.
i puts you in insert mode. Position the cursor to point to a location under the existing server line. Press Enter in order to add a new line.
Enter server, then press Tab and enter the IP address of the NTP server.
In this example, the IP address of the NTP server is 172.22.1.216.
Press Esc in order to get out of insert mode.
Enter :wq and press Enter in order to write changes and quit the vi editor.
The file looks like this output. The line to change is the one that starts with server.
# --- GENERAL CONFIGURATION ---
#
# Undisciplined Local Clock. This is a fake driver intended for
# backup and when no outside source of synchronized time is
# available. The default stratum is usually 3, but in this case
# we elect to use stratum 0. Since the server line does not have
# the prefer keyword, this driver is never used for synchronization,
# unless no other other synchronization source is available. In case
# the local host is controlled by some external source, such as an
# external oscillator or another protocol, the prefer keyword would
# cause the local host to disregard all other synchronization sources,
# unless the kernel modifications are in use and declare an
# unsynchronized condition.
#
server 127.22.1.216     # local clock
Make sure that there is no time zone defined in /etc/sysconfig/clock. This example shows the use of the more command.
[root@loc-server etc]#more /etc/sysconfig/clock
# ZONE="UTC"
UTC=true
ARC=false
Notice that the line that starts with ZONE is commented out. If it is not, use an editor, such as vi, to add the # symbol at the beginning of the ZONE command in order to make the command be only a comment.
Turn on the config checker in order to make sure things are not misconfigured. Use the chkconfig ntpd on command.
[root@loc-server etc]#chkconfig ntpd on
    [root@loc-server etc]#
Restart the network in order to bring in the new time zone configuration.
/etc/rc.d/init.d/network restart

[root@loc-server root]#/etc/rc.d/init.d/network restart
Shutting down interface eth0:  [  OK  ]
Shutting down loopback interface:  [  OK  ]
Setting network parameters:  [  OK  ]
Bringing up loopback interface:  ip_tables: (C) 2000-2002 Netfilter
  core team [OK]
Bringing up interface eth0:  ip_tables: (C) 2000-2002 Netfilter
  core team [OK]
[root@loc-server root]#
Restart the NTP daemon in order to bring in the new settings.
/etc/rc.d/init.d/ntpd restart

[root@loc-server root]#/etc/rc.d/init.d/ntpd restart
Shutting down ntpd: [  OK  ]
Starting ntpd: [  OK  ]
[root@loc-server root]#
Initially seed the NTP process with the time.
ntpdate -u

[root@loc-server etc]#ntpdate -u 172.22.1.216
28 Mar 17:35:27 ntpdate[2947]: step time server 172.22.1.216 offset
  1.766436 sec
Restart the Location Appliance service.
/etc/rc.d/init.d/locserverd start

[root@loc-server etc]#/etc/rc.d/init.d/locserverd start
Starting locserverd:
[root@loc-server etc]#
NTP
In unix there are two clocks, the hardware clock (bios) and the system clock.
To display the two clocks do the following
1) go to epert mode
2) type /bin/sh
3) type the following
hwclock
date
Your system clock should be synced to NTP, so I suspect you will want to set the HW clock to the system clock type. To do this type
hwclock --systohc

No comments:

 
Custom Search