Table of Content

109.2 Basic network configuration

Weight: 4

Description: Candidates should be able to view, change and verify configuration settings on client hosts.

Key Knowledge Areas:

  • Manually and automatically configure network interfaces
  • Basic TCP/IP host configuration
  • Setting a default route

Terms and Utilities:

/etc/hostname
/etc/hosts
/etc/nsswitch.conf
ifconfig
ifup
ifdown
ip
route
ping

address

ifoconfig -a
Link encap:Ethernet HWaddr 00:A0:CC:24:BA:02

ip addr

MAC and IP address

  • ipv4 ARP Address Resolution Protocol
  • ipv6 Neighbor Discovery Protocol (NDP)
oldhorse@dclab:~$ arp
Address HWtype HWaddress Flags Mask Iface
192.168.100.2 ether 00:50:56:fe:ed:ca C eth0
192.168.126.1 ether 00:50:56:c0:00:01 C eth1
192.168.100.254 ether 00:50:56:e5:b1:ab C eth0

ipv6 address

  • link-local and global
  • Most Linux distributions automatically assign a link-local IPv6 address to all network interfaces to communicate on the local networks
  • The fe80:0000:0000:0000: link-local address de facto standard
  • Link-local addresses are nonroutable
eth0 Link encap:Ethernet HWaddr 00:0c:29:8f:55:ee
inet addr:192.168.100.128 Bcast:192.168.100.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe8f:55ee/64 Scope:Link

oldhorse@dclab:~$ ping6 fe80::20c:29ff:fe8f:55ee%eth0
PING fe80::20c:29ff:fe8f:55ee%eth0(fe80::20c:29ff:fe8f:55ee) 56 data bytes
64 bytes from fe80::20c:29ff:fe8f:55ee: icmp_seq=1 ttl=64 time=0.073 ms
64 bytes from fe80::20c:29ff:fe8f:55ee: icmp_seq=2 ttl=64 time=0.070 ms

Classless Inter-Domain Routing (CIDR)

172.30.0.0/17
10101100 00011110 00001001 01100110 // 172.30.9.102
11111111 11111111 10000000 00000000 // netmask 255.255.128.0
10101100 00011110 01111111 11111111 // broadcast 172.30.127.255

address class

Class Address range Reserved private addresses
A 1.0.0.0-127.255.255.255 10.0.0.0-10.255.255.255
B 128.0.0.0-191.255.255.255 172.16.0.0-172.31.255.255
C 192.0.0.0-223.255.255.255 192.168.0.0-192.168.255.255
D 224.0.0.0-239.255.255.255 none
E 240.0.0.0-255.255.255.255 none

NAT

  • Network Address Translation (NAT) routers
  • enable arbitrary numbers of computers to “hide” behind a single system
  • The NAT router substitutes its own IP address on outgoing packets and then directs the reply to the correct system
  • when want connect more computers to the Internet than you have IP addresses

NIC config

ubuntu
/etc/network/interface
auto eth0
iface eth0 inet dhcp

auto eth1
iface eth1 inet static
address 192.168.126.51
netmask 255.255.255.0

/etc/init.d/networking restart
or reboot

centOS

/etc/sysconfig/network-scripts/ifcfg-xxx

[root@dclab-centos7 network-scripts]# ls -ltr |grep ifcfg
-rw-r--r--. 1 root root 254 Jan 15 2015 ifcfg-lo
-rw-r--r--. 1 root root 365 Sep 19 14:05 ifcfg-eno16777736
-rw-r--r--. 1 root root 159 Mar 9 11:58 ifcfg-eno33554984

[root@dclab-centos7 network-scripts]# cat ifcfg-eno16777736
TYPE="Ethernet"
BOOTPROTO="dhcp"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
NAME="eno16777736"
UUID="ce6029d2-2a3e-4b38-b8e4-8ac184b98e58"
DEVICE="eno16777736"
ONBOOT="yes"
HWADDR="00:0C:29:EF:EB:06"
PEERDNS="yes"
PEERROUTES="yes"
IPV6_PEERDNS="yes"
IPV6_PEERROUTES="yes"
IPV6_PRIVACY="no"

[root@dclab-centos7 network-scripts]# cat ifcfg-eno33554984
TYPE="Ethernet"
BOOTPROTO="static"
NAME="eno33554984"
DEVICE="eno33554984"
ONBOOT="yes"
HWADDR="00:0c:29:ef:eb:10"
IPADDR=192.168.126.50
NETMASK=255.255.255.0

service network restart

manually startup interface

# ifconfig eth0 up 192.168.100.128 netmask 255.255.255.0
# route add default gw 192.168.100.2
# ifconfig -a
# route –n

eth0 Link encap:Ethernet HWaddr 00:0c:29:8f:55:ee
inet addr:192.168.100.128 Bcast:192.168.100.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe8f:55ee/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2034 errors:0 dropped:0 overruns:0 frame:0
TX packets:929 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1557827 (1.5 MB) TX bytes:88305 (88.3 KB)

eth1 Link encap:Ethernet HWaddr 00:0c:29:8f:55:f8
inet addr:192.168.126.51 Bcast:192.168.126.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe8f:55f8/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1361 errors:0 dropped:0 overruns:0 frame:0
TX packets:715 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:126492 (126.4 KB) TX bytes:137582 (137.5 KB)

oldhorse@dclab:~$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.100.2 0.0.0.0 UG 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 eth1
192.168.100.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.126.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1

ip addr

[root@dclab-centos7 ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:ef:eb:06 brd ff:ff:ff:ff:ff:ff
inet 192.168.100.129/24 brd 192.168.100.255 scope global dynamic eno16777736
valid_lft 1368sec preferred_lft 1368sec
3: eno33554984: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:ef:eb:10 brd ff:ff:ff:ff:ff:ff
inet 192.168.126.50/24 brd 192.168.126.255 scope global eno33554984
valid_lft forever preferred_lft forever

router config

# route add -net 172.20.0.0 netmask 255.255.0.0 gw 172.21.1.1
# echo "1" > /proc/sys/net/ipv4/ip_forward

hostname

oldhorse@dclab:~$ hostname
dclab
oldhorse@dclab:~$ cat /etc/hostname
dclab

hostname newhostname > /etc/hostname