使用者工具

網站工具


linux:network_command

常用的網路指令

ifconfig

ifconfig {interface}{option}
  1. 觀察介面:ifconfig(顯示所有介面)
  2. 觀察單一介面:ifconfig eth0
  3. 設定或修改ip參數:ifconfig eth0 192.168.1.200 netmask 255.255.255.0 broadcast 192.168.1.255
  4. 設定或修改虛擬網卡的ip參數:ifconfig eth0:0 192.168.10.1 netmask 255.255.255.0 broadcast 192.168.10.255
  5. 停止網路介面:ifconfig eth0 down
  6. 啟動網路介面:ifconfig eth0 up

route 設定路由指令

1
顯示路由資訊(以數字表示)
route -n
顯示路由詳盡資訊
route -ee
路由增加及刪除
route add  [-net|-host] [網域或主機] netmask [mask] [gw|dev]
      del  [-net|-host] [網域或主機] netmask [mask] [gw|dev]
  1. 增加192.168.10.x 的網段由eth1網路介面出去 route add -net 192.168.10.0 netmask 255.255.255.0 dev eth1

ip 多用途網路設定指令

ip 指令可代替ifconfig route

ip link 
      --> 看網卡介面等資訊,MAC Address,網卡是否啟動(up,down)
      -ip link [show]

      --> 設定網卡相關參數
ip addr
      --> 看網卡ip等資訊
      -ip addr [show] 或ip a

      --> 設定網卡ip資訊
      -ip addr add 192.168.1.13/24 dev eth0 新增
      -ip addr del 192.168.1.13/24 dev eth0 刪除

      --> 設定ip alias (ex:eth0:0 eth0:1)
      -ip addr add 192.168.2.13/24 dev eth0 label eth0:0 新增
      -ip addr del 192.168.2.13/24 dev eth0 label eth0:0 刪除
ip route
      --> 看routing table資訊
      -ip route

      --> 設定靜態路由 ip route add network/netmask via router ip
      -ip route add 192.168.1.0/24 via 192.168.0.254 新增
      -ip route del 192.168.1.0/24 via 192.168.0.254 刪除
      -ip route add default via 192.168.0.1         新增預設路由
linux/network_command.txt · 上一次變更: 2013/07/06 01:28 (外部編輯)