The material we plan to cover in the Unix Sys Admin ed 5 text related to network sys admin on Linux includes:
Note that we cover network topics that are related to security in LinuxSystemSecurity.
The following topics provide the basics of Unix network administration.. The majority of concepts are applicable to all types of Unix systems - further detals related to Linux are presented as well.
Additional Topics:
Linux commands and popular tools:
Either Linux network is managed/configured through the linux network manager, or the network manager is disabled. If you manually configure an interface in /etc/network/interfaces, the network manager will not manage it. Another way to stop network manager:
sudo /etc/init.d/network-manager stop
and then add /etc/network/interfaces
Or....if want dhcp:
iface eth0 inet dhcp
Three ways to restart networking:
The main network config file is /etc/network/interfaces. On my VM1, I see:
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
NOTE: As of 3/25/2018 I have not updated the info below to reflect the 'correct' way to do things in Ubuntu 16.04. These all work....at least some are considered to be old and should be done with newer commands. I'll try to update this soon!
Add calls to ethtool in this file: $cat /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 /sbin/ethtool -s eth0 speed 1000 duplex full
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
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 manner. 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 the following manner.
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
If you require DNS for your temporary network configuration, you can add DNS server IP addresses in the file /etc/resolv.conf. In general, editing /etc/resolv.conf directly is not recommanded, but this is a temporary and non-persistent configuration. 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 the proper persistent way to do 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 below.
ip addr flush eth0
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, or re-boot which should also cause /etc/resolv.conf, which is actually now a symlink to /run/resolvconf/resolv.conf, to be re-written.
To configure your server to use DHCP for dynamic address assignment, add the dhcp method 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.
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 dhclient.
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
To configure your system to use a static IP address assignment, add the static method 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 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.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
last updated: 3/25/2018