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 typically identified as eth0, the second as eth1, and all others should move up in numerical order.Identify Ethernet Interfaces
ifconfig -a | grep eth
eth0      Link encap:Ethernet  HWaddr 00:15:c5:4a:16:5a
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
/etc/udev/rules.d/70-persistent-net.rules.  If you would 
   like control which interface receives a particular logical name, find the line 
   matching the interfaces physical MAC address and modify the value of 
   NAME=ethX to the desired logical name. 
   Reboot the system to commit your changes.
   SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:15:c5:4a:16:5a", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:15:c5:4a:16:5b", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
Ethernet Interface Settings
sudo apt-get install ethtool
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
/etc/network/interfaces. 
   The following is an example of how the interface identified as eth0 could be permanently 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]](https://help.ubuntu.com/10.04/libs/admon/note.png)  | |
| Although the example above shows the interface configured to use the static method, it actually works with other methods as well, such as DHCP. The example is meant to demonstrate only proper placement of the pre-up statement in relation to the rest of the interface configuration. | 
IP Addressing
Temporary IP Address Assignment
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 network requirements.
sudo ifconfig eth0 10.0.0.100 netmask 255.255.255.0
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 
sudo route add default gw 10.0.0.1 eth0
route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.0.0.0        0.0.0.0         255.255.255.0   U     1      0        0 eth0
0.0.0.0         10.0.0.1        0.0.0.0         UG    0      0        0 eth0
/etc/resolv.conf. The example below 
   shows how to enter two DNS servers to /etc/resolv.conf, which 
   should be changed to servers appropriate 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.4If 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 below.
ip addr flush eth0
| ![[Note]](https://help.ubuntu.com/10.04/libs/admon/note.png)  | |
| Flushing the IP configuration using the ip command does not clear the 
   contents of /etc/resolv.conf.  You must remove or modify those entries manually. | 
Dynamic IP Address Assignment (DHCP Client)
/etc/network/interfaces.
   The example below assumes you are configuring your first Ethernet interface identified as 
   eth0.
   auto eth0 iface eth0 inet dhcpBy adding an interface configuration as shown above, you can manually enable the interface through the ifup command which initiates the DHCP process via dhclient.
sudo ifup eth0
sudo ifdown eth0
Static IP Address Assignment
/etc/network/interfaces. 
   The example below assumes you are configuring your first Ethernet interface identified as 
   eth0.  Change the address, 
   netmask, and gateway 
   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.1By adding an interface configuration as shown above, you can manually enable the interface through the ifup command.
sudo ifup eth0
sudo ifdown eth0
Loopback Interface
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)
/etc/network/interfaces 
   responsible for automatically configuring your loopback interface. It is recommended that you 
   keep the default settings unless you have a specific purpose for changing them.  An example of 
   the two default lines are shown below.
   auto lo iface lo inet loopback
Name Resolution
DNS Client Configuration
/etc/resolv.conf. 
   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.4The search option can also be used with multiple domain names so that DNS queries will be appended in the order in which they are entered. For example, your network may have multiple sub-domains to search; a parent domain of example.com, and two sub-domains, sales.example.com and dev.example.com.
If you have multiple domains you wish to search, your configuration might look like the following.
search example.com sales.example.com dev.example.com nameserver 8.8.8.8 nameserver 8.8.4.4If you try to ping a host with the name of server1, your system will automatically query DNS for its Fully Qualified Domain Name (FQDN) in the following order:
- 
                        
   server1.example.com
   
 
- 
                        
   server1.sales.example.com
   
 
- 
                        
   server1.dev.example.com
   
 
Static Hostnames
/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 entry in /etc/hosts, it will not attempt to look up the
   record in DNS.  In some configurations, especially when Internet access is not required, servers that 
   communicate 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 Qualified Domain Names (FQDN's).
   127.0.0.1 localhost 127.0.1.1 ubuntu-server 10.0.0.11 server1 vpn server1.example.com 10.0.0.12 server2 mail server2.example.com 10.0.0.13 server3 www server3.example.com 10.0.0.14 server4 file server4.example.com
| ![[Note]](https://help.ubuntu.com/10.04/libs/admon/note.png)  | |
| In the above example, notice that each of the servers have been given aliases in addition to their proper names and FQDN's. Server1 has been mapped to the name vpn, server2 is referred to as mail, server3 as www, and server4 as file. | 
Name Service Switch Configuration
/etc/nsswitch.conf.
   As mentioned in the previous section, typically static hostnames defined in the systems 
   /etc/hosts file have precedence over names resolved from DNS. The following 
   is an example of the line responsible for this order of hostname 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 
   mdns4_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.
   
 
/etc/nsswitch.conf 
   as shown below.
   hosts: files dns [NOTFOUND=return] mdns4_minimal mdns4
Bridging
Before configuring a bridge you will need to install the bridge-utils package. To 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
        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]](https://help.ubuntu.com/10.04/libs/admon/note.png)  | |
| Enter the appropriate values for your physical interface and network. | 
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 of the bridge, etc.  See man brctl 
        for more information.        
         
