“IP Linux command line”的版本间的差异
来自百问网嵌入式Linux wiki
Zhouyuebiao(讨论 | 贡献) |
|||
(未显示1个用户的3个中间版本) | |||
第1行: | 第1行: | ||
− | 本文提供了开始使用Linux内核工具ip <ref>https://linux.die.net/man/8/ip</ref>所需的基本信息。 | + | {{DISPLAYTITLE:IP Linux命令行}} |
+ | |||
+ | 本文提供了开始使用Linux内核工具ip <ref name="multiple" >https://linux.die.net/man/8/ip</ref>所需的基本信息。 | ||
+ | |||
=简介= | =简介= | ||
+ | :ip命令用来 <ref name="multiple" />显示/操纵网络接口的路由,设备,策略路由和隧道。 | ||
+ | |||
+ | =开始使用= | ||
+ | |||
+ | *检查网络接口 | ||
+ | |||
+ | <syntaxhighlight lang="bash"> | ||
+ | Board $> ip addr show | ||
+ | 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 | ||
+ | link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 | ||
+ | inet 127.0.0.1/8 scope host lo | ||
+ | valid_lft forever preferred_lft forever | ||
+ | inet6 ::1/128 scope host | ||
+ | valid_lft forever preferred_lft forever | ||
+ | 2: can0: <NOARP,ECHO> mtu 16 qdisc noop state DOWN group default qlen 10 | ||
+ | link/can | ||
+ | 3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 | ||
+ | link/ether 00:80:e1:42:43:65 brd ff:ff:ff:ff:ff:ff | ||
+ | inet 192.168.1.237/22 brd 192.168.3.255 scope global dynamic eth0 | ||
+ | valid_lft 172057sec preferred_lft 172057sec | ||
+ | inet 192.168.0.4/32 scope global eth0 | ||
+ | valid_lft forever preferred_lft forever | ||
+ | inet6 fe80::280:e1ff:fe42:4365/64 scope link | ||
+ | valid_lft forever preferred_lft forever | ||
+ | 4: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000 | ||
+ | link/sit 0.0.0.0 brd 0.0.0.0 | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | *为指定网络接口分配IP地址 | ||
+ | Board $> ip addr add 192.168.1.53 dev eth0 | ||
+ | |||
+ | *删除IP地址 | ||
+ | Board $> ip addr del 192.168.1.53 dev eth0 | ||
+ | *禁用接口 | ||
+ | Board $> ip link set eth0 down | ||
+ | *启用接口 | ||
+ | Board $> ip link set eth0 up | ||
+ | |||
+ | *检查路由表 | ||
+ | Board $> ip route show | ||
+ | default via 192.168.3.254 dev eth0 proto dhcp src 192.168.1.237 metric 1024 | ||
+ | 192.168.0.0/22 dev eth0 proto kernel scope link src 192.168.1.237 | ||
+ | 192.168.3.254 dev eth0 proto dhcp scope link src 192.168.1.237 metric 1024 | ||
+ | *增加静态路由 | ||
+ | Board $> ip route add 192.168.2.0/16 via 192.168.1.1 dev eth0 | ||
+ | |||
+ | *移除静态路由 | ||
+ | Board $> ip route del 192.168.2.0/16 | ||
+ | *设置默认网关 | ||
+ | Board $> ip route add default via 192.168.1.1 | ||
+ | =进阶使用= | ||
+ | :一些用法示例可供参考<ref>https://www.linuxtechi.com/ip-command-examples-for-linux-users/</ref> | ||
+ | =参考= | ||
+ | <references /> | ||
+ | *其它参考链接 | ||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | ! 文件链接 !! 文件链接 !! 描述 | ||
+ | |- | ||
+ | | http://www.tecmint.com/ip-command-examples || 标准 || tecmint的文档 | ||
+ | |- | ||
+ | | https://tty1.net/blog/2010/ifconfig-ip-comparison_en.html || 标准 || 文献资料 | ||
+ | |} | ||
− | |||
[[Category:Linux_Operating_System]][[Category:Linux_monitoring_tools]] | [[Category:Linux_Operating_System]][[Category:Linux_monitoring_tools]] |
2020年1月6日 (一) 15:28的最新版本
本文提供了开始使用Linux内核工具ip [1]所需的基本信息。
简介
- ip命令用来 [1]显示/操纵网络接口的路由,设备,策略路由和隧道。
开始使用
- 检查网络接口
Board $> ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: can0: <NOARP,ECHO> mtu 16 qdisc noop state DOWN group default qlen 10
link/can
3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:80:e1:42:43:65 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.237/22 brd 192.168.3.255 scope global dynamic eth0
valid_lft 172057sec preferred_lft 172057sec
inet 192.168.0.4/32 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::280:e1ff:fe42:4365/64 scope link
valid_lft forever preferred_lft forever
4: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000
link/sit 0.0.0.0 brd 0.0.0.0
- 为指定网络接口分配IP地址
Board $> ip addr add 192.168.1.53 dev eth0
- 删除IP地址
Board $> ip addr del 192.168.1.53 dev eth0
- 禁用接口
Board $> ip link set eth0 down
- 启用接口
Board $> ip link set eth0 up
- 检查路由表
Board $> ip route show default via 192.168.3.254 dev eth0 proto dhcp src 192.168.1.237 metric 1024 192.168.0.0/22 dev eth0 proto kernel scope link src 192.168.1.237 192.168.3.254 dev eth0 proto dhcp scope link src 192.168.1.237 metric 1024
- 增加静态路由
Board $> ip route add 192.168.2.0/16 via 192.168.1.1 dev eth0
- 移除静态路由
Board $> ip route del 192.168.2.0/16
- 设置默认网关
Board $> ip route add default via 192.168.1.1
进阶使用
- 一些用法示例可供参考[2]
参考
- 其它参考链接
文件链接 | 文件链接 | 描述 |
---|---|---|
http://www.tecmint.com/ip-command-examples | 标准 | tecmint的文档 |
https://tty1.net/blog/2010/ifconfig-ip-comparison_en.html | 标准 | 文献资料 |