Linux ppp0 및 기본 라우팅과 공용 인터넷에 액세스하는 방법

Linux ppp0 및 기본 라우팅과 공용 인터넷에 액세스하는 방법

내 프로젝트에는 모바일 인터넷이 필요합니다. M2M 시뮬레이션(공용 IP, NAT 없음)과 함께 LTE 스틱 모뎀을 사용하여 이를 달성하려고 합니다.

이것은 ubuntu(5.3.0-29-generic)에서는 잘 작동하지만 Raspbian Buster(4.19.97+)에서는 작동하지 않습니다.

Feb 11 22:31:48 raspberrypi systemd[1]: Reloading.
Feb 11 22:31:51 raspberrypi systemd[1]: [email protected]: Current command vanished from the unit file, execution of the command list won't be resumed.
Feb 11 22:31:51 raspberrypi systemd[1]: [email protected]: Current command vanished from the unit file, execution of the command list won't be resumed.
Feb 11 22:32:00 raspberrypi systemd[1]: Reloading.
Feb 11 22:32:41 raspberrypi pppd[699]: pppd 2.4.7 started by root, uid 0
Feb 11 22:32:41 raspberrypi pppd[699]: Using interface ppp0
Feb 11 22:32:41 raspberrypi pppd[699]: Connect: ppp0 <--> /dev/ttyUSB1
Feb 11 22:32:41 raspberrypi NetworkManager[288]: <info>  [1581460361.7138] manager: (ppp0): new Ppp device (/org/freedesktop/NetworkManager/Devices/5)
Feb 11 22:32:42 raspberrypi pppd[699]: CHAP authentication succeeded: Welcome!!
Feb 11 22:32:42 raspberrypi pppd[699]: CHAP authentication succeeded
Feb 11 22:32:42 raspberrypi pppd[699]: Could not determine remote IP address: defaulting to 10.64.64.64
Feb 11 22:32:42 raspberrypi pppd[699]: not replacing default route to eth0 [192.168.0.1]
Feb 11 22:32:42 raspberrypi pppd[699]: local  IP address 10.217.44.214
Feb 11 22:32:42 raspberrypi pppd[699]: remote IP address 10.64.64.64
Feb 11 22:32:42 raspberrypi pppd[699]: primary   DNS address 109.249.185.224
Feb 11 22:32:42 raspberrypi pppd[699]: secondary DNS address 109.249.186.32
Feb 11 22:32:42 raspberrypi NetworkManager[288]: <info>  [1581460362.2378] device (ppp0): state change: unmanaged -> unavailable (reason 'connection-assumed', sys-iface-state: 'external')
Feb 11 22:32:42 raspberrypi NetworkManager[288]: <info>  [1581460362.3090] device (ppp0): state change: unavailable -> disconnected (reason 'none', sys-iface-state: 'external')
Feb 11 22:35:30 raspberrypi pppd[699]: Terminating on signal 15
Feb 11 22:35:30 raspberrypi pppd[699]: Connect time 2.8 minutes.
Feb 11 22:35:30 raspberrypi pppd[699]: Sent 0 bytes, received 0 bytes.
Feb 11 22:35:30 raspberrypi NetworkManager[288]: <info>  [1581460530.4393] device (ppp0): state change: disconnected -> unmanaged (reason 'connection-assumed', sys-iface-state: 'external')
Feb 11 22:35:30 raspberrypi pppd[699]: Connection terminated.

이를 위해 wvdial과 다음 설정을 사용해 보았습니다.

[Dialer Defaults]
Auto DNS = yes
Init1 = ATZ+CFUN=1
Init2 = ATH
Init3 = ATE1
Init3 = AT+CGDCONT=1,"IP","EEM2M"
Stupid mode = 1
Baud = 9600
Dial Command = ATD
Modem = /dev/ttyUSB1
ISDN = 0
Phone = *99#
Password = bt
Username = bt

NetworkManager.conf에는 다음 내용이 있습니다.

[main]
plugins=ifupdown,keyfile

[ifupdown]
managed=false

ppp/resolv.conf에는 다음 내용이 있습니다.

nameserver 109.249.185.224
nameserver 109.249.186.32

나는 이것이 설정에 의해 설정된 것 같아요 (위의 로그 참조)

마지막으로 이것은 wvdial이 실행된 후 ifconfig -a를 실행하는 것을 보여줍니다. ppp0의 6개 패킷은 10.217.44.214에 대한 내부 핑입니다.

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.12  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::b435:fc5d:b267:a226  prefixlen 64  scopeid 0x20<link>
        ether 00:e0:92:00:15:f3  txqueuelen 1000  (Ethernet)
        RX packets 299  bytes 30739 (30.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 269  bytes 36598 (35.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 4  bytes 156 (156.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4  bytes 156 (156.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ppp0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1500
        inet 10.217.44.214  netmask 255.255.255.255  destination 10.64.64.64
        ppp  txqueuelen 3  (Point-to-Point Protocol)
        RX packets 6  bytes 66 (66.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 7  bytes 129 (129.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wwan0: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether 00:1e:10:1f:00:00  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

편집 1: wvdial을 루트로 실행하면 다음과 같은 결과가 나타납니다.

--> WvDial: Internet dialer version 1.61
--> Initializing modem.
--> Sending: ATZ+CFUN=1
OK
--> Sending: ATH
OK
--> Sending: AT+CGDCONT=1,"IP","EEM2M"
OK
--> Modem initialized.
--> Sending: ATD*99#
--> Waiting for carrier.
CONNECT 150000000
--> Carrier detected.  Starting PPP immediately.
--> Starting pppd at Tue Feb 11 23:01:49 2020
--> Pid of pppd: 1281
--> Using interface ppp0
--> pppd: X?C[01]X?C[01]
--> pppd: X?C[01]X?C[01]
--> pppd: X?C[01]X?C[01]
--> pppd: X?C[01]X?C[01]
--> pppd: X?C[01]X?C[01]
--> pppd: X?C[01]X?C[01]
--> local  IP address 10.217.44.214
--> pppd: X?C[01]X?C[01]
--> remote IP address 10.64.64.64
--> pppd: X?C[01]X?C[01]
--> primary   DNS address 109.249.185.224
--> pppd: X?C[01]X?C[01]
--> secondary DNS address 109.249.186.32
--> pppd: X?C[01]X?C[01]

또한 wvdial을 실행하면 NetworkManager가 /etc/resolv.conf에 올바른 DNS를 로드하여 변경되는 것으로 나타났습니다.

# Generated by NetworkManager
nameserver 194.168.4.100
nameserver 194.168.8.100

도착하다

nameserver 109.249.185.224
nameserver 109.249.186.32
# Generated by NetworkManager

답변1

비슷한 문제에 직면하여,

sudo route add default ppp0

나를 위해 작동합니다.

이 프로세스를 자동화해야 하는 경우 연결이 설정될 때 실행될 스크립트를 /etc/ppp/ip-up.d에 만들 수 있습니다.

관련 정보