2023年11月7日火曜日

YAMAHA RTX ルータのWAN側InterfaceへのSSH

 Yamaha RTXルータは、WAN側アドレスへの直接のSSH接続は仕様上できない。

そのため、WAN側にSSHで接続するには、少し、工夫が必要となる。


1 ループバックアドレスの作成

ip loopback1 address 192.168.1.1/32


2 NATの設定

nat descriptor masquerade static 200 1 192.168.1.1 tcp 10022=22

ip lan2 address 10.0.0.1/24

ip lan2 nat descriptor 200


ループバックアドレスを作成し、WAN側アドレス(10.0.0.1)にPort10022でアクセスしたときに、ループバックアドレス(192.168.1.1)に、22で転送するように設定する。

VPN環境でLAN側のアドレスを変更する必要があったが、コンフィグの入れ替えによる再起動ではなく、WAN側からアクセスすることで、接続不能になる危険を避けることができた。

2023年7月28日金曜日

DMVPN Cisco

 R1


Building configuration...


Current configuration : 1939 bytes

!

version 12.4

service timestamps debug datetime msec

service timestamps log datetime msec

no service password-encryption

!

hostname R1

!

boot-start-marker

boot-end-marker

!

!

no aaa new-model

memory-size iomem 5

no ip icmp rate-limit unreachable

ip cef

!

!

!

!

no ip domain lookup

!

multilink bundle-name authenticated

!

!

!

!

!

!

!

!

!

!

!

!

!

!

!

!

!

!

!

!

!

archive

 log config

  hidekeys

!

crypto isakmp policy 1

 encr 3des

 hash md5

 authentication pre-share

 group 2

crypto isakmp key cisco address 0.0.0.0 0.0.0.0

crypto isakmp keepalive 30

!

!

crypto ipsec transform-set dmvpnset esp-3des esp-md5-hmac 

!

crypto ipsec profile dmprofile

 set transform-set dmvpnset 

!

!

!

!

ip tcp synwait-time 5

!

!

!

!

interface Loopback0

 no ip address

!

interface Tunnel0

 ip address 172.31.255.1 255.255.255.0

 no ip redirects

 ip mtu 1368

 ip nhrp authentication dmcisco

 ip nhrp map multicast dynamic

 ip nhrp network-id 99

 ip nhrp holdtime 300

 ip ospf network broadcast

 tunnel source FastEthernet0/0

 tunnel mode gre multipoint

 tunnel key 10

 tunnel protection ipsec profile dmprofile

!

interface FastEthernet0/0

 ip address 64.100.1.100 255.255.255.0

 ip mtu 1454

 duplex auto

 speed auto

!

interface FastEthernet0/1

 ip address 172.16.10.1 255.255.255.0

 ip tcp adjust-mss 1328

 duplex auto

 speed auto

!

interface FastEthernet1/0

 no ip address

 shutdown

 duplex auto

 speed auto

!

interface FastEthernet2/0

 no ip address

 shutdown

 duplex auto

 speed auto

!

router ospf 1

 log-adjacency-changes

 network 172.16.0.0 0.0.0.255 area 0

 network 172.31.255.0 0.0.0.255 area 0

!

ip forward-protocol nd

ip route 0.0.0.0 0.0.0.0 FastEthernet0/0

!

!

no ip http server

no ip http secure-server

!

no cdp log mismatch duplex

!

!

!

!

!

!

control-plane

!

!

!

!

!

!

!

!

!

!

line con 0

 exec-timeout 0 0

 privilege level 15

 logging synchronous

line aux 0

 exec-timeout 0 0

 privilege level 15

 logging synchronous

line vty 0 4

 login

!

!

end


R1#

R2

ter len 0

R2#show run

Building configuration...


Current configuration : 1993 bytes

!

version 12.4

service timestamps debug datetime msec

service timestamps log datetime msec

no service password-encryption

!

hostname R2

!

boot-start-marker

boot-end-marker

!

!

no aaa new-model

memory-size iomem 5

no ip icmp rate-limit unreachable

ip cef

!

!

!

!

no ip domain lookup

!

multilink bundle-name authenticated

!

!

!

!

!

!

!

!

!

!

!

!

!

!

!

!

!

!

!

!

!

archive

 log config

  hidekeys

!

crypto isakmp policy 1

 encr 3des

 hash md5

 authentication pre-share

 group 2

crypto isakmp key cisco address 0.0.0.0 0.0.0.0

crypto isakmp keepalive 30

!

!

crypto ipsec transform-set dmvpnset esp-3des esp-md5-hmac 

!

crypto ipsec profile dmprofile

 set transform-set dmvpnset 

!

!

!

!

ip tcp synwait-time 5

!

!

!

!

interface Tunnel0

 ip address 172.31.255.2 255.255.255.0

 no ip redirects

 ip mtu 1368

 ip nhrp authentication dmcisco

 ip nhrp map multicast 64.100.1.100

 ip nhrp map 172.31.255.1 64.100.1.100

 ip nhrp network-id 99

 ip nhrp holdtime 300

 ip nhrp nhs 172.31.255.1

 ip ospf network broadcast

 ip ospf priority 0

 tunnel source FastEthernet0/0

 tunnel mode gre multipoint

 tunnel key 10

 tunnel protection ipsec profile dmprofile

!

interface FastEthernet0/0

 ip address 64.100.1.101 255.255.255.0

 ip mtu 1454

 duplex auto

 speed auto

!

interface FastEthernet0/1

 ip address 172.16.11.1 255.255.255.0

 ip tcp adjust-mss 1328

 duplex auto

 speed auto

!

interface FastEthernet1/0

 no ip address

 shutdown

 duplex auto

 speed auto

!

interface FastEthernet2/0

 no ip address

 shutdown

 duplex auto

 speed auto

!

router ospf 1

 log-adjacency-changes

 network 172.16.11.0 0.0.0.255 area 0

 network 172.31.255.0 0.0.0.255 area 0

!

ip forward-protocol nd

ip route 0.0.0.0 0.0.0.0 FastEthernet0/0

!

!

no ip http server

no ip http secure-server

!

no cdp log mismatch duplex

!

!

!

!

!

!

control-plane

!

!

!

!

!

!

!

!

!

!

line con 0

 exec-timeout 0 0

 privilege level 15

 logging synchronous

line aux 0

 exec-timeout 0 0

 privilege level 15

 logging synchronous

line vty 0 4

 login

!

!

end


R2#



R3

ter len 0

R3#show run

Building configuration...


Current configuration : 1993 bytes

!

version 12.4

service timestamps debug datetime msec

service timestamps log datetime msec

no service password-encryption

!

hostname R3

!

boot-start-marker

boot-end-marker

!

!

no aaa new-model

memory-size iomem 5

no ip icmp rate-limit unreachable

ip cef

!

!

!

!

no ip domain lookup

!

multilink bundle-name authenticated

!

!

!

!

!

!

!

!

!

!

!

!

!

!

!

!

!

!

!

!

!

archive

 log config

  hidekeys

!

crypto isakmp policy 1

 encr 3des

 hash md5

 authentication pre-share

 group 2

crypto isakmp key cisco address 0.0.0.0 0.0.0.0

crypto isakmp keepalive 30

!

!

crypto ipsec transform-set dmvpnset esp-3des esp-md5-hmac 

!

crypto ipsec profile dmprofile

 set transform-set dmvpnset 

!

!

!

!

ip tcp synwait-time 5

!

!

!

!

interface Tunnel0

 ip address 172.31.255.3 255.255.255.0

 no ip redirects

 ip mtu 1368

 ip nhrp authentication dmcisco

 ip nhrp map multicast 64.100.1.100

 ip nhrp map 172.31.255.1 64.100.1.100

 ip nhrp network-id 99

 ip nhrp holdtime 300

 ip nhrp nhs 172.31.255.1

 ip ospf network broadcast

 ip ospf priority 0

 tunnel source FastEthernet0/0

 tunnel mode gre multipoint

 tunnel key 10

 tunnel protection ipsec profile dmprofile

!

interface FastEthernet0/0

 ip address 64.100.1.102 255.255.255.0

 ip mtu 1454

 duplex auto

 speed auto

!

interface FastEthernet0/1

 ip address 172.16.12.1 255.255.255.0

 ip tcp adjust-mss 1328

 duplex auto

 speed auto

!

interface FastEthernet1/0

 no ip address

 shutdown

 duplex auto

 speed auto

!

interface FastEthernet2/0

 no ip address

 shutdown

 duplex auto

 speed auto

!

router ospf 1

 log-adjacency-changes

 network 172.16.12.0 0.0.0.255 area 0

 network 172.31.255.0 0.0.0.255 area 0

!

ip forward-protocol nd

ip route 0.0.0.0 0.0.0.0 FastEthernet0/0

!

!

no ip http server

no ip http secure-server

!

no cdp log mismatch duplex

!

!

!

!

!

!

control-plane

!

!

!

!

!

!

!

!

!

!

line con 0

 exec-timeout 0 0

 privilege level 15

 logging synchronous

line aux 0

 exec-timeout 0 0

 privilege level 15

 logging synchronous

line vty 0 4

 login

!

!

end


R3#wr

Building configuration...

[OK]

R3#



2023年7月27日木曜日

L2TPv3 over IPSEC Cisco

 R1

R1#show run

Building configuration...


Current configuration : 2153 bytes

!

version 12.4

service timestamps debug datetime msec localtime

service timestamps log datetime msec localtime

no service password-encryption

!

hostname R1

!

boot-start-marker

boot-end-marker

!

logging buffered 512000

!

no aaa new-model

memory-size iomem 5

clock timezone JST 9

no ip icmp rate-limit unreachable

ip cef

!

!

!

!

no ip domain lookup

!

multilink bundle-name authenticated

!

!

!

!

!

!

!

!

!

!

!

!

!

!

!

!

!

!

!

!

!

archive

 log config

  hidekeys

!

!

crypto isakmp policy 1

 encr 3des

 hash md5

 authentication pre-share

 group 2

crypto isakmp key cisco address 10.0.0.2

crypto isakmp keepalive 30 periodic

!

!

crypto ipsec transform-set IPSEC esp-3des esp-md5-hmac

!

crypto map L2TPv3-IPSEC_to_vpn2 1 ipsec-isakmp

 set peer 10.0.0.2

 set transform-set IPSEC

 match address 100

!

!

!

ip tcp synwait-time 5

pseudowire-class L2TPv3

 encapsulation l2tpv3

 ip local interface FastEthernet0/0

!

!

!

!

!

interface FastEthernet0/0

 ip address 10.0.0.1 255.255.255.252

 duplex auto

 speed auto

 crypto map L2TPv3-IPSEC_to_vpn2

!

interface FastEthernet0/1

 no ip address

 shutdown

 duplex auto

 speed auto

!

interface FastEthernet1/0

 no ip address

 duplex auto

 speed auto

 xconnect 10.0.0.2 1 pw-class L2TPv3

!

interface FastEthernet2/0

!

interface FastEthernet2/1

!

interface FastEthernet2/2

!

interface FastEthernet2/3

!

interface FastEthernet2/4

!

interface FastEthernet2/5

!

interface FastEthernet2/6

!

interface FastEthernet2/7

!

interface FastEthernet2/8

!

interface FastEthernet2/9

!

interface FastEthernet2/10

!

interface FastEthernet2/11

!

interface FastEthernet2/12

!

interface FastEthernet2/13

!

interface FastEthernet2/14

!

interface FastEthernet2/15

!

interface Vlan1

 no ip address

!

ip forward-protocol nd

ip route 0.0.0.0 0.0.0.0 FastEthernet0/0

!

!

no ip http server

no ip http secure-server

!

access-list 1 permit any

access-list 100 permit 115 host 10.0.0.1 host 10.0.0.2

no cdp log mismatch duplex

!

!

!

!

!

!

control-plane

!

!

!

!

!

!

!

!

!

!

line con 0

 exec-timeout 0 0

 privilege level 15

 logging synchronous

line aux 0

 exec-timeout 0 0

 privilege level 15

 logging synchronous

line vty 0 4

 login

!

!

end


R2
R2#show run
Building configuration...

Current configuration : 2152 bytes
!
version 12.4
service timestamps debug datetime msec localtime
service timestamps log datetime msec localtime
no service password-encryption
!
hostname R2
!
boot-start-marker
boot-end-marker
!
logging buffered 512000
!
no aaa new-model
memory-size iomem 5
clock timezone JST 9
no ip icmp rate-limit unreachable
ip cef
!
!
!
!
no ip domain lookup
!
multilink bundle-name authenticated
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
archive
 log config
  hidekeys
!
!
crypto isakmp policy 1
 encr 3des
 hash md5
 authentication pre-share
 group 2
crypto isakmp key cisco address 10.0.0.1
crypto isakmp keepalive 30 periodic
!
!
crypto ipsec transform-set IPSEC esp-3des esp-md5-hmac
!
crypto map L2TPv3-IPSEC_to_vpn1 10 ipsec-isakmp
 set peer 10.0.0.1
 set transform-set IPSEC
 match address 100
!
!
!
ip tcp synwait-time 5
pseudowire-class L2TPv3
 encapsulation l2tpv3
 ip local interface FastEthernet0/0
!
!
!
!
!
interface FastEthernet0/0
 ip address 10.0.0.2 255.255.255.252
 duplex auto
 speed auto
 crypto map L2TPv3-IPSEC_to_vpn1
!
interface FastEthernet0/1
 no ip address
 shutdown
 duplex auto
 speed auto
!
interface FastEthernet1/0
 no ip address
 duplex auto
 speed auto
 xconnect 10.0.0.1 1 pw-class L2TPv3
!
interface FastEthernet2/0
!
interface FastEthernet2/1
!
interface FastEthernet2/2
!
interface FastEthernet2/3
!
interface FastEthernet2/4
!
interface FastEthernet2/5
!
interface FastEthernet2/6
!
interface FastEthernet2/7
!
interface FastEthernet2/8
!
interface FastEthernet2/9
!
interface FastEthernet2/10
!
interface FastEthernet2/11
!
interface FastEthernet2/12
!
interface FastEthernet2/13
!
interface FastEthernet2/14
!
interface FastEthernet2/15
!
interface Vlan1
 no ip address
!
ip forward-protocol nd
ip route 0.0.0.0 0.0.0.0 FastEthernet0/0
!
!
no ip http server
no ip http secure-server
!
access-list 1 permit any
access-list 100 permit 115 host 10.0.0.2 host 10.0.0.1
no cdp log mismatch duplex
!
!
!
!
!
!
control-plane
!
!
!
!
!
!
!
!
!
!
line con 0
 exec-timeout 0 0
 privilege level 15
 logging synchronous
line aux 0
 exec-timeout 0 0
 privilege level 15
 logging synchronous
line vty 0 4
 login
!
!
end

2023年7月8日土曜日

RHEL8 SMB自動マウント(CIFS)

RHEL8で再起動後に、自動マウントに失敗する事象が発生。

 以下の設定で回避した。


root@localhost ~]# mkdi /mnt/nas

root@localhost ~]# chmod 777 /mnt/nas

[root@localhost ~]# vi /root/.credfile

username=smbuser

password=smbpass

domain=WORKGROUP

[root@localhost ~]# chown root:root /root/.credfile

[root@localhost ~]# chmod 600 /root/.credfile


[root@localhost ~]# vi /etc/fstab

//192.168.x.x/TMP_Share /mnt/nas cifs _netdev,credentials=/root/.credfile,dir_mode=0755,file_mode=0755 0 0


説明

  • "//192.168.x.x/TMP_Share":ネットワーク上のリモートサーバー(192.168.x.x)のTMP_Share共有フォルダをマウントポイントとして使用します。この共有フォルダは、ローカルディレクトリ"/mnt/nas"に接続されます。


  • "cifs":このマウントポイントはCIFS(Common Internet File System)プロトコルを使用してアクセスされます。CIFSは、WindowsやSambaなどの共有フォルダをLinuxで利用するためのプロトコルです。


  • "_netdev":ネットワークデバイスであることを示すオプションです。このオプションを指定することで、システムがネットワークの利用可能性を確認してからマウントを試行します。


  • "credentials=/root/.credfile":認証情報ファイル"/root/.credfile"を使用して、リモートサーバーへのアクセスに必要なユーザー名とパスワードを指定します。このファイルには機密情報が含まれるため、適切なパーミッションを設定してアクセスを制限する必要があります。


  • "dir_mode=0755":マウントされたディレクトリのパーミッションを指定します。この場合、ディレクトリのモードは"0755"(読み取りと実行が全体に許可され、書き込みが所有者にのみ許可される)に設定されます。


  • "file_mode=0755":マウントされたファイルのパーミッションを指定します。この場合、ファイルのモードは"0755"(読み取りと実行が全体に許可され、書き込みが所有者にのみ許可される)に設定されます。


  • "0 0":ファイルシステムのバックアップとチェックの設定を示します。この場合、バックアップは無効化されており、fsck(ファイルシステムのチェック)も行われません。


<参考>

https://access.redhat.com/ja/solutions/1447443


2022年12月5日月曜日

Linux(CentOS8) NATルータ構築

前提条件 WAN側は名前解決できており、インターネットにアクセスできる。


##########################

#     DNSサーバ構築      #

##########################

dnsmasqをインストール。

yum install dnsmasq

vi /etc/dnsmasq.d/local-dns.conf

---------------------------------------

domain-needed

bogus-priv

---------------------------------------

systemctl enable dnsmasq

systemctl start dnsmasq

firewall-cmd --add-service=dns --permanent --zone=internal

firewall-cmd --reload


##########################

#     NATルータ設定      #

##########################


WAN側 enp3s0

LAN側 enp4s0


firewall-cmd --permanent --zone=internal --change-interface=enp4s0

firewall-cmd --permanent --zone=internal --add-masquerade


firewall-cmd --permanent --direct --add-rule ipv4 nat POSTROUTING 0 -o enp3s0 -j MASQUERADE

firewall-cmd --permanent --direct --add-rule ipv4 filter FORWARD 0 -i enp4s0 -o enp3s0 -j ACCEPT

firewall-cmd --permanent --direct --add-rule ipv4 filter FORWARD 0 -i enp3s0 -o enp4s0 -m state --state RELATED,ESTABLISHED -j ACCEPT


firewall-cmd --reload


2022年10月20日木曜日

Cisco 841M IOS復旧手順

ルータがダウンし、リンクアップしなくなったらしい。

コンソールを接続すると、ロムモニタープロンプトになっている。

loadprog: bad file magic number: 0x0

 rommon 1 >

Dirをたたいても、Flashはきれいに消えている。

Bootコマンドをたたいても、IOSが消えているので、起動できない。
rommon 1 > boot

loadprog: bad file magic number: 0x0
boot: cannot load "flash:"

Ciscoの公式サイトから、IOSをダウンロードする。
同じIOSが動作している機器があれば、そこからダウンロードする手もあるが、公式からダウンロードできた。







PCのIPを192.168.4.2に設定する。
TFTPサーバを起動して、IOSをRootディレクトリに保存する。
Gi4にLANケーブルを接続し、TFTPでIOSを転送する。

rommon 3 > IP_ADDRESS=192.168.4.3
rommon 4 > IP_SUBNET_MASK=255.255.255.0
rommon 5 > TFTP_SERVER=192.168.4.2
rommon 6 > DEFAULT_GATEWAY=192.168.4.1
rommon 7 > TFTP_FILE=c800m-universalk9-mz.SPA.155-3.M10.bin
rommon 8 > TFTP_VERBOSE=2
rommon 9 > tftpdnld

IP_ADDRESS: 192.168.4.3
IP_SUBNET_MASK: 255.255.255.0
DEFAULT_GATEWAY: 192.168.4.1
TFTP_SERVER: 192.168.4.2
TFTP_FILE: c800m-universalk9-mz.SPA.155-3.M10.bin

Invoke this command for disaster recovery only.
WARNING: all existing data in all partitions on flash will be lost!
Do you wish to continue? y/n: [n]: y

Performing tftpdnld over Fast Enet.
Interface is operating at: 100Mbps/FULL DUPLEX
Initializing interface.
Interface link state down.
Interface link state up.
ARPing for 192.168.4.2

完了まで、15分から20分かかった。途中放置
boot コマンドで起動を確認。
コンフィグはNVRAMに保存されていたため、無事
念のため、電源コードを抜いて、再度起動させ、正常起動するか確認する。

flash_init しておいたほうが良かったかも。
最後に気づく。

以上

2022年3月16日水曜日

楽天LINKとXiaomi MI Bandとの連動

 楽天LINKとXiaomi MI Bandの連動をTaskerでカスタマイズした。


タスク作成

 1.通知を出す/Notify

 2.通知取り消し/Notify Cancel


作成したタスクをプロファイルに紐づける。

 通知(Link,Call) 所有者であるアプリ 楽天LINK

 カテゴリー Call


Mi Fitアプリ

 プロフィール

  マイデバイスのMi スマートバンド6をタップ

  通知とリマインド

  アプリ通知

  アプリを管理からTaskerを追加する。


GoogleAD