Linux:Network: Difference between revisions
From Cheatsheet
Jump to navigationJump to search
(→Common) |
No edit summary |
||
| Line 36: | Line 36: | ||
# Test specific IP and port combination for connectivity | # Test specific IP and port combination for connectivity | ||
telnet 172.16.2.1 22 | telnet 172.16.2.1 22 | ||
# Wireshark on a specific interface to a file, listening on a local port and for a remote IP | |||
tshark -p -i bond0 -w file.pcap -f "port 443 and host 172.16.16.25" | |||
# List available routers | |||
ip netns | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 59: | Line 65: | ||
7bb91614-6ffe-4bdc-9b37-c6e9d37f6987 | 7bb91614-6ffe-4bdc-9b37-c6e9d37f6987 | ||
# | # Execute the ifconfig within a specific router | ||
ip netns exec qrouter-asdwe49-as8d7-asd2-ert0-cvb7klj2 "ifconfig" | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 11:38, 24 August 2023
Checks
Common
# List route table route -n # Display network connections and current states netstat # Check listening ports, connected remote IPs, processes, states and more netstat -taupen # Check listening ports and IPs of the local server netstat -tulpn # List the routing table netstat -r # List verbose common TCP and ICMP information netstat -s # Show all active network connections nmcli connection show # Show active and unactive network connections nmcli dev status # List iptable rules (Nftables) iptables -nvL # List iptable rules (Legacy iptables) iptables-legacy -nvL # Test specific IP and port combination for connectivity telnet 172.16.2.1 22 # Wireshark on a specific interface to a file, listening on a local port and for a remote IP tshark -p -i bond0 -w file.pcap -f "port 443 and host 172.16.16.25" # List available routers ip netns
DNS
# Lookup reverse DNS host information dig -x 10.0.2.15 # Lookup reverse DNS host information host 10.0.2.15 # Lookup DNS host information nslookup 10.0.2.15
Network
Common
# Generate a unique UUID (for an interface) uuidgen eth0 7bb91614-6ffe-4bdc-9b37-c6e9d37f6987 # Execute the ifconfig within a specific router ip netns exec qrouter-asdwe49-as8d7-asd2-ert0-cvb7klj2 "ifconfig"
Routing
# Delete default route ip route del 0.0.0.0/0 via 192.168.10.1 dev ens3 # Delete default route (explicit) ip route del default via 192.168.0.1 dev eth0 proto static metric 100 # Add a default route via a specific IP and interface ip route add default via 192.168.0.1 dev eth0 proto static metric 90 # Add route for a network via gateway on an interface ip route add 10.0.100.0/24 via 10.0.100.254 dev ens5 # Add default route met een specifieke metric ip route add default via 10.0.180.1 dev ens7 proto static metric 90
RHEL
Generic Interface
# /etc/sysconfig/network-scripts/ifcfg-ens128 BOOTPROTO=static HWADDR=ab:cd:ef:gh:ij:kl IPADDR=192.168.10.2 NETMASK=255.255.255.0 NAME=ens128 STARTMODE=auto UUID=0a8d3485-d512-46da-8225-19f4721813c1 GATEWAY=192.168.10.1 DEVICE=ens128
Generic VLAN Interface
# /etc/sysconfig/network-scripts/ifcfg-eno2.100 VLAN=yes TYPE=Vlan PHYSDEV=eno2 VLAN_ID=100 NAME=eno2.100 BOOTPROTO=static HWADDR=ab:cd:ef:gh:ij:kl IPADDR=192.168.100.217 NETMASK=255.255.255.0 STARTMODE=auto UUID=689cff6f-c750-4db7-936c-234fb80b6018 GATEWAY=192.168.100.1
VLAN Bond interface configuration
Virtual Bond Master
BONDING_OPTS="mode=802.3ad miimon=100" TYPE=Bond BONDING_MASTER=yes PROXY_METHOD=none BROWSER_ONLY=no IPV6INIT=no NAME=bond0 UUID=7bb91614-6ffe-4bdc-9b37-c6e9d37f6987 DEVICE=bond0 ONBOOT=yes AUTOCONNECT_PRIORITY=9 AUTOCONNECT_RETRIES=0 AUTOCONNECT_SLAVES=yes MTU=1500
Physical bond Slaves
# /etc/sysconfig/network-scripts/ifcfg-ens1 TYPE=Ethernet NAME=ens1 UUID=c6a4da43-b84a-44f4-b49f-4bdc717d4238 DEVICE=ens1 ONBOOT=yes AUTOCONNECT_PRIORITY=9 AUTOCONNECT_RETRIES=0 MASTER_UUID=7bb91614-6ffe-4bdc-9b37-c6e9d37f6987 MASTER=bond0 SLAVE=yes
# /etc/sysconfig/network-scripts/ifcfg-ens2 TYPE=Ethernet NAME=ens2 UUID=ca09a126-a082-4620-a920-be45269e5d8a DEVICE=ens2 ONBOOT=yes AUTOCONNECT_PRIORITY=9 AUTOCONNECT_RETRIES=0 MASTER_UUID=7bb91614-6ffe-4bdc-9b37-c6e9d37f6987 MASTER=bond0 SLAVE=yes
VLAN 100 Interface
# /etc/sysconfig/network-scripts/ifcfg-vlan-bond0.100 VLAN=yes TYPE=Vlan PHYSDEV=bond0 VLAN_ID=100 REORDER_HDR=yes GVRP=no MVRP=no HWADDR= PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=none IPADDR=192.168.100.10 PREFIX=24 DEFROUTE=yes IPV4_FAILURE_FATAL=no NAME=vlan-bond0.100 UUID=83b0e31c-9a9f-47da-9dc6-645796bc47aa ONBOOT=yes AUTOCONNECT_PRIORITY=9 AUTOCONNECT_RETRIES=0 GATEWAY=192.168.100.1
Ubuntu/Debian
Netplan
# Apply the configuration, but if the dialogue is left unconfirmed, the configuration will be reverted. netplan try # Apply the configuration netplan apply
Generic interface
# /etc/netplan/60-cloud-init.yaml
network:
version: 2
ethernets:
ens7:
addresses:
- 192.168.0.23/24
match:
macaddress: ab:cd:ef:gh:ij:kl
mtu: 1500
set-name: ens7
nameservers:
addresses: [1.1.1.1.1, 8.8.8.8]
routes:
- to: default
via: 192.168.0.1
VLAN Interface
# /etc/netplan/01-eno1-interface.yaml
network:
version: 2
ethernets:
eno1: {}
vlans:
eno1.10:
id: 10
link: eno1
addresses: [192.168.1.1/24]
eno1.20:
id: 20
link: eno1
addresses: [192.168.2.1/24]
nameservers:
addresses:
- 1.1.1.1
- 8.8.8.8
search: []
routes:
- to: default
via: 192.168.0.1
eno1.30:
id: 30
link: eno1
addresses: [192.168.3.1/24]
Empty Interface
# /etc/netplan/02-eno2-interface.yaml
network:
version: 2
ethernets:
eno2:
dhcp4: false
dhcp6: false
Networkmanager
Generic interface
# /etc/network/interfaces.d/ens160.conf
auto ens160
iface ens160 inet static
address 192.168.23.7
netmask 255.255.255.0
gateway 192.168.23.1