Jump to content

spbr

Member
  • Posts

    114
  • Joined

  • Last visited

Everything posted by spbr

  1. Hi, Currently, I have a bash script which when the user logs in the PC connects to a VM on another computer: ECHO OFF CLS :MENU ECHO. ECHO ............................................... ECHO PRESS 1 or 2 to select your OS, or 3 to EXIT. ECHO ............................................... ECHO. ECHO 1 - Start Windows VM (port# 3390) ECHO 2 - Start Ubuntu VM (port# 3389) ECHO 3 - EXIT ECHO. SET /P M=Type 1, 2 or 3 then press ENTER: IF %M%==1 GOTO Windows IF %M%==2 GOTO Ubuntu IF %M%==3 GOTO EOF :Windows mstsc /v:192.168.0.2:3390 /f GOTO MENU :Ubuntu mstsc /v:192.168.0.2:3389 /f GOTO MENU Now what I want to add, is to be able for the PC to log off when the remote desktop program closes Thank you
  2. Thanks for that, I'm able to have LAN PC ping the WAN PC but not vice versa I've disabled the firewall on both PCs which allowed the LAN PC to ping successfully. The router I'm using is tl-r600vpn Thank you
  3. IPs: PC1: DHCP Router: LAN: 192.168.0.1/24 WAN: 10.0.0.1/24 PC2: 10.0.0.2/24
  4. Hi, Network Layout: | LAN Side | WAN Side | PC1 ---------- Switch ---------- Router ---------- PC2 I'm unable to get PC2 to ping PC1 Seems traffic is unable to transmit from WAN to LAN and vice versa Any help required Thank you
  5. Hi, I've got the below line chart How do I bring the 4 line series closer together, so there is a huge gap between them Thank you
  6. I've got the following python chat server code: import socket import threading import sys class Server: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) connections = [] def __init__(self): self.sock.bind(('0.0.0.0', 10000)) self.sock.listen(1) def handler(self, c, a): while True: data = c.recv(1024) for connection in self.connections: connection.send(data) if not data: print(str(a[0]) + ':' + str(a[1]), "disconnected") self.connections.remove(c) c.close() break def run(self): while True: c, a = self.sock.accept() cThread = threading.Thread(target=slef.handler, args=(c, a)) cThread.daemon = True cThread.start() self.connections.append(c) print(str(a[0]) + ':' + str(a[1]), "connected") class Client: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) def sendMsg(self): while True self.sock.send(bytes(input(""). 'utf-8')) def __init__(self, address): self.sock.connect((address, 10000)) iThread = threading.Thread(target=self.sendMsg) iThread.daemon = True iThread.start() while True data = self.sock.recv(1024) if not data: break print(str(data, 'utf-8')) if (len(sys.argv) > 1): client = Client(sys.argv[1]) else: server = Server() server.run() and I'm able to send messages across two machines, but I would like to automatically have messages sent into the python chat messaging service with a bash script. Is there any way to do this? Thank you
  7. Hi, I'm currently run into an issue with my below python code import socket import threading import sys class Server: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) connections = [] def __init__(self): self.sock.bind(('0.0.0.0', 10000)) self.sock.listen(1) def handler(self, c, a): while True: data = c.recv(1024) for connection in self.connections: connection.send(data) if not data: print(str(a[0]) + ':' + str(a[1]), "disconnected") self.connections.remove(c) c.close() break def run(self): while True: c, a = self.sock.accept() cThread = threading.Thread(target=self.handler, args=(c, a)) cThread.daemon = True cThread.start() self.connections.append(c) print(str(a[0]) + ':' + str(a[1]), "connected") class Client: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) def sendMsg(self): while True: self.sock.send(bytes(input(""), 'utf-8')) def __init__(self, address): self.sock.connect((address, 10000)) iThread = threading.Thread(target=self.sendMsg) iThread.daemon = True iThread.start() while True: data = self.sock.recv(1024) if not data: break print(str(data, 'utf-8')) if (len(sys.argv) > 1): client = Client(sys.argv[1]) else: server = Server() server.run() Everytime I run the code on the client end I keep getting the following error: File "chat.py", line 29 print(str(a[0]) + ':' + str(a[1]), "connected") The python code is exactly the same on the server and client end, but I don't get any issues on the server end. Any Questions? Thank you
  8. Hi, #! /bin/bash ip="172.16.0.1" networkconf="filetext.txt" dhcpd="filetext.txt" netmask30="2" netmask29="6" netmask28="14" echo "How many raspberry pi's are on your premises?" read norpi if [[ "$norpi" -le "$netmask30" ]]; then sed -i "30s/.*/netmask 255.255.255.252/" "$networkconf" sed -i.bak "10s/$/ 255.255.255.252{/" "$dhcpd" elif [[ "$norpi" -ge 3 && "$norpi" -le "$netmask29" ]]; then sed -i "30s/.*/netmask 255.255.255.248/" "$networkconf" sed -i.bak "10s/$/ 255.255.255.248{/" "$dhcpd" elif [[ "$norpi" -ge 7 && "$norpi" -le "$netmask28" ]]; then sed -i "30s/.*/netmask 255.255.255.240/" "$networkconf" sed -i.bak "10s/$/ 255.255.255.240{/" "$dhcpd" else echo "unable" fi lastoct=${ip: -1} range="$(($lastoct + $norpi))" echo "$range" So at the moment I'm able to take the last digit of the ip and add the amount of raspberry pi's, but what I want to do know is to place the new digit, from variable 'range' and replace the last digit of 'ip' with 'range'. Any Suggestions? Thank you
  9. I guess thats one way Do you think this would work? variable='cmd1;cmd2'
  10. Hi, Is there a way to group multiple commands, which then can be executed by a single variable? variable( command1 command2 ) Any Questions? Thank you
  11. root@Gateway:~# cat /etc/*-release PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)" NAME="Raspbian GNU/Linux" VERSION_ID="8" VERSION="8 (jessie)" ID=raspbian ID_LIKE=debian HOME_URL="http://www.raspbian.org/" SUPPORT_URL="http://www.raspbian.org/RaspbianForums" BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs" root@Gateway:~# lsb_release -a No LSB modules are available. Distributor ID: Raspbian Description: Raspbian GNU/Linux 8.0 (jessie) Release: 8.0 Codename: jessie root@Gateway:~# uname -a Linux Gateway 4.4.50+ #970 Mon Feb 20 19:12:50 GMT 2017 armv6l GNU/Linux root@Gateway:~#
  12. Hi, So I want to create a DHCP server and im trying to install isc-dhcp-server but everytime I keep getting pi@Gateway:~ $ sudo apt install isc-dhcp-server Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package isc-dhcp-server My sources list is deb http://mirror.ox.ac.uk/sites/archive.raspbian.org/archive/raspbian jessie main contrib non-free rpi #deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free #deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free rpi # Uncomment line below then 'apt-get update' to enable 'apt-get source' #deb-src http://archive.raspbian.org/raspbian/ jessie main contrib non-free rpi Any suggestions?
  13. Hi I keep getting the following error sed: -e expression #1, char 32: unterminated `s' command sed: -e expression #1, char 35: unterminated `s' command sed: -e expression #1, char 35: unterminated `s' command whenever I use the following bash script #! /bin/bash mailgmail="smtp\.gmail\.com:587" mailyahoo="smtp\.mail\.yahoo\.com:587" echo "Email:" read emailuse echo "Password:" read emailpass sed -i "6s/.*/root=$emailuse/" /etc/ssmtp/ssmtp.conf sed -i "25s/.*/AuthUser=$emailuse/" /etc/ssmtp/ssmtp.conf sed -i "26s/.*/AuthPass=$emailpass/" /etc/ssmtp/ssmtp.conf if [[ "$emailuse" == *"gmail"* ]]; then sed -i "10s/.*/mail=$mailgmail" /etc/ssmtp/ssmtp.conf sed -i "23s/.*/mailhub=$mailgmail" /etc/ssmtp/ssmtp.conf sed -i "28s/.*/mailhub=$mailgmail" /etc/ssmtp/ssmtp.conf elif [[ "$emailuse" == *"yahoo"* ]]; then sed -i "10s/.*/mail=$mailyahoo" /etc/ssmtp/ssmtp.conf sed -i "23s/.*/mailhub=$mailyahoo" /etc/ssmtp/ssmtp.conf sed -i "28s/.*/mailhub=$mailyahoo" /etc/ssmtp/ssmtp.conf else echo "Use another email address with yahoo or gmail" fi Thank you
  14. dropping of 172.16.0.0/24
  15. Hi I've got the current iptables below on my gateway pi Chain INPUT (policy ACCEPT) target prot opt source destination DROP all -- 172.16.0.0/24 anywhere REJECT tcp -- anywhere anywhere tcp dpt:http reject-with icmp-port-unreachable REJECT tcp -- anywhere anywhere tcp dpt:https reject-with icmp-port-unreachable ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh ACCEPT icmp -- anywhere anywhere icmp echo-request Chain FORWARD (policy ACCEPT) target prot opt source destination ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED ACCEPT all -- anywhere anywhere Chain OUTPUT (policy ACCEPT) target prot opt source destination but for some reason its not taking any affect on my traffic Thank you
  16. Hi The below file shows the contents of the interfaces file. /etc/network/interfaces # interfaces(5) file used by ifup(8) and ifdown(8) # Please note that this file is written to be used with dhcpcd # For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf' # Include files from /etc/network/interfaces.d: source-directory /etc/network/interfaces.d auto lo iface lo inet loopback #allow-hotplug wlan0 #iface wlan0 inet manual # wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf #allow-hotplug wlan1 #iface wlan1 inet manual # wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf auto eth0 allow-hotplug eth0 iface eth0 inet static address 192.168.0.50 netmask 255.255.255.0 gateway 192.168.0.1 dns-nameservers 8.8.8.8 8.8.4.4 auto wlan0 allow-hotplug wlan0 iface wlan0 inet static address 192.168.1.1 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 However when I do ifconfig, I get the following lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:384 errors:0 dropped:0 overruns:0 frame:0 TX packets:384 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1 RX bytes:31104 (30.3 KiB) TX bytes:31104 (30.3 KiB) wlan0 Link encap:Ethernet HWaddr b8:27:eb:71:4d:84 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2715 errors:0 dropped:0 overruns:0 frame:0 TX packets:19 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:180 (180.0 B) TX bytes:0 (0.0 B) wlan1 Link encap:Ethernet HWaddr 08:6a:0a:64:18:49 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2715 errors:0 dropped:0 overruns:0 frame:0 TX packets:19 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:180 (180.0 B) TX bytes:0 (0.0 B) Any Suggestions? Thank you
  17. Hi, Instead of using br0 to bridge two ethernet ports, is there something else to use? The reason for this as I want to use iptables on a specific ethernet port, but when using br0 it cancels out eth0 & eth1. Thank you
  18. spbr

    ufw - websites

    Hi, Currently i've got my pi as the gateway for my pc. At the moment, when I turn on ufw, I'm unable to view any websites. Why? Thank you
  19. spbr

    ufw debian

    Hi I want to stop device a from pinging device b, but with the ufw rules being on device b. (as shown in the pic) What would be the ufw config for this one? Thank you
×