Linux配置IP路由

 

 

 没配之前

 

 

命令

ifconfig eth0 192.168.1.101 netmask 255.255.255.0 up

ifconfig eth1 192.168.1.102 netmask 255.255.255.0 up

配置之后

 

 

没配之前

 

 

 配置之后

 

 

永久开启

临时开启 

echo 1 > /proc/sys/net/ipv4/ip_forward

 

 route add -net 192.168.1.100/24  gw 192.168.2.100 dev eth0   

添加路由时报错

route: netmask doesn't match route address

 

-net 后加的是网段,不是IP。
试试 192.168.1.0

route add -net 192.168.1.0/24  gw 192.168.2.100 dev eth0   

 

 

 

删除ip

ip addr del 192.168.1.102 dev eth1

 

删除路由

route del default

route del -net 10.0.0.0 netmask 255.255.0.0 gw 0.0.0.0

posted @ 2020-09-17 11:41  quanzhan  阅读(2547)  评论(0编辑  收藏  举报