linux网络不可达


当前第2页 返回上一页

1、添加网卡,配置ip

1

[root@vm50 ~]# nmcli connection show //查看网卡

名称 UUID 类型 设备

1

2

3

4

5

6

7

8

9

10

11

12

13

eth0 4f5f8b5d-4b51-4e1c-98c7-40f0eb90f241 802-3-ethernet eth0

virbr0 566dccb2-cbb0-4bbe-a714-06f3d313d9cd bridge virbr0

[root@vm50 ~]# nmcli connection add con-name eth1 type ethernet ifname eth1   //添加网卡

连接“eth1”(4cb9f43e-77d6-455f-990c-620e4a12d52b) 已成功添加。

 

[root@vm50 ~]# nmcli connection modify eth1 ipv4.method manual  ipv4.addresses 192.168.2.50/24 con.autoconnect yes  // 配置ip地址,此处192.168.2.50/24(24未加,则网络不可达)

[root@vm50 ~]# nmcli connection up eth1    /激活网卡

连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/8)

[root@vm50 ~]# nmcli connection show

名称    UUID                                  类型            设备  

eht1    4cb9f43e-77d6-455f-990c-620e4a12d52b  802-3-ethernet  eth1          //已经添加的网卡

eth0    4f5f8b5d-4b51-4e1c-98c7-40f0eb90f241  802-3-ethernet  eth0  

virbr0  566dccb2-cbb0-4bbe-a714-06f3d313d9cd  bridge          virbr0

2、配置网关

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

[root@mysql51 ~]# systemctl stop NetworkManager    //配置网关,需先停止网络管理  

[root@mysql51 ~]# route -n                  //查看网关Gateway      

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

192.168.4.0     0.0.0.0         255.255.255.0   U     100    0        0 eth0

192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0

[root@mysql51 ~]# route add default gw 192.168.4.50                

    route: SIOCADDRT: Network is unreachable    //配置网关,出现网络不可达,重新配置ip

[root@mysql51 ~]# route add default gw 192.168.4.50

[root@mysql51 ~]# route -n

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

0.0.0.0         192.168.4.50    0.0.0.0         UG    0      0        0 eth0      

192.168.4.0     0.0.0.0         255.255.255.0   U     100    0        0 eth0

192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0

推荐:linux服务器维护

以上就是linux网络不可达的详细内容,更多文章请关注木庄网络博客

返回前面的内容

相关阅读 >>

Linux修改配置文件的命令是什么

如何理解转换云盘的计费方式

Linux安装失败怎么办

Linux中如何重命名文件

useradd命令详解

Linux中如何设置nginx开机自启

如何释放一台按量付费实例或者到期的预付费的实例

Linux无法删除文件怎么办

Linux u盘乱码怎么办

Linux echo命令怎么用

更多相关阅读请进入《Linux》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...