configuration network commonly used add, delete, change search command
modify the IP address
- modify the configuration file
/etc/sysconfig/network-scripts/ifcfg-ens33
blockquote> li>
- ifconfig command
ifconfig ens33:0 192.168.235.127/24
li>
- IP command
ip addr add 192.168.235.127/24 dev ens33 label ens33:1
li>
- nmcli command
nmcli connection modify ens33 ipv4.address 192.168.80.100/24 # 修改ip地址 nmcli connection modify ens33 ipv4.gateway 192.168.80.2/24 #修改网关 nmcli connection modify ens33 ipv4.dns1 114.114.114.114 # 修改dns信息 nmcli connection modify ens33 ipv4.method mannual # 指定网络信息获取方式为手动指定
- ifconfig command
open/disable network card
- ifconfig command
ifconfig ens33 up ifconfig ens33 down
li>
- ifup/ifdown command
ifup ens33 ifdown ens33
li>
- IP command
ip link set ens33 up ip link set ens33 down
li>
- nmcli command
nmcli device connect ens33 nmcli device disconnect ens33
add routing
- modify the configuration file
/etc/sysconfig/network-scripts/route-ens33
The
- way
target via gw
220.181.38.148 via 192.168.80.2 -
each three lines defines a route
ADDRESS0=TARGET
NETMASK0=MASK
GATEWAY0=GWBlockquote> li>
- way
- route command
route add -net 192.168.235.0 netmask 255.255.255.0 gw 192.168.235.2 dev ens33
li>
- IP command
ip route add 192.168.80.0/24 via 192.168.80.2 dev ens33 # 添加网络路由 ip route add 192.168.80.100 via 192.168.80.0 dev ens33 #添加主机路由 ip route add default via 192.168.80.2 dev ens33 # 添加默认路由
modify routing
- modify the configuration file
/etc/sysconfig/network-scripts/route-ens33
The
- way
target via gw
220.181.38.148 via 192.168.80.2 -
each three lines defines a route
ADDRESS0=TARGET
NETMASK0=MASK
GATEWAY0=GWBlockquote> li>
- way
- IP command
ip route change # 如果路由本身不存在则报错显示不存在 ip route replace # 如果路由本身不存在则会直接创建该路由信息
delete route
- delete the configuration file
/etc/sysconfig/network-scripts/route-ens33
blockquote> li>
- the route command
route del -net 192.168.235.0 netmask 255.255.255.0 gw 192.168.235.2 dev ens33
li>
- IP command
ip route del 192.168.80.0/24 via 192.168.80.2 dev ens33
- the route command
view routing table
- the route command
route -n
li>
- netstat command
netstat -r # 显示内核路由表 netstat -n # 数字格式(不进行反向解析)