How can I detect the Ethernet cable has been switched to a different network and if so shutdown computer? - switch-statement

I have a problem at work where a co-worker is the system admin and he has gone LogMeIn crazy. I even tried moving all three of my computers to a different network administered by a different department and domain. He just simply unplugs network 1 cable and plugs in network 2 cable and proceeds to mess with all my settings via LogMein. I don't know the exact details as to how he is doing it but I did manage to catch a connection in the event log the captured his computer name, IP Address and port 64474. This is a huge problem!
Can anyone tell how I can listen for network 1 and accept it but if network 2 cables is connected shutdown the computer right away
The program "LogMeIn" can even connect to a computer that is unattended and become admin.
My plan is to Visual Basic 2010 32 bit on a 64 bit windows 7 computer and write a program that will store a variable in a file that will hold the desired network IP or string that will be compared to the ip that computer currently has.
The desired network uses DHCP and unwanted is an intranet using a range of fixed IP addresses (e.g. 10.20.2.0 - 10.20.2.99).
Now here is my question:
The only compiler I have available is Visual Studio 2010 32 bit. What type of data do I need to capture other than IP addresses to know a different network was plugged into? I can handle where to store the data and how to compare it.
Here is what I am starting with just the IP:
Dim HostName As String = Dns.GetHostName()
Dim thisHost As IPHostEntry = Dns.GetHostByName(HostName)
Dim thisIpAddr As String = thisHost.AddressList(0).ToString
Debug.WriteLine(thisIpAddr)
Maybe I could do it in a simple batch file drop it into startup like below but how do I handle booting without any Ethernet plugged in?
#echo off
for /f "delims=[] tokens=2" %%a in ('ping -4 -n 1 %ComputerName% ^| findstr [') do set NetworkIP=%%a
echo Network IP: %NetworkIP%
for /f %%a in ('powershell Invoke-RestMethod api.ipify.org') do set PublicIP=%%a
echo Public IP: %PublicIP%
IF %PublicIP% EQU 75.555.55.555 (
echo Its Me!
)ELSE (shutdown /f
)

Related

Virtual Serial Port on Linux with Elfin EE-10

I want to connect the UART-Port of our central heater to my ProxMox-Server (LXC - Debian) over Web with Virtual Serial Port.
I bought this: https://www.aliexpress.com/item/4000945033185.html and connected it to the central heater and is reachable in the local network.
Since I have never done something in this direction I'm not exactly sure how to set up the connection and I hope someone can help me.
In the Web-Interface of the device, I can set up different protocols (see screenshot).
Thank you for your help.
You need to know more about what the heater is writing and expecting on the serial port. Did you select the right serial baud rate for it?
Have you read the EE-10 IOT_Device_Series_Software_Funtion_20200623 guide (in Downloads tab)? One possibility for further debug is to select the telnetd mode and connect from Linux with telnet to the IP address of the device, default port 23. (Ensure your Linux firewall allows this).
It seems it should ask for login and password, as in the web page. Then you might get an EPORT> prompt which is the EE-10 cli. Enter Exit to enter transparent mode when what you type is sent directly to the heater, and what you see comes from the heater.

Is there a way to "give a url" to a website runned in a WLAN?

I've developed a small application to manage grocery using Node.js and Express, and I run it locally on my pc. There are other three computers in my home: all four computers are connected to my wi-fi and need to access to my grocery application.
In this scenario, my computer acts as a "server": the other three connect to mine using my IP and the port I've set in Node.js (eg: to access in my application I type in my browser "http://localhost:3000/", while from the other three computers it's something like "http://192.168.x.x:3000/").
My problem is the following: since I'm connected to wifi, I found that my IP address often changes, so everytime this happens I have to look for my address (using ipconfig) and manually update the bookmarks saved in the other computers. I was wondering if there is a program / method / script / something that I could do to give my computer some sort of "local url" or something similar to a "local DNS", a name that can be used to find my pc in the WLAN. I've already tried to set my wi-fi router in order to have static IPs but for some reason that doesn't work well with my internet connection, so I was hoping for a different solution.
Thanks for your help!
While some smart routers have DNS capabilities, my experience is that most home routers do not. This solution can work without built in DNS capabilities for your router, and while it is not exactly 'DNS' it should keep you from having to reset the bookmarks on the other computers. Depending on your router, you should be able to adjust the DHCP range of IP addresses that it can assign to devices. You can set it to a smaller range of addresses, and assign your host computer a static address, so it doesn't change.
For example, lets say your network is using 192.168.0.x/24 addresses. So the router by default will most likely assign IP addresses in a range from 192.168.0.2 (the router is usually 192.168.0.1) to 192.168.0.254. You could adjust the DHCP range in your router settings to assign an IP address range from 192.168.0.1 to 192.168.0.250, and then manually set your host computer's address to 192.168.0.251. On all the other computers, you can now set the bookmarks to 192.168.0.251, and you shouldn't have to change them. You could also edit the hosts file (on Windows machines) so it maps an internal domain name, such as groceries.com, to your host machine, 192.168.0.250. To change the hosts file, go to C:\Windows\System32\drivers\etc, then open the hosts file in notepad, and enter in the desired domain name and IP address. Once the hosts file has been edited on all the client computers, you can just use groceries.com as the url from any browser on the computer
here's a link for manually setting the IP address on a Windows 10 PC
https://support.microsoft.com/en-us/help/15089/windows-change-tcp-ip-settings

Configuring Ports on a Cisco Switch

I am very new to Cisco networking (haven't done any course either). I have been trying to learn a bit of networking myself and had no trouble in doing some of the basic stuff which i needed for my personal work. But i am planning to buy a new Cisco switch(a gigabit switch) and configure it to 2 different networks (1 being an internet and other being a separate network for a specific job). I want to configure the ports in such a way that the first few slots for normal internet and the rest for my other network. For example if its a Cisco 2950 48 port switch, the first 1-16 port for my local internet network and the ports from 17-32 for my other network. Can somebody give me a run down on how to achieve this? Sorry for such a long but basic question, i am just trying to save few $$ and learning something new. Any help would be appreciated. Cheers
You can just create the 2 different Vlans and Give the Access port to the 1st vlan with port 1 - 16 , And for Second vlan Give access port remaining Ports. As well you can also configure 2 different network on Single Switch .
Vlans can separate the network traffic away from each other. For Example
Int range gi 0/1 - 16
Desc Local Internet Network
Switchport access vlan 444
Switch port mode access
Int range gi 0/17 - 32
Desc Other Network
Switchport access vlan 555
Switch port mode access
Of course it depends on what you plug into the ports? depends on what type of switchport it is going to be.
Switch#configure terminal
Switch(config)#vlan 10
Switch(config-vlan)#name Local_Internet_Network
Switch(config-vlan)#exit
Switch(config)#vlan 20
Switch(config-vlan)#name my_other_network
Switch(config-vlan)#exit
Switch(config)#interface range gigabitEthernet 0/1-16
Switch(config-if-range)#switchport mode access
Switch(config-if-range)#switchport access vlan 10
Switch(config-if-range)#exit
Switch(config)#interface range gigabitEthernet 0/17-32
Switch(config-if-range)#switchport mode access
Switch(config-if-range)#switchport access vlan 20
Switch(config-if-range)#exit
Switch(config)#exit
Switch#write memory
and check on trunk
The 2950 switch was a L2 switch only last time I checked so it will not be able to route between the VLANs. You may want to consider a small firewall in order to provide the layer 3 element (routing) and block any internet traffic from hitting your LAN. You can then also utilise a switch with this topology.
The respective switch VLANs for Internet and LAN would be connected to the relevant Internet /LAN firewall ports and your servers would be connected to the LAN. The switch management port should also be on the trusted LAN network or a dedicated management VLAN.

Bridge Wifi to Raspberry Pi using Ethernet Cable

I am not finding this question in SF history, which was a surprise, so I'll go ahead and ask it.
I am working on an IoT Raspberry Pi project with Windows 10 and need to connect it to the internet via an Ethernet/USB adapter. The adapter itself is made by Belkin. Using this, I can see an ip of 169.stuff get generated for my Pi, which is a private ip. I can deploy code to that from my connected box, however other devices are not able to reach it, and it is not able to make connections out to any servers.
I'm wondering if anybody knows how to bridge the connection.
I am attempting to use the new Azure IoT Hub and the SDK with this in case that makes any differences as that is not a simple rest interface and I believe is some form of socket connection.
Additional Notes:
I have installed a DCHP Server and the Pi gets the ip address: 192.168.0.3 assigned to it. Unfortunately the Pi still can not ping external sites, such as google.com
Latest Discoveries:
I am on a corporate box, which has internet sharing disabled by the system admin. Following these instructions: http://zizhujy.com/blog/post/2013/07/07/Solved-Internet-Connection-Sharing-has-been-disabled-by-the-Network-Administrator.aspx Fails. It shuts down all connectivity to my box and I cannot ping anything or reach the internet or anything.
Thanks,
~David
The 169 address means it isn’t getting a DHCP address assigned.
Since you don't have a router for the Ethernet, you can use Internet Connection Sharing, however we will need to run the following commands against the Pi to set a static IP, gateway, and dns server, since internet connection sharing botches this up a bit at times:
Set-Item WSMan:\localhost\Client\TrustedHosts -Value 192.168.137.2
Enter-PSSession -ComputerName 192.168.137.2 -Credential 192.168.137.2\Administrator
set-executionpolicy unrestricted
netsh int ip set address "Ethernet" static 192.168.137.2 255.255.255.0 192.168.137.1
netsh int ip set dns "Ethernet" static 8.8.8.8
netsh interface ipv4 show config
set-executionpolicy remotesigned
You may need to reboot the Pi at this point then test pinging 8.8.8.8 and google.com to make sure resolution is working. You should be all set!
One other thing, if you have a group policy on the machine that is restricting Internet Connection Sharing then take a look at this article to fix the issue. Note if your organization is constantly sending down the policy then you may have to re-enable Internet Connection Sharing often which is aggravating but at least it will work.
http://zizhujy.com/blog/post/2013/07/07/Solved-Internet-Connection-Sharing-has-been-disabled-by-the-Network-Administrator.aspx
I do this by creating a DHCP server on my laptop and connecting the Pi directly to it. I followed these instructions to get it working:
Download DHCP Server for Windows. It is a 100kB download.
Go to the IPv4 properties page of the Ethernet adapter and set a fixed IP address, say 192.168.2.1
Run the DHCP Server Wizard (downloaded above)
Select the Ethernet adapter from the list shown
Save the configuration file and start up the DHCP Server
Click the 'Continue as tray app' button in the server control panel.
Boot up the Raspberry Pi
A popup notification shows the IP address assigned by the DHCP server to the Raspberry Pi.
Use a SSH client, like PuTTy, to connect to the IP address shown
Hope this works!

Is there any way to find the ip address of all users in my LAN network?

Imagine that I am working in a corporate network in which all the computers are interconnected using private IPs. Is there any way to find the IP address of different users along with the username without contacting the sysadmin?
Use a scanner like nmap, this will get you all the IPs in your subnetwork.
As for the usernames.. not sure what usernames you're talking about, i think nmap can also give the hostname.
yes you can. if you are interested in IP and Hostname then angryscanner is more than enough
you can download it free and install it without admin privileges. however, if you want to get the usernames then it depends on the network. you need to clarify what usernames you are looking for ? the currently logged on? is your network workgroup ? or domain-based ?
for current logged on users
#echo off
for /f %%a in (pcList.txt) do (
echo ********************
echo Host: %%a
echo ********************
For /F "Tokens=2* Delims==\" %%i In (
'WMIC /Node:%%a ComputerSystem GET UserName /Value^|Find "="'
) Do Echo Current Logged in User ID for %%a is: %%j
)
echo ********************
echo Sweep is Complete
echo ********************
pause
this is a bat script (copy and paste in text file and rename to anything.bat)
now in the same folder you need to create a text file (pclist.txt) with all computers or IP addresses
for me I think using IP is very fast
get your network ip and subnet to discover the range of you local network
generate a list of all possible ips and copy-paste them to the text file

Resources