전화접속 서버 만들기

이번에는 전화로 인터넷에 접속하는 서버를 만들 것이다.

우선 가상머신에 우분투 서버를 깔아주고 USB모뎀을 연결해 주었다.

다음 명령어를 입력하여 mgetty와 ppp를 깔아준다.

sudo apt update
sudo apt upgrade
sudo apt install mgetty ppp

이제 mgetty가 자동으로 실행 되도록 서비스를 등록해 줄 것이다.

/lib/systemd/system/mgetty.service 파일을 만들어 준 후 다음 내용을 채워 넣는다.

[Unit]
Description=External Modem
Documentation=man:mgetty(8)
Requires=systemd-udev-settle.service
After=systemd-udev-settle.service

[Service]
Type=simple
ExecStart=/sbin/mgetty /dev/ttyACM0
Restart=always
PIDFile=/var/run/mgetty.pid.ttyACM0

[Install]
WantedBy=multi-user.target

그리고 이제 /etc/mgetty/mgetty.config 파일을 열고 맨 아래에 다음 내용을 채워 넣는다.

debug 9

port ttyACM0
 port-owner root
 port-group dialout
 port-mode 0660
 data-only yes
 ignore-carrier no
 toggle-dtr yes
 toggle-dtr-waittime 500
 rings 2
 #autobauding yes
 speed 57600

그리고 아래 명령어를 실행해서 부팅시 켜지도록 해 준다.

sudo systemctl enable mgetty.service

재부팅 하고나서 서버로 전화를 걸면 터미널에 접속할 수 있다.

터미널 접속 영상

이제 ppp를 설정해 줄 것이다 /etc/ppp/options 파일일에서 아래 부분과 같이 주석을 해제하고 수정해 준다

# Define the DNS server for the client to use
ms-dns 8.8.8.8
# async character map should be 0
asyncmap 0
# Require authentication
auth
# Use hardware flow control
crtscts
# We want exclusive access to the modem device
lock
# Require the client to authenticate with pap
+pap
# Heartbeat for control messages, used to determine if the client connection has dropped
lcp-echo-interval 30
lcp-echo-failure 4
# Cache the client mac address in the arp system table
proxyarp
# Disable the IPXCP and IPX protocols.
noipx

이제 /etc/ppp/options.ttyACM0 를 아래 내용으로 생성해 준다

local
lock
nocrtscts
192.168.32.1:192.168.32.105
netmask 255.255.255.0
noauth
proxyarp
lcp-echo-failure 60

이제 ppp계정을 만들 것이다. 계정을 만들고 비밀번호를 설정해 주

sudo useradd -G dialout,dip,users -m -g users -s /usr/sbin/pppd ppp
sudo passwd ppp

/etc/ppp/pap-secrets 파일의 맨 아랫부분에 아래와 같이 아까 만든 아이디와 비밀번호를 추가 한다.

아이디 * "비밀번호" *

이제 ppp에 사용되는 ip가 외부에 접근할 수 있도록 설정을 해야 한다.

/etc/systemd/system/ppp-ready.service 파일을 만들고 아래 내용을 넣는다.

[Unit]
After=network.target

[Service]
ExecStart=/usr/local/bin/ppp-ready.sh

[Install]
WantedBy=default.target

그리고 /usr/local/bin/ppp-ready.sh 파일을 만들고 아래 내용을 넣는다.

#!/bin/bash
iptables -t nat -A POSTROUTING -s 192.168.32.0/24 -o enp0s3 -j MASQUERADE

아래 명령어를 입력 해 파일의 권한을 수정해 준다

sudo chmod 744 /usr/local/bin/ppp-ready.sh
sudo chmod 644 /etc/systemd/system/ppp-ready.service

마지막으로 /etc/sysctl.conf 파일에서 아래 부분을 주석 해제 한다.

net.ipv4.ip_forward=1

이제 다 끝났다 시스템을 껐다가 키면 이제 전화 접속을 할 준비가 됐다.

아래는 전화 접속으로 Google에 접속하는 영상이다.

인터넷 연결 영상

참조
Dial up server – Doge Microsystems
How to run script on startup on Ubuntu 22.04 Jammy Jellyfish Server/Desktop – Linux Tutorials – Learn Linux Configuration

코멘트

“전화접속 서버 만들기”에 대한 4개 응답

  1. kwangyol 아바타
    kwangyol

    안녕하세요~ 혹시 사용하신 USB 모뎀이 어떤 제품이었는지 알수있을까요?

    1. 미니 아바타

      그냥 인터넷에서 USB모뎀 검색한거 사서 썼었어서요 정확한 모델은 기억이 안 나네요…

      1. kwangyol 아바타
        kwangyol

        참조하신 글(https://dogemicrosystems.ca/wiki/Dial_up_server)에도

        Note: You will have a lot of trouble using a softmodem/winmodem! You are much better off using a hardware-based modem.

        소프트 모뎀을 쓰면 문제가 많이 생길거라고 저자가 말해서요,
        저는 5만원 이하대의 소프트모뎀을 썼는데 mgetty 접속이 잘안되더라구요,
        (h/w컨트롤러모뎀은 10~20만원정도)
        근데 작성하신글에서는 접속이 잘되서 어떤 usb 모뎀을 쓰셨는지 궁금해서 여쭤봤습니다.

        1. 미니 아바타

          소프트 모뎀이라 그런지 한번 연결이 종료되면 또 다시 연결이 안되고 그렇긴 하더라구요.
          지금은 전화접속 서버 운영 안하고 있고요 나중에 다시 HW모뎀 사서 구축해 보려고 생각하고 있습니다.
          나중에 구축하게 되면 다시 포스트 써 보도록 하겠습니다.

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다