General

From The Linux Source
Jump to: navigation, search

Enterprise 7 Note

Networking drastically changed under Enterprise 7, which now has Network Manager fully integrated (which was recommended to be uninstalled in previous releases when used on a server/static configuration). On 7, the convention is now not to modify any config files (which may be auto-generated, and/or will get overwritten by updates), but to use command-line utilities to modify any of the configuration settings/parameters (which normally does not modify the primary config file, but creates an override config file usually in a separate location).

Network Setup (ent 7)

1. determine interface and connection name setup for the subsequent nmcli commands, use what it shows for the Connection name (Device and Connection name are normally the same, but not always the same - this needs to be checked to verify what to use).
Note: "show" is a default argument in most cases, and does not need to be specified, unless other "show" arguments/details are needed (as in: nmcli dev show eno16777728)

# nmcli dev

2. configure the interface, IP, and gateway (defaults to "automatic" (DHCP), change to "manual" to be able to configure static parameters - settings saved in an ifcfg-interface file in /etc/sysconfig/network-scripts/, in this example; ifcfg-eno16777728)

# nmcli con mod eno16777728 ipv4.method manual ipv4.addresses 172.100.200.140/24 ipv4.gateway 172.100.200.1

3. configure hostname (saved in /etc/hostname) and domain (saved in an ifcfg-interface file in /etc/sysconfig/network-scripts/ and in /etc/resolv.conf)

# nmcli gen hostname ks-c7a.lab.example.com
# nmcli con mod eno16777728 ipv4.dns-search lab.example.com

4. configure DNS servers ((use DNS servers appropriate for your internet provider, for your own internal network, or for your local data center - saved in an ifcfg-interface file in /etc/sysconfig/network-scripts/ and in /etc/resolv.conf)

# nmcli con mod eno16777728 ipv4.dns 172.100.170.90,172.100.130.90

5. optional, list networking/connection info

# nmcli con show eno16777728

Network Setup (before ent 7)

most of this is common knowledge, but some of these additional steps have been added (moreso) as a comparison to the new ent 7 listing/steps (above)

1. configure the IP and gateway 1a. set the following in an ifcfg-interface file (usually ifcfg-eth0) under /etc/sysconfig/network-scripts/ Note: ent 6 defaults to/prefers quotes around the params, i.e. BOOTPROTO="none", ent 6 also introduced CIDR notation, ex; PREFIX="24" to replace the old/longer netmask convention (NETMASK="255.255.255.0")

BOOTPROTO=none
IPADDR=172.200.110.140
NETMASK=255.255.255.0

1b. configure the default gateway and disable the dynamic link-local (DHCP network) address in /etc/sysconfig/network
Note: ent 6 defaults to/prefers quotes around the params, i.e. GATEWAY="172.100.130.1"

GATEWAY=172.100.130.1
NOZEROCONF=yes

2. configure hostname 2a. set the FQDN hostname in /etc/sysconfig/network

HOSTNAME=ks-c7a.lab.example.com

2b. set the domain in /etc/resolv.conf

domain lab.example.com

2c. set the IP and hostname info in /etc/hosts (required for 'hostname -s' and other types of resolution)

172.100.200.140   ks-c7a.lab.example.com ks-c7a

3. configure the DNS servers in /etc/resolv.conf (use DNS servers appropriate for your internet provider, for your own internal network, or for your local data center)

nameserver 172.100.170.90
nameserver 172.100.130.90

4. optional, list interface info

Ent 5 or older
# ifconfig
Ent 6
# ip addr

Changing the IP (ent 7)

1. set the new IP and netmask
Note: if the IP is not getting set, please check or go through the Network Setup steps (above), specifically see the note on the default setting with DHCP/manual mode

# nmcli con mod eno16777728 ipv4.addresses 172.100.200.140/24 ipv4.gateway 172.100.200.1
OR
# nmcli con mod eno16777728 ipv4.addresses 172.100.200.140/24
# nmcli con mod eno16777728 ipv4.gateway 172.100.200.1

2. restart networking
Note: this has worked remotely over ssh, as long as the two commands are entered together as per this example, otherwise doing the single down command will cause you to lose your connection and require console access to resolve/fix

# nmcli con down eno16777728 ; nmcli con up eno16777728

Changing the IP (before ent 7)

1. set the new IP and netmask in the ifcfg-interface file (usually ifcfg-eth0) under /etc/sysconfig/network-scripts/
Note: ent 6 defaults to/prefers quotes around the params, i.e. NETMASK="255.255.255.0", ent 6 also introduced CIDR notation, ex; PREFIX="24" to replace the old/longer netmask convention (NETMASK="255.255.255.0")

IPADDR=172.200.110.140
NETMASK=255.255.255.0

2. set the new default gateway in /etc/sysconfig/network
Note: ent 6 defaults to/prefers quotes around the params, i.e. GATEWAY="172.100.130.1"

GATEWAY=172.100.130.1

3. set the IP info in /etc/hosts (required for 'hostname -s' and other types of resolution)

172.100.200.140   ks-c7a.lab.example.com ks-c7a

4. restart networking
Note: recommended to use "&" when connected remotely so the command will continue after the network gets disconnected (your session is normally not lost in this case, and you would normally stay connected)

# service network restart &

Adding Additional IP's/Aliases (ent 7)

1. add the additional IP

# nmcli con mod eno16777728 +ipv4.addresses 172.100.200.140/24

2. restart networking
Note: this has worked remotely over ssh, as long as the two commands are entered together as per this example, otherwise doing the single down command will cause you to lose your connection and require console access to resolve/fix

# nmcli con down eno16777728 ; nmcli con up eno16777728

Adding Additional IP's/Aliases (before ent 7)

1. create an ifcfg-interface:aliasnumber file in /etc/sysconfig/network-scripts/ (ifcfg-eth0:0 for this example), with the following contents

DEVICE="eth0:0"
IPADDR="172.100.200.140"
NETMASK="255.255.255.0"
ONPARENT="yes"

2. restart networking
Note: recommended to use & when connected remotely so the command will continue after the network gets disconnected (your session is normally not lost in this case, and you would normally stay connected)

# service network restart &

Adding Static Routes (ent 7)

Set the address range and gateway address (saved in a route-interface file in /etc/sysconfig/network-scripts/, in this example; route-eno16777728)

# nmcli con mod eno16777728 ipv4.routes "172.200.210.0/24 172.200.210.120"

Adding Static Routes (before ent 7)

Create a route-interface file (for IPv4), example /etc/sysconfig/network-scripts/route-eth0 (or route-bond0 for a bonding interface);

ADDRESS0=172.200.210.0
NETMASK0=255.255.255.0
GATEWAY0=172.200.210.120

Quick Reference

past what is shown above, here are a few additional/helpful commands

Show IP Info (before ent 6)

# ifconfig

Show IP Info (ent 6 and newer)

# ip addr

Show IP Configuration (before ent 7)

# cat /etc/sysconfig/network /etc/sysconfig/network-scripts/ifcfg-e*

Show IP Configuration (ent 7)
Note: run 'nmcli dev' to find the device name

# nmcli dev
DEVICE  TYPE      STATE      CONNECTION
ens32   ethernet  connected  ens32
lo      loopback  unmanaged  --
# nmcli con show ens32

Show Listening Ports (only)
Note: the : in the output normally denotes a listening port

# lsof -nP | grep ":"

Show Network Connections (before ent 7)

# netstat -an

Show Network Connections (ent 7)

# ss -an