deepin使用iproute配置网络命令

用惯了ifconfig命令配置网络,ip命令使用的非常少。今天因为临时需要用到ip命令,就来详细学习下ip命令的用法。

查看系统设备的IP地址:

ip a
ip address show
ip address show eth0

配置设备的IP地址:

ip address add 192.168.1.11/24 dev eth0
ip address add 192.168.1.12/24 dev eth0

删除设备的IP地址:

sudo ip address del 192.168.1.12/24 dev eth0

删除设备上的全部IP地址:

sudo ip address flush dev eth0

查看系统上的route列表。

sudo ip route list
sudo ip route list dev eth0

假设现在你有一个IP地址,你需要知道路由包从哪里来。

sudo ip route get 192.168.1.2

添加路由:

sudo ip route add default via 192.168.1.1 dev eth0
sudo ip route add 192.168.2.0/24 via 192.168.1.1 dev eth3
删除路由:
sudo ip route del default via 192.168.1.1 dev eth0
sudo ip route del 192.168.2.0/24 via 192.168.1.1 devFailed to restart network.service: Unit network.service not found.
deepin@sw6a:~$ sudo reboot
Connection to 192.168.1.10 closed by remote host.
Connection to 192.168.1.10 closed.
eth3

清除系统中IP地址:

sudo ip address flush dev eth1
清除系统中route
sudo ip route flush dev eth1sudo ip route add

把IP配置写入配置文件/etc/network/interfaces

auto eth0
iface eth0 inet static
address 192.168.1.7
netmark 255.255.255.0
broadcast 192.168.1.255
gateway 192.168.1.1

发布了41 篇原创文章 · 获赞 0 · 访问量 531

猜你喜欢

转载自blog.csdn.net/m0_46560389/article/details/105206105