Difference between revisions of "Ubuntu networking"

From Ever changing code
Jump to navigation Jump to search
Line 136: Line 136:


=== Links and references ===
=== Links and references ===
[https://help.ubuntu.com/10.04/serverguide/network-configuration.html Ubuntu 10.04 network-configuration Wiki] the most used here
*[https://help.ubuntu.com/10.04/serverguide/network-configuration.html Ubuntu 10.04 network-configuration Wiki] the most used here
[http://ubuntuguide.org/wiki/Ubuntu_Precise_Network_Management Ubuntu_Precise_Network_Management]
*[http://ubuntuguide.org/wiki/Ubuntu_Precise_Network_Management Ubuntu_Precise_Network_Management]

Revision as of 00:22, 27 August 2013

IP addressing

Temporary set IP address

sudo ifconfig eth0 192.168.100.2/24 up
sudo ifconfig eth0 192.168.100.2 netmask 255.255.255.0

Temporary add default GW

sudo route add default gw 192.168.100.1 eth0

To verify your default gateway configuration, you can use the route command in the following manner.

route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.100.1   0.0.0.0         UG    0      0        0 eth0
192.168.100.0   0.0.0.0         255.255.255.0   U     1      0        0 eth0

DNS for your temporary network configuration, you can add DNS server IP addresses in the file /etc/resolv.conf. Please bear in mind these changes will be overwritten.

echo "nameserver 8.8.8.8" >> /etc/resolv.conf
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 below:

ip addr flush eth0

Permanent changes to IP address are saved in /etc/network/interfaces This requires live dump from Dell D620 laptop...........

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
	address 	192.168.100.2 	
	netmask 	255.255.255.0 	
	network 	192.168.100.0	
	broadcast 	192.168.100.255	
	gateway 	192.168.100.1
	dns-nameservers 192.168.100.1 8.8.8.8

Wireless from command line

Manual configuration from the command-line

3 steps for WEP
sudo iwconfig eth[N] essid [SSID]
sudo iwconfig eth[N] key restricted s:[PASSWORD]
sudo dhclient
WPA is more complicated
sudo mkdir /etc/wpa_supplicant
cd /etc/wpa_supplicant
sudo echo network = { > wpa_supplicant.conf
sudo echo ssid="SSID" >> wpa_supplicant.conf
sudo echo key_mgmt=WPA-PSK >> wpa_supplicant.conf
sudo echo psk="PRESHAREDKEY" >> wpa_supplicant.conf
sudo echo } >> wpa_supplicant.conf
cd /etc/network
sudo gedit interfaces

Now add after "auto eth[N] ..." & "iface eth[N] .." :

wpa-driver wext # or whatever driver your network card needs
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

Save the file and restart networking sudo service networking restart

Networking Tools

nm-tool - utility to report NetworkManager state and devices, it provides information about NM, device and wireless networks.

Ethernet Interfaces wip... add D620 output ...

Identify Ethernet Interfaces

lshw shows here an interface with the logical name of eth0 along with bus information, driver details 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-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

ethtool is a program that displays and changes Ethernet card settings such as auto-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 settings 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 reboot. If you would like to retain settings, simply add the desired ethtool command to a pre-up statement in the interface configuration file /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

Links and references