1. vim:
i
switch to input mode from command mode
[esc]
switch to command mode from input mode
:wq
save and quit in command mode
:/
search a text in command mode
:dd
delete a line in command mode
:set number
show line numbers
:u
undo
2. Linux bash
grep textToSearch
Text search in lines
grep -i textToSearch
Text search in lines, ignore case
clear
clear screen
ps -aux
print current running process information, like PID, command line parameters
watch command -n watchinterval
execute command repeatedly in the specified interval (default is 2s)
watch date
cat filename
show file content
pwd
get current directory
ls
list all file and folder in the current directory
openssl req -x509 -new -nodes -key ca.key -sha256 -days 1024 -out ca.crt
openssl req -new -key server.key -out server.csr
create signing request for server certificate
openssl x509 -req -in server.csr -CAcreateserial -CA ca.crt -CAkey ca.key -out server.crt
create server certificate from signing request by signed with root CA
Route table is used for ip to ip routing. Arp table is used for ip to mac address mapping.
show which ip and port are listening from which process
netstat
net.ipv4.ip_forward=1
Host name resolution file
/etc/hosts
DNS config file
/etc/resolv.conf
Change DNS lookup order
/etc/nsswitch.conf
hosts: files dns
Show dns lookup information
nslookup hostnametolookup
list network namespace
ip netns
add network namespace red
ip netns add red
run ip command from namespace of red
ip -n red link
or
ip netns exec red ip link
create a virtual link (veth type) to connect two interfaces you named: vethred and vethblue
ip link add vethred type veth peer name vethblue
set interface vethred to a particular namespace red
ip link set vethred netns red
ip link set vethblue netns blue
set ip address for the network interface link vethred and vethblue
ip -n red addr add 192.168.15.1/24 dev vethred
ip -n blue addr add 192.168.15.2/24 dev vethblue
enable the interface link to up state
ip -n red link set vethred up
ip -n blue link set vethblue up
ping from one namespace to another using link interface ip
sudo ip netns exec red ping 192.168.15.2
delete interface link
ip -n red link delete vethred
add a virtual bridge v-net-0 of bridge type as switch
ip link add v-net-0 type bridge
bring bridge interface up
ip link set v-net-0 up
verify the status by
ip link
create link to the bridge
ip link add vethred type veth peer name veth-red-br
ip link add vethblue type veth peer name veth_blue_br
set link to namespace
ip link set vethred netns red
ip link set vethblue netns blue
ip link set veth-red-br master v-net-0
set ip address for the link
ip -n red addr add 192.168.15.1/24 dev vethred
ip -n blue addr add 192.168.15.2/24 dev vethblue
bring link interface up
ip -n red link set vethred up
ip -n blue link set vethblue up
set ip address for bridge
ip addr add 192.168.15.5/24 dev v-net-0
ip addr add 192.168.15.5/24 dev veth-blue-br
ping from one namespace to another
ip netns exec red ping 192.168.15.2
display and config network configuration
ifconfig
No comments:
Post a Comment