Differences
This shows you the differences between two versions of the page.
linux_wiki:configure_networking_and_hostname_resolution_statically_or_dynamically [2018/03/18 16:13] billdozor [Hostname Configuration] |
linux_wiki:configure_networking_and_hostname_resolution_statically_or_dynamically [2019/05/25 23:50] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Configure Networking And Hostname Resolution Statically Or Dynamically ====== | ||
- | |||
- | **General Information** | ||
- | |||
- | Networking has changed from RHEL 6 to 7. You can still edit network scripts in / | ||
- | |||
- | ---- | ||
- | |||
- | ===== Troubleshooting Tools ===== | ||
- | |||
- | Show IP Address of Devices | ||
- | <code bash> | ||
- | ip addr show | ||
- | </ | ||
- | * ifconfig is deprecated in RHEL 7. | ||
- | |||
- | \\ | ||
- | Show all Established Connections | ||
- | <code bash> | ||
- | ss | ||
- | </ | ||
- | |||
- | \\ | ||
- | Show Established and Listening TCP Connections | ||
- | <code bash> | ||
- | ss -ant | ||
- | </ | ||
- | |||
- | flags: | ||
- | * a => show both established and listening | ||
- | * t => show tcp connections | ||
- | * n => do not resolve service names (ports) | ||
- | |||
- | \\ | ||
- | Other tools to use: | ||
- | * ping -c 5 (send 5 pings) | ||
- | * traceroute | ||
- | * tracepath | ||
- | * netstat - netstat has been deprecated (use ss instead), but can still be installed as part of the net-tools package | ||
- | |||
- | ---- | ||
- | |||
- | ===== Network Manager ===== | ||
- | |||
- | NetworkManager is the default network service in RHEL 7. | ||
- | * Main Service = NetworkManager.service | ||
- | * Tools to interface with NetworkManager | ||
- | * nm-connection-editor (GUI) | ||
- | * nmtui (ncurses based) | ||
- | * nmcli (cli) | ||
- | * Fallback service = network.service | ||
- | * This uses the traditional network scripts in / | ||
- | |||
- | \\ | ||
- | Open GUI for network connections (GUI Only) | ||
- | <code bash> | ||
- | nm-connection-editor | ||
- | </ | ||
- | |||
- | \\ | ||
- | Open text based wizard | ||
- | <code bash> | ||
- | nmtui | ||
- | </ | ||
- | |||
- | \\ | ||
- | ==== CLI Tool: nmcli ==== | ||
- | |||
- | nmcli makes configuration changes to files in: / | ||
- | |||
- | These files can alternatively be modified manually. | ||
- | |||
- | \\ | ||
- | Network Device Status | ||
- | <code bash> | ||
- | nmcli dev status | ||
- | </ | ||
- | |||
- | \\ | ||
- | Show all connection configurations | ||
- | <code bash> | ||
- | nmcli con show | ||
- | </ | ||
- | * Configurations location: / | ||
- | |||
- | \\ | ||
- | Example: Create new connection (dhcp) | ||
- | <code bash> | ||
- | nmcli con add con-name " | ||
- | </ | ||
- | |||
- | \\ | ||
- | Example: Create new connection (static ip) | ||
- | <code bash> | ||
- | nmcli con add con-name " | ||
- | </ | ||
- | * The above produces the following config: | ||
- | * / | ||
- | BOOTPROTO=none | ||
- | IPADDR=10.0.0.5 | ||
- | PREFIX=24 | ||
- | GATEWAY=10.0.0.254 | ||
- | DEFROUTE=yes | ||
- | IPV4_FAILURE_FATAL=no | ||
- | IPV6INIT=yes | ||
- | IPV6_AUTOCONF=yes | ||
- | IPV6_DEFROUTE=yes | ||
- | IPV6_PEERDNS=yes | ||
- | IPV6_PEERROUTES=yes | ||
- | IPV6_FAILURE_FATAL=no | ||
- | NAME=mycon-static | ||
- | UUID=f7e0c9af-715d-43da-9576-e6ce218d0c28 | ||
- | DEVICE=eth1 | ||
- | ONBOOT=yes | ||
- | |||
- | \\ | ||
- | Show only active connections | ||
- | <code bash> | ||
- | nmcli con show --active | ||
- | </ | ||
- | |||
- | \\ | ||
- | Bring connections up/down | ||
- | <code bash> | ||
- | nmcli con down " | ||
- | nmcli con up " | ||
- | </ | ||
- | |||
- | \\ | ||
- | Change an existing connection' | ||
- | <code bash> | ||
- | nmcli con mod eth0 ipv4.addresses 192.168.1.50/ | ||
- | nmcli con mod eth0 ipv4.gateway 192.168.1.254 | ||
- | nmcli con mod eth0 ipv4.method manual | ||
- | nmcli con up eth0 | ||
- | </ | ||
- | * Changes do not take place until "nmcli con up eth0" | ||
- | |||
- | ---- | ||
- | |||
- | ===== Hostname Configuration ===== | ||
- | |||
- | View current hostname | ||
- | <code bash> | ||
- | hostname | ||
- | </ | ||
- | |||
- | \\ | ||
- | Set **temporary**(transient) hostname | ||
- | <code bash> | ||
- | hostname myserver.domain.com | ||
- | exec bash | ||
- | </ | ||
- | |||
- | \\ | ||
- | View detailed hostname information | ||
- | <code bash> | ||
- | hostnamectl | ||
- | </ | ||
- | * static hostname (stored in: / | ||
- | * transient hostname - assigned temporarily due to network configuration, | ||
- | * pretty hostname (stored in: / | ||
- | |||
- | \\ | ||
- | Set **persistent**(static) hostname | ||
- | <code bash> | ||
- | hostnamectl set-hostname myserver.com | ||
- | </ | ||
- | |||
- | \\ | ||
- | Order of name resolution (hosts entry) | ||
- | <code bash> | ||
- | / | ||
- | |||
- | #....other entries above | ||
- | |||
- | # hosts: search local files and then DNS | ||
- | hosts: | ||
- | |||
- | #....other entries below | ||
- | </ | ||
- | |||
- | \\ | ||
- | System wide dns name server entries (static or network manager generated) | ||
- | <code bash> | ||
- | / | ||
- | |||
- | # Generated by NetworkManager | ||
- | search us-west-2.compute.internal | ||
- | nameserver 172.31.0.2 | ||
- | </ | ||
- | |||
- | \\ | ||
- | Local system hostname resolution and example entry | ||
- | <code bash> | ||
- | /etc/hosts | ||
- | |||
- | # IP Hostname | ||
- | 10.1.1.2 | ||
- | </ | ||
- | |||
- | \\ | ||
- | **Add DNS** (not replace) for eth0 with nmcli or with config file | ||
- | * Using nmcli< | ||
- | nmcli con show | ||
- | (observe NAME field) | ||
- | nmcli con mod " | ||
- | * Edit files directly< | ||
- | vim / | ||
- | |||
- | DNS1=8.8.8.8</ | ||
- | * Apply changes: restart NetworkManager or issue nmcli command | ||
- | * nmcli method< | ||
- | * Service restart< | ||
- | |||
- | ---- | ||