常用網絡工作

ifconfig

# 查看網卡設備:
ifconfig(僅列出up狀態)ifconfig -a(包含down狀態)

# 開啓網卡:
ifconfig up

# 關閉網卡:
ifconfig down

# 配置網卡地址:
ifconfig eth1 add 192.168.101.100 netmask 255.255.255.0 up
ifconfig eth1 192.168.101.2/24

# 配置網卡子接口(虛擬IP):
ifconfig eth1:0 11.11.11.11 netmask 255.255.255.0 up

# 刪除網卡子接口:
ifconfig eth1:0 del 11.11.11.11

# 刪除網卡地址:
ifconfig eth1 del 192.168.101.100 netmask 255.255.255.0 down

# 修改網卡MAC:
ifconfig eth1 hw ether d0:dd:ca:ba:58:21
ip link set dev eth1 address d0:dd:ca:ba:58:20

# 開啓ARP協議:
ifconfig eth1 arp

# 關閉ARP協議:
ifconfig eth1 -arp

ip

# 網卡添加IP:
ip a a 192.168.101.2/24 dev eth1	
ip addr add 192.168.101.2/24 dev eth1

# 網卡刪除IP:
ip a d 192.168.101.2/24 dev eth1
ip addr del 192.168.101.2/24 dev eth1

# 添加路由:
ip route add 192.168.100.0/24 via 192.168.101.1

# 刪除路由:
ip route del 192.168.100.0/24 via 192.168.101.1

route

 # 添加默認路由:
 route add default gw 10.202.1.254
 
# 刪除默認路由:
route del default gw 10.202.1.254

# 添加策略路由:
route add -net 192.168.100.0 netmask 255.255.255.0 gw 192.168.101.1

# 刪除策略路由:
route del -net 192.168.100.0 netmask 255.255.255.0 gw 192.168.101.1

# 添加策略路由設備:
route add -net 192.168.100.0/24 dev eth1

# 刪除策略路由設備:
route del -net 192.168.100.0/24 dev eth1

ethtool

  1. 查詢網卡基本設置:ethtool enp5s0在這裏插入圖片描述
  2. 設置網卡速率、半/全雙工、是否自協商
ethtool –s enp5s0 [speed 10|100|1000] [duplex half|full]  [autoneg on|off]
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章