Skip to main content

Networking

Hostname

Set

sudo hostnamectl set-hostname vm7.orgDomain

View

Use one of the following commands.

hostnamectl status
cat /etc/hostname

HTTP protocol

Method role in RESTful APIs

  • POST (sometimes PUT) - Create a new resource using the information sent with the request.
  • GET - Read an existing resource without modifying it.
  • PUT or PATCH (sometimes POST) - Update a resource using the data sent.
  • DELETE - Delete a resource.

Sending arguments

GET method

Sent as a query string after the ? in the url.

http://example.com/page?parameter=value&also=another

POST/PUT methods

Stored as key-value pairs in the body (not visible in the url).

{ "key": "value" }

IP

Add a route temporarily (until reboot)

ip route add 192.168.2.1/23 via 10.11.12.3

Add an IP address to an interface temporarily (until reboot)

sudo ip address add 192.168.1.1/24 dev eth0

Bring interfaces up and down

sudo ip link set eth0 up
sudo ip link set eth0 down

Delete a route temporarily (until reboot)

sudo ip route delete 192.168.2.1/23 via 10.11.12.3
sudo ip route delete 192.168.2.1/23 # for all routes to target

Show ARP cache (MAC addresses)

ip -c neighbor show

Show information for all interfaces

ip -c link show

Show ip addresses allocated to interfaces

ip -c address show

Show public ip address

curl ifconfig.me

Show statistics of an interface

ip -c -h -s link show eth0
note

Options -c and -h add color and human-readable values to output.

Route

Add route temporarily (until reboot)

sudo route add -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.0.1
# Add default gateway.
sudo route add default gw 192.168.0.1

Delete route temporarily (until reboot)

sudo route del -net 192.168.0.0 netmask 255.255.255.0
# Delete default gateway.
sudo route del default

Show routing table

route

Ss

Useful options

OptionDescription
-4IPv4 sockets only.
-aListening and non-listening sockets (established for TCP).
-lListening sockets only.
-mSocket memory usage.
-nDon't resolve numeric adresses/ports.
-oOptions (i. e. state established).
-pProcess using socket.
-tTCP sockets.
-uUDP sockets.
-xUnix domain sockets.
-ZProcess and security context (SELinux).

Traceroute

See route to target host.

traceroute targetHost

To bypass firewalls that block ICMP traffic try one of these options:

--udp or --tcp

note

These commands were tested on RHEL 7 unless otherwise specified.