linuxルータ構築

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
linuxルータ構築 [2021/04/14 13:05] 133.11.222.89linuxルータ構築 [Unknown date] (現在) – 削除 - 外部編集 (Unknown date) 127.0.0.1
行 1: 行 1:
-# Linux ルータ 
  
-CentOS7をインストールし、1つのNICに192.168.251.204 (enp3s0)、もう一つのNICにOCNから割り当てられた動的なIP (ppp0)が設定されている。 
- 
-``` 
-firewall-cmd --get-active-zone 
-firewall-cmd --zone=external --change-interface=ppp0 --permanent 
-firewall-cmd --zone=trusted --change-interface=enp3s0 --permanent 
-firewall-cmd --zone=external --add-forward-port=port=8352:proto=tcp:toport=3389:toaddr=192.168.251.152 
-4 --permanent 
-firewall-cmd --zone=trusted --add-masquerade --permanent 
-firewall-cmd --reload 
-firewall-cmd --get-active-zone 
-firewall-cmd --list-all --zone=trusted  
-firewall-cmd --list-all --zone=external  
-``` 
- 
-firewalldで制御せず、単にポートを転送するだけなら 
- 
-``` 
-firewall-cmd --list-all --zone=public 
-firewall-cmd --zone=public --add-port=2222/tcp --permanent 
-firewall-cmd --reload 
-socat tcp-listen:2222,fork tcp-connect:192.168.251.167:3389 
-``` 
- 
-firewalldでポート開けるには 
- 
-``` 
-firewall-cmd --zone=public --add-port=1187/tcp --permanent   
-firewall-cmd --zone=public --add-port=10050/tcp --permanent   #zabbix用 
-firewall-cmd --permanent --add-service=nfs --zone=internal  #nfs 
-firewall-cmd --permanent --add-service=mountd --zone=internal  #nfs 
-firewall-cmd --permanent --add-service=rpc-bind --zone=internal  #nfs 
-firewall-cmd --reload 
-``` 
- 
-PPPoEだと速度が出ないので、普通に192.168.251.xxxとNTT光のLANの間をルーティング 
- 
-enp3s0がinternalで、enp0s25がpublic(NTT側) 
- 
-``` 
-firewall-cmd --permanent --zone=internal --change-interface=enp3s0 
-firewall-cmd --permanent --zone=internal --add-masquerade 
-firewall-cmd --permanent --direct --add-rule ipv4 nat POSTROUTING 0 -o enp0s25 -j MASQUERADE 
-firewall-cmd --permanent --direct --add-rule ipv4 filter FORWARD 0 -i enp3s0 -o enp0s25 -j ACCEPT 
-firewall-cmd --permanent --direct --add-rule ipv4 filter FORWARD 0 -i enp0s25 -o enp3s0 -m state --state RELATED,ESTABLISHED -j ACCEPT 
-firewall-cmd --reload 
-firewall-cmd --direct --get-all-rules #ルールの確認 
-firewall-cmd --direct --get-all-rules --permanent #permanentルールの確認 
-``` 
- 
-ポート転送をする場合 
- 
-``` 
-firewall-cmd --zone=public --add-forward-port=port=1187:proto=tcp:toport=3389:toaddr=192.168.251.150 --permanent 
-firewall-cmd --zone=public --add-forward-port=port=1186:proto=tcp:toport=3389:toaddr=192.168.251.214 --permanent 
-``` 
- 
-ポート転送をやめる場合 
- 
-``` 
-firewall-cmd --zone=public --remove-forward-port=port=1186:proto=tcp:toport=3389:toaddr=192.168.251.214 --permanent 
-``` 
- 
- 
-## r251 
- 
-Ubuntu 20での話。 
-ufwを有効にした後 
-``` 
-sudo ufw allow in from 192.168.0.0/16 
-``` 
-で研究室内からのみアクセスを受け入れる。 
- 
-ルーター化するには 
- 
-/etc/default/ufw  
-``` 
-DEFAULT_FORWARD_POLICY="ACCEPT" 
-``` 
- 
-/etc/ufw/sysctl.conf 
-``` 
-net.ipv4.ip_forward=1 
-``` 
- 
-/etc/ufw/before.rules  
-``` 
-# *filterの前あたりに下記を追加 
- 
-*nat 
-#-Fがあるとufw reloadしたときに古い設定をリセットしてくれる 
--F 
-:POSTROUTING ACCEPT [0:0] 
- 
-# Forward traffic from eth0 through eth1. 
--A POSTROUTING -s 192.168.253.0/24 -o enp5s0 -j MASQUERADE #enp5s0がグローバル側 
--A PREROUTING -i enp5s0 -p tcp -d 133.11.144.11 --dport 80 -j DNAT --to-destination 192.168.253.163:80 
--A PREROUTING -i enp5s0 -p tcp -d 133.11.144.11 --dport 443 -j DNAT --to-destination 192.168.253.163:443 
- 
-COMMIT 
- 
-``` 
- 
-``` 
-sudo ufw disable && sudo ufw enable 
-``` 
- 
-``` 
-#before.rulesを書き換えたならば 
-sudo systemctl restart ufw.service 
- 
-#転送ルール確認 
-sudo iptables -t nat -nL 
-``` 
- 
- 
-``` 
-sudo ufw status 
-sudo ufw allow 80 
-sudo ufw allow 443 
-``` 
- 
-``` 
-sudo nmtui 
-``` 
-下記の箇所を変更 
-``` 
-│ 送信先/プレフィックス  次のホップ             メトリック        │      │ 
-│ 192.168.0.0/16_______  192.168.253.1________  100_______ <削除> │      │ 
-│ <追加...>                                                       │      │ 
-│                                                                 │      │ 
-│                                                 <取り消し> <OK> │      │ 
-``` 
-``` 
-[X] このネットワークはデフォルトのルートには使用しない                      │ 
-[X] 自動的に取得されたルートを無視                         
-``` 
  • linuxルータ構築.1618405532.txt.gz
  • 最終更新: 2021/04/14 13:05
  • by 133.11.222.89