{"id":67,"date":"2024-07-05T15:30:32","date_gmt":"2024-07-05T15:30:32","guid":{"rendered":"http:\/\/blog.ltzs.us\/?p=67"},"modified":"2024-09-08T22:02:31","modified_gmt":"2024-09-08T22:02:31","slug":"useful-commands","status":"publish","type":"post","link":"http:\/\/blog.ltzs.us\/?p=67","title":{"rendered":"Useful Commands"},"content":{"rendered":"\n<ul class=\"wp-block-list\">\n<li>SSH\n<ul class=\"wp-block-list\">\n<li>ssh-keyscan -H 192.168.1.162 &gt;&gt; ~\/.ssh\/known_hosts (add connection to known hosts to prevent errors with automated connections)<\/li>\n\n\n\n<li>ssh-keygen<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>netstat\n<ul class=\"wp-block-list\">\n<li>netstat -ltun (list all listening ports for tcp and udp)<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>iptables (from <a href=\"https:\/\/askubuntu.com\/questions\/790001\/sharing-connection-iptables\">https:\/\/askubuntu.com\/questions\/790001\/sharing-connection-iptables<\/a>, also <a href=\"https:\/\/stackoverflow.com\/questions\/28857402\/reverse-tethering-of-several-android-devices-via-usb\">https:\/\/stackoverflow.com\/questions\/28857402\/reverse-tethering-of-several-android-devices-via-usb<\/a> might have some useful info)\n<ul class=\"wp-block-list\">\n<li>edit&nbsp;<em>\/etc\/sysctl.conf<\/em>&nbsp;and uncomment:<\/li>\n\n\n\n<li># net.ipv4.ip_forward=1<\/li>\n\n\n\n<li><\/li>\n\n\n\n<li>And the iptables part should look something like below, where eth0 is internet and eth1 is LAN:<\/li>\n\n\n\n<li>iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE<\/li>\n\n\n\n<li><\/li>\n\n\n\n<li>iptables -A FORWARD -i eth1 -o eth0 -m state &#8211;state RELATED,ESTABLISHED -j ACCEPT<\/li>\n\n\n\n<li><\/li>\n\n\n\n<li>iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT<\/li>\n\n\n\n<li><\/li>\n\n\n\n<li>If you have 2 physical network interfaces in server then it should work, you cant use your server as internet gateway if it only has 1 physical interface<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>ssh dd\n<ul class=\"wp-block-list\">\n<li>sudo dd if=\/dev\/mmcblk0 | ssh pi@192.168.200.149 dd of=\/media\/pi\/ext4storage\/image.bin<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>sudo route -n\n<ul class=\"wp-block-list\">\n<li>sudo route del -net 0.0.0.0 gw 0.0.0.0 netmask 0.0.0.0 dev vethfea8f6c<\/li>\n\n\n\n<li>or sudo ip route delete default via 182.18.1.1 dev tun0<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>sudo journalctl &#8211;lines 1000 &#8211;follow<\/li>\n\n\n\n<li>For managing interfaces directly, without using connman or NetworkManager, edit \/etc\/network\/interfaces like follows:\n<ul class=\"wp-block-list\">\n<li># Loopback<\/li>\n\n\n\n<li>#<\/li>\n\n\n\n<li>auto lo<\/li>\n\n\n\n<li>iface lo inet loopback<\/li>\n\n\n\n<li><\/li>\n\n\n\n<li># network card<\/li>\n\n\n\n<li>#<\/li>\n\n\n\n<li>auto eth0 #enables interface on startup<\/li>\n\n\n\n<li>iface eth0 inet static<\/li>\n\n\n\n<li>address 192.168.1.254<\/li>\n\n\n\n<li>netmask 255.255.255.0<\/li>\n\n\n\n<li>network 192.168.1.0<\/li>\n\n\n\n<li>broadcast 192.168.1.255<\/li>\n\n\n\n<li>gateway 192.168.1.1<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>fail2ban\n<ul class=\"wp-block-list\">\n<li><code>fail2ban-client set &lt;jail-name&gt; unbanip &lt;ip-address&gt;<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-67","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/blog.ltzs.us\/index.php?rest_route=\/wp\/v2\/posts\/67","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.ltzs.us\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.ltzs.us\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.ltzs.us\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.ltzs.us\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=67"}],"version-history":[{"count":9,"href":"http:\/\/blog.ltzs.us\/index.php?rest_route=\/wp\/v2\/posts\/67\/revisions"}],"predecessor-version":[{"id":219,"href":"http:\/\/blog.ltzs.us\/index.php?rest_route=\/wp\/v2\/posts\/67\/revisions\/219"}],"wp:attachment":[{"href":"http:\/\/blog.ltzs.us\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=67"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.ltzs.us\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=67"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.ltzs.us\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=67"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}