>  기사  >  운영 및 유지보수  >  Linux 네트워크에 연결할 수 없습니다.

Linux 네트워크에 연결할 수 없습니다.

angryTom
angryTom원래의
2019-11-08 15:21:0113607검색

Linux 네트워크에 연결할 수 없습니다.

Linux 네트워크에 연결할 수 없습니다

Linux 구성 게이트웨이에서 네트워크에 연결할 수 없다는 메시지가 표시됩니다

route: SIOCADDRT: Network is unreachable

원인: IP 주소를 구성할 때 서브넷 마스크가 추가되지 않았을 가능성이 있습니다

해결책: IP를 재구성하세요. 서브넷 마스크를 추가하고 게이트웨이를 추가합니다

구체적인 작업 프로세스는 다음과 같습니다.

1. 네트워크 카드를 추가하고 ip

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

이름 UUID 유형 장치

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를 구성합니다.

[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 네트워크에 연결할 수 없습니다.의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.