Lệnh |
Mô tả |
Ví dụ |
ip address show |
Hiển thị tất cả địa chỉ IP |
ip -4 addr show (chỉ IPv4) |
ip address show $(interface) |
Hiển thị địa chỉ của giao diện cụ thể |
ip addr show eth0 |
ip address show up |
Chỉ hiển thị giao diện đang hoạt động |
– |
ip address show [dev $(interface)] permanent |
Chỉ hiển thị địa chỉ tĩnh |
ip addr show dev eth0 permanent |
ip address show [dev $(interface)] dynamic |
Chỉ hiển thị địa chỉ động (DHCP) |
ip addr show dev eth0 dynamic |
ip address add $(address)/$(mask) dev $(interface) |
Thêm địa chỉ vào giao diện |
ip addr add 192.0.2.10/24 dev eth0
ip addr add 2001:db8:1::48/64 dev tun10 |
ip address add $(address)/$(mask) dev $(interface) label $(label) |
Thêm địa chỉ với nhãn |
ip addr add 192.0.2.1/24 dev eth0 label eth0:alias |
Lệnh |
Mô tả |
Ví dụ |
ip route get $(address)/$(mask) |
Xem route thực tế kernel dùng |
ip route get 192.0.2.1 |
ip route show cached |
Xem bộ đệm route (kernel < 3.6) |
– |
ip route add $(address)/$(mask) via $(next_hop) |
Thêm route qua gateway |
ip route add 192.0.2.128/25 via 192.0.2.1 |
ip route add $(address)/$(mask) dev $(interface) |
Thêm route qua giao diện |
ip route add 192.0.2.0/25 dev eth0 |
ip route change $(route_spec) |
Sửa route |
ip route change 192.168.2.0/24 via 10.0.0.1 |
ip route delete $(route_spec) |
Xóa route |
ip route delete 192.0.2.0/25 dev eth0 |
ip route add default via $(address) |
Thêm route mặc định |
ip route add default via 192.168.1.1 |
ip route add blackhole $(address)/$(mask) |
Route loại bỏ gói tin |
ip route add blackhole 192.0.2.1/32 |
ip route add unreachable $(address)/$(mask) |
Route trả về “unreachable” |
ip route add unreachable 192.0.2.0/24 |
ip route add prohibit $(address)/$(mask) |
Route trả về “prohibited” |
ip route add prohibit 192.0.2.0/24 |
ip route add throw $(address)/$(mask) |
Route dừng xử lý bảng |
ip route add throw 192.0.2.0/24 |
ip route add $(address)/$(mask) via $(gateway) metric $(number) |
Thêm route với độ ưu tiên |
ip route add 192.168.2.0/24 via 10.0.1.1 metric 5 |
ip route add $(address)/$(mask) nexthop via $(gw1) weight $(w1) nexthop via $(gw2) weight $(w2) |
Multipath routing |
ip route add default nexthop via 192.168.1.1 weight 1 nexthop dev ppp0 weight 10 |
Lệnh |
Mô tả |
Ví dụ |
ip link show |
Hiển thị tất cả liên kết |
ip link show |
ip link show dev $(interface) |
Hiển thị liên kết cụ thể |
ip link show dev eth0 |
ip link set dev $(interface) [up|down] |
Bật/tắt liên kết |
ip link set dev eth0 up |
ip link set dev $(interface) alias "$(description)" |
Đặt biệt danh |
ip link set dev eth0 alias "LAN interface" |
ip link set dev $(old_name) name $(new_name) |
Đổi tên giao diện |
ip link set dev eth0 name lan (phải tắt trước) |
ip link set dev $(interface) address $(address) |
Thay đổi địa chỉ MAC |
ip link set dev eth0 address 22:ce:e0:99:63:6f |
ip link set dev $(interface) mtu $(value) |
Thay đổi MTU |
ip link set dev tun0 mtu 1480 |
ip link delete dev $(interface) |
Xóa liên kết |
ip link delete dev tun0 |
ip link set $(interface) multicast [on|off] |
Bật/tắt multicast |
ip link set eth0 multicast on |
ip link set $(interface) arp [on|off] |
Bật/tắt ARP |
ip link set eth0 arp off |
ip link add name $(vlan_name) link $(parent) type vlan id $(tag) |
Tạo VLAN |
ip link add name vlan10 link eth0 type vlan id 10 |
ip link add $(interface) type ifb |
Tạo giao diện IFB |
ip link add ifb10 type ifb |
ip link add name $(veth1) type veth peer name $(veth2) |
Tạo cặp veth |
ip link add name veth-host type veth peer name veth-guest |
Lệnh |
Mô tả |
Ví dụ |
ip link set dev $(interface) group $(number) |
Thêm giao diện vào nhóm |
ip link set dev eth0 group 42 |
ip link set dev $(interface) group 0 |
Xóa giao diện khỏi nhóm |
ip link set dev eth0 group 0 |
echo "$(number) $(name)" > /etc/iproute2/group |
Gán tên tượng trưng cho nhóm |
echo "10 customer-vlans" > /etc/iproute2/group |
ip link set group $(number) $(operation) |
Thực hiện thao tác trên nhóm |
ip link set group 42 down |
ip link show group $(number) |
Xem thông tin nhóm |
ip link show group 42 |
Lệnh |
Mô tả |
Ví dụ |
ip tunnel add $(interface) mode ipip local $(local_addr) remote $(remote_addr) |
Tạo tunnel IPIP (IPv4 trong IPv4) |
ip tunnel add tun0 mode ipip local 192.168.1.1 remote 203.0.113.1 |
ip tunnel add $(interface) mode sit local $(local_addr) remote $(remote_addr) |
Tạo tunnel SIT (IPv6 trong IPv4) |
ip tunnel add tun0 mode sit local 192.168.1.1 remote 203.0.113.1 |
ip -6 tunnel add $(interface) mode ip6ip6 local $(local_addr) remote $(remote_addr) |
Tạo tunnel IP6IP6 (IPv6 trong IPv6) |
ip -6 tunnel add tun0 mode ip6ip6 local 2001:db8::1 remote 2001:db8::2 |
ip tunnel add $(interface) mode ipip6 local $(local_addr) remote $(remote_addr) |
Tạo tunnel IPIP6 (IPv4 trong IPv6) |
ip tunnel add tun0 mode ipip6 local 2001:db8::1 remote 2001:db8::2 |
ip link add $(interface) type gretap local $(local_addr) remote $(remote_addr) |
Tạo tunnel gretap (Ethernet qua GRE) |
ip link add gretap0 type gretap local 192.168.1.1 remote 203.0.113.1 |
ip tunnel add $(interface) mode gre local $(local_addr) remote $(remote_addr) |
Tạo tunnel GRE |
ip tunnel add gre0 mode gre local 192.168.1.1 remote 203.0.113.1 |
ip tunnel add $(interface) mode gre local $(local_addr) remote $(remote_addr) key $(key) |
Tạo GRE với khóa |
ip tunnel add gre0 mode gre local 192.168.1.1 remote 203.0.113.1 key 1234 |
ip -6 tunnel add $(interface) mode ip6gre local $(local_addr) remote $(remote_addr) |
Tạo GRE qua IPv6 |
ip -6 tunnel add gre0 mode ip6gre local 2001:db8::1 remote 2001:db8::2 |
ip tunnel del $(interface) |
Xóa tunnel |
ip tunnel del gre0 |
ip tunnel change $(interface) $(options) |
Sửa tunnel |
ip tunnel change tun0 remote 203.0.113.89 key 23456 |
ip tunnel show |
Xem thông tin tunnel |
ip tunnel show tun0 |
Lệnh |
Mô tả |
Ví dụ |
ip route add $(route_options) table $(table_id) |
Tạo route trong bảng tùy chỉnh |
ip route add 192.0.2.0/27 via 203.0.113.1 table 10 |
ip route show table $(table_id) |
Xem route trong bảng |
ip route show table 100 |
ip rule add from $(source_network) $(action) |
Rule theo mạng nguồn |
ip rule add from 192.0.2.0/24 lookup 10 |
ip rule add to $(dest_network) $(action) |
Rule theo mạng đích |
ip rule add to 192.0.2.0/24 blackhole |
ip rule add tos $(tos_value) $(action) |
Rule theo ToS |
ip rule add tos 10 lookup 110 |
ip rule add fwmark $(mark) $(action) |
Rule theo firewall mark |
ip rule add fwmark 0x11 lookup 100 |
ip rule add iif $(interface) $(action) |
Rule theo giao diện vào |
ip rule add iif eth0 lookup 10 |
ip rule add oif $(interface) $(action) |
Rule theo giao diện ra |
ip rule add oif eth0 lookup 10 |
ip rule add $(options) $(action) priority $(value) |
Rule với độ ưu tiên |
ip rule add from 192.0.2.0/24 lookup 10 priority 20 |
ip rule show |
Xem tất cả rule |
ip -6 rule show |
ip rule del $(options) $(action) |
Xóa rule |
ip rule del from 192.0.2.0/24 lookup 10 |
ip rule flush |
Xóa tất cả rule |
ip -6 rule flush |
Lệnh |
Mô tả |
Ví dụ |
ip netns add $(namespace) |
Tạo namespace |
ip netns add ns1 |
ip netns list |
Liệt kê namespace |
– |
ip netns delete $(namespace) |
Xóa namespace |
ip netns delete ns1 |
ip netns exec $(namespace) $(command) |
Chạy lệnh trong namespace |
ip netns exec ns1 ip addr |
ip netns pids $(namespace) |
Liệt kê PID trong namespace |
ip netns pids ns1 |
ip netns identify $(pid) |
Xác định namespace của PID |
ip netns identify 1234 |
ip link set $(interface) netns $(namespace) |
Gán giao diện vào namespace |
ip link set eth0 netns ns1 |
ip link add name $(veth1) type veth peer name $(veth2); ip link set $(veth2) netns $(namespace) |
Kết nối namespace |
ip link add name veth0 type veth peer name veth1; ip link set veth1 netns ns1 |
ip netns monitor |
Theo dõi sự kiện namespace |
– |