You are on page 1of 8

Not sure how or why this happened, but this can be easily fixed.

From a terminal open interfaces file sudo gedit /etc/network/interfaces add the following two lines if missing auto eth0 iface eth0 inet dhcp restart networking sudo /etc/init.d/networking restart service network-manager stop rm /var/lib/NetworkManager/NetworkManager.state service network-manager start sudo gedit /etc/network/interfaces add the following two lines if missing auto eth0 iface eth0 inet dhcp restart networking sudo /etc/init.d/networking restart rfkill unblock wifi auto lo eth0 iface lo inet loopback iface eth0 inet dhcp auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 192.168.1.200 netmask 255.255.255.0 gateway 192.168.1.2

Network Configuration

Ubuntu ships with a number of graphical utilities to configure your network devi ces. This document is geared toward server administrators and will focus on mana ging your network on the command line. Ethernet Interfaces Ethernet interfaces are identified by the system using the naming convention of ethX, where X represents a numeric value. The first Ethernet interface is typica lly identified as eth0, the second as eth1, and all others should move up in num erical order. Identify Ethernet Interfaces To quickly identify all available Ethernet interfaces, you can use the ifconfig command as shown below. ifconfig -a | grep eth eth0 Link encap:Ethernet HWaddr 00:15:c5:4a:16:5a Another application that can help identify all network interfaces available to y our system is the lshw command. In the example below, lshw shows a single Ethern et interface with the logical name of eth0 along with bus information, driver de tails and all supported capabilities. sudo lshw -class network *-network description: Ethernet interface product: BCM4401-B0 100Base-TX vendor: Broadcom Corporation physical id: 0 bus info: pci@0000:03:00.0 logical name: eth0 version: 02 serial: 00:15:c5:4a:16:5a size: 10MB/s capacity: 100MB/s width: 32 bits clock: 33MHz capabilities: (snipped for brevity) configuration: (snipped for brevity) resources: irq:17 memory:ef9fe000-ef9fffff Ethernet Interface Logical Names Interface logical names are configured in the file /etc/udev/rules.d/70-persiste nt-net.rules. If you would like control which interface receives a particular lo gical name, find the line matching the interfaces physical MAC address and modif y the value of NAME=ethX to the desired logical name. Reboot the system to commi t your changes. SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:15:c5:4a:16:5 a", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0" SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:15:c5:4a:16:5 b", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1" Ethernet Interface Settings ethtool is a program that displays and changes Ethernet card settings such as au to-negotiation, port speed, duplex mode, and Wake-on-LAN. It is not installed by default, but is available for installation in the repositories.

sudo apt-get install ethtool The following is an example of how to view supported features and configured set tings of an Ethernet interface. sudo ethtool eth0 Settings for eth0: Supported ports: [ TP ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Half 1000baseT/Full Supports auto-negotiation: Yes Advertised link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Half 1000baseT/Full Advertised auto-negotiation: Yes Speed: 1000Mb/s Duplex: Full Port: Twisted Pair PHYAD: 1 Transceiver: internal Auto-negotiation: on Supports Wake-on: g Wake-on: d Current message level: 0x000000ff (255) Link detected: yes Changes made with the ethtool command are temporary and will be lost after a reb oot. If you would like to retain settings, simply add the desired ethtool comman d to a pre-up statement in the interface configuration file /etc/network/interfa ces. The following is an example of how the interface identified as eth0 could be per manently configured with a port speed of 1000Mb/s running in full duplex mode. auto eth0 iface eth0 inet static pre-up /usr/sbin/ethtool -s eth0 speed 1000 duplex full [Note] Although the example above shows the interface configured to use the static meth od, it actually works with other methods as well, such as DHCP. The example is m eant to demonstrate only proper placement of the pre-up statement in relation to the rest of the interface configuration. IP Addressing The following section describes the process of configuring your systems IP addre ss and default gateway needed for communicating on a local area network and the Internet. Temporary IP Address Assignment For temporary network configurations, you can use standard commands such as ip, ifconfig and route, which are also found on most other GNU/Linux operating syste ms. These commands allow you to configure settings which take effect immediately , however they are not persistent and will be lost after a reboot. To temporarily configure an IP address, you can use the ifconfig command in the following manner. Just modify the IP address and subnet mask to match your netwo rk requirements.

sudo ifconfig eth0 10.0.0.100 netmask 255.255.255.0 To verify the IP address configuration of eth0, you can use the ifconfig command in the following manner. ifconfig eth0 eth0 Link encap:Ethernet HWaddr 00:15:c5:4a:16:5a inet addr:10.0.0.100 Bcast:10.0.0.255 Mask:255.255.255.0 inet6 addr: fe80::215:c5ff:fe4a:165a/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:466475604 errors:0 dropped:0 overruns:0 frame:0 TX packets:403172654 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:2574778386 (2.5 GB) TX bytes:1618367329 (1.6 GB) Interrupt:16 To configure a default gateway, you can use the route command in the following m anner. Modify the default gateway address to match your network requirements. sudo route add default gw 10.0.0.1 eth0 To verify your default gateway configuration, you can use the route command in t he following manner. route -n Kernel IP routing table Destination Gateway 10.0.0.0 0.0.0.0 0.0.0.0 10.0.0.1

Genmask 255.255.255.0 0.0.0.0

Flags Metric Ref U 1 0 UG 0 0

Use Iface 0 eth0 0 eth0

If you require DNS for your temporary network configuration, you can add DNS ser ver IP addresses in the file /etc/resolv.conf. The example below shows how to en ter two DNS servers to /etc/resolv.conf, which should be changed to servers appr opriate for your network. A more lengthy description of DNS client configuration is in a following section. nameserver 8.8.8.8 nameserver 8.8.4.4 If you no longer need this configuration and wish to purge all IP configuration from an interface, you can use the ip command with the flush option as shown bel ow. ip addr flush eth0 [Note] Flushing the IP configuration using the ip command does not clear the contents o f /etc/resolv.conf. You must remove or modify those entries manually. Dynamic IP Address Assignment (DHCP Client) To configure your server to use DHCP for dynamic address assignment, add the dhc p method to the inet address family statement for the appropriate interface in t he file /etc/network/interfaces. The example below assumes you are configuring y our first Ethernet interface identified as eth0. auto eth0 iface eth0 inet dhcp

By adding an interface configuration as shown above, you can manually enable the interface through the ifup command which initiates the DHCP process via dhclien t. sudo ifup eth0 To manually disable the interface, you can use the ifdown command, which in turn will initiate the DHCP release process and shut down the interface. sudo ifdown eth0 Static IP Address Assignment To configure your system to use a static IP address assignment, add the static m ethod to the inet address family statement for the appropriate interface in the file /etc/network/interfaces. The example below assumes you are configuring your first Ethernet interface identified as eth0. Change the address, netmask, and g ateway values to meet the requirements of your network. auto eth0 iface eth0 inet static address 10.0.0.100 netmask 255.255.255.0 gateway 10.0.0.1 By adding an interface configuration as shown above, you can manually enable the interface through the ifup command. sudo ifup eth0 To manually disable the interface, you can use the ifdown command. sudo ifdown eth0 Loopback Interface The loopback interface is identified by the system as lo and has a default IP ad dress of 127.0.0.1. It can be viewed using the ifconfig command. ifconfig lo lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:2718 errors:0 dropped:0 overruns:0 frame:0 TX packets:2718 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:183308 (183.3 KB) TX bytes:183308 (183.3 KB) By default, there should be two lines in /etc/network/interfaces responsible for automatically configuring your loopback interface. It is recommended that you k eep the default settings unless you have a specific purpose for changing them. A n example of the two default lines are shown below. auto lo iface lo inet loopback Name Resolution Name resolution as it relates to IP networking is the process of mapping IP addr

esses to hostnames, making it easier to identify resources on a network. The fol lowing section will explain how to properly configure your system for name resol ution using DNS and static hostname records. DNS Client Configuration To configure your system to use DNS for name resolution, add the IP addresses of the DNS servers that are appropriate for your network in the file /etc/resolv.c onf. You can also add an optional DNS suffix search-lists to match your network domain names. Below is an example of a typical configuration of /etc/resolv.conf for a server on the domain "example.com" and using two public DNS servers. search example.com nameserver 8.8.8.8 nameserver 8.8.4.4 The search option can also be used with multiple domain names so that DNS querie s will be appended in the order in which they are entered. For example, your net work may have multiple sub-domains to search; a parent domain of example.com, an d two sub-domains, sales.example.com and dev.example.com. If you have multiple domains you wish to search, your configuration might look l ike the following. search example.com sales.example.com dev.example.com nameserver 8.8.8.8 nameserver 8.8.4.4 If you try to ping a host with the name of server1, your system will automatical ly query DNS for its Fully Qualified Domain Name (FQDN) in the following order: server1.example.com server1.sales.example.com server1.dev.example.com If no matches are found, the DNS server will provide a result of notfound and th e DNS query will fail. Static Hostnames Static hostnames are locally defined hostname-to-IP mappings located in the file /etc/hosts. Entries in the hosts file will have precedence over DNS by default. This means that if your system tries to resolve a hostname and it matches an en try in /etc/hosts, it will not attempt to look up the record in DNS. In some con figurations, especially when Internet access is not required, servers that commu nicate with a limited number of resources can be conveniently set to use static hostnames instead of DNS. The following is an example of a hosts file where a number of local servers have been identified by simple hostnames, aliases and their equivalent Fully Qualifi ed Domain Names (FQDN's). 127.0.0.1 127.0.1.1 10.0.0.11 10.0.0.12 10.0.0.13 10.0.0.14 localhost ubuntu-server server1.example.com server2.example.com server3.example.com server4.example.com

server1 server2 server3 server4

vpn mail www file

[Note] In the above addition to vpn, server2 Name Service example, notice that each of the servers have been given aliases in their proper names and FQDN's. Server1 has been mapped to the name is referred to as mail, server3 as www, and server4 as file. Switch Configuration

The order in which your system selects a method of resolving hostnames to IP add resses is controlled by the Name Service Switch (NSS) configuration file /etc/ns switch.conf. As mentioned in the previous section, typically static hostnames de fined in the systems /etc/hosts file have precedence over names resolved from DN S. The following is an example of the line responsible for this order of hostnam e lookups in the file /etc/nsswitch.conf. hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4

files first tries to resolve static hostnames located in /etc/hosts. mdns4_minimal attempts to resolve the name using Multicast DNS. [NOTFOUND=return] means that any response of notfound by the preceeding mdns 4_minimal process should be treated as authoritative and that the system should not try to continue hunting for an answer. dns represents a legacy unicast DNS query. mdns4 represents a Multicast DNS query. To modify the order of the above mentioned name resolution methods, you can simp ly change the hosts: string to the value of your choosing. For example, if you p refer to use legacy Unicast DNS versus Multicast DNS, you can change the string in /etc/nsswitch.conf as shown below. hosts: Bridging Bridging multiple interfaces is a more advanced configuration, but is very usefu l in multiple scenarios. One scenario is setting up a bridge with multiple netwo rk interfaces, then using a firewall to filter traffic between two network segme nts. Another scenario is using bridge on a system with one interface to allow vi rtual machines direct access to the outside network. The following example cover s the latter scenario. Before configuring a bridge you will need to install the bridge-utils package. T o install the package, in a terminal enter: sudo apt-get install bridge-utils Next, configure the bridge by editing /etc/network/interfaces: auto lo iface lo inet loopback auto br0 iface br0 inet static address 192.168.0.10 network 192.168.0.0 netmask 255.255.255.0 files dns [NOTFOUND=return] mdns4_minimal mdns4

broadcast 192.168.0.255 gateway 192.168.0.1 bridge_ports eth0 bridge_fd 9 bridge_hello 2 bridge_maxage 12 bridge_stp off [Note] Enter the appropriate values for your physical interface and network. Now restart networking to enable the bridge interface: sudo /etc/init.d/networking restart The new bridge interface should now be up and running. The brctl provides useful information about the state of the bridge, controls which interfaces are part o f the bridge, etc. See man brctl for more information.