0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Ubuntu 20.04.4 LTS Serverで内部ネットワークへの踏み台を作る

Posted at

1. はじめに

何度も何度もやってるのだけどUbuntu 20.04になって微妙にかわっていたのでメモ。

2. ネットワーク設定

$ ip address

でIPアドレスを確認できる。

/etc/netplan/99_config.yamlを作るのがいいらしい。

network:
        version: 2
        renderer: networkd
        ethernets:
                enp0s25:
                        dhcp4: false
                        dhcp6: false
                        addresses: [133.X.X.X/27]
                        gateway4: 133.X.X.X
                        nameservers:
                                addresses: [133.X.X.X,8.8.8.8]

インストールの時に生成された

00-installer-config-wifi.yaml
00-installer-config.yaml

の2点は

00-installer-config-wifi.yaml.bak
00-installer-config.yaml.bak

に名前変更。

# netplan apply

で設定反映。

3. sshdの設定

/etc/ssh/sshd_configでPortの行を任意の番号に変更。

# service sshd restart
$ ssh-keygen -f "/home/saru/.ssh/known_hosts" -R "[133.X.X.X]:X"

4. 内部ネットワーク用のインタフェースの設定

USB Ethernetを追加。ip addressコマンドで確認

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:1b:d3:89:a5:b9 brd ff:ff:ff:ff:ff:ff
    inet 133.X.X.X/27 brd 133.X.X.X scope global enp0s25
       valid_lft forever preferred_lft forever
    inet6 fe80::21b:d3ff:fe89:a5b9/64 scope link
       valid_lft forever preferred_lft forever
3: enx001de12f77c7: <NO-CARRIER,NOARP,UP> mtu 1400 qdisc fq_codel state DOWN group default qlen 20
    link/ether 00:1d:e1:2f:77:c7 brd ff:ff:ff:ff:ff:ff
4: wlp10s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:23:15:05:2d:20 brd ff:ff:ff:ff:ff:ff
    inet 172.16.2.28/16 brd 172.16.255.255 scope global dynamic wlp10s0
       valid_lft 477sec preferred_lft 477sec
    inet6 fdc5:1c2d:8716:0:223:15ff:fe05:2d20/64 scope global dynamic mngtmpaddr noprefixroute
       valid_lft 1796sec preferred_lft 1796sec
    inet6 fe80::223:15ff:fe05:2d20/64 scope link
       valid_lft forever preferred_lft forever
5: enx0024a568d5c9: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 00:24:a5:68:d5:c9 brd ff:ff:ff:ff:ff:ff

enx0024a568d5c9に設定する。

以下を追加。

                enx0024a568d5c9:
                        dhcp4: false
                        dhcp6: false
                        addresses: [172.16.2.6/16]

gateway4を付けるとバグるので付けないことが大事。
gatewayは必ず外に向かうように。

5. 蓋を閉じても停止しないように

/etc/systemd/logind.confの以下の所を以下のように修正します。
HandleLidSwitch関連をignoreにします。

#HandleLidSwitch=suspend
#HandleLidSwitchExternalPower=suspend
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore

そしてsystemdを再起動。

# systemctl restart systemd-logind.service

6. dhcpdの設定

# sudo apt install isc-dhcp-server

元の/etc/dhcpd/dhcpd.confをコピー。

7. sshdで公開鍵認証方式のみ許可

/etc/ssh/sshd_configを以下の通り設定

#PasswordAuthentication yes

PasswordAuthentication no
#PubkeyAuthentication yes

PubkeyAuthentication yes
# service sshd restart
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?