Set MTU in Win XP from the command line - command-line

I want to set MTU from the command line. I'm running under XP.
I've tried:
netsh interface ipv4 set subinterface "Local Area Connection" mtu=1300 store=persistent
But it's not working.
I've tried to change "ipv4" to "ip" but it didn't help. The token "subinterface" is not recognized.
Any ideas?
Thanks in advance.

You can set the MTU in Windows XP via command line in this format:
netsh interface ipv4 set subinterface "Local Area Connection" mtu=1300 store=persistent
As per http://my.bergersoft.net/2010/05/13/how-to-change-mtu-size-on-windows-xpvista72008/

Related

Why does this Powershell subexpression operator command not work?

I am trying to understand why a Powershell one liner I want to use to setup a port proxy to a WSL instance seemingly does not work, but running it without the grouping/substitution does work. Steps:
Get the IP address of WSL instance:
wsl hostname -I
> 172.18.108.185
Try one liner with the previous command as subexpression:
netsh interface portproxy add v4tov4 listenport=3443 `
listenaddress=0.0.0.0 connectport=3443 `
connectaddress=$(wsl hostname -I)
That seems to work because listing port proxies shows it:
netsh interface portproxy show v4tov4
> Listen on ipv4: Connect to ipv4:
>
> Address Port Address Port
> --------------- ---------- --------------- ----------
> 0.0.0.0 3443 172.18.108.185 3443
(I have also tried it without the $.)
However, the proxy forwarding does not actually work.
If I then do the same command without the substitution:
netsh interface portproxy add v4tov4 listenport=3443 `
listenaddress=0.0.0.0 connectport=3443 `
connectaddress=172.18.108.185
The output looks exactly the same:
netsh interface portproxy show v4tov4
> Listen on ipv4: Connect to ipv4:
>
> Address Port Address Port
> --------------- ---------- --------------- ----------
> 0.0.0.0 3443 172.18.108.185 3443
However, this time it works.
What is different between these two executions such that one works, one doesn't, and yet the results look exactly the same?
Abraham Zinala provided the crucial pointer:
The output from wsl hostname -I - surprisingly - has a trailing space, which must be trimmed in order for the IP address represented by the output to be used as an argument passed to netsh:
netsh interface portproxy add v4tov4 listenport=3443 `
listenaddress=0.0.0.0 connectport=3443 `
connectaddress=$((wsl hostname -I).Trim())

Updating MAC Address in a DHCP reservation removes other variables

i have an odd issue for when i run this command:
Set-DhcpServerv4Reservation -computer name -ip 1.1.1.1 -clientid macaddress
it removes a few other variables, such as "root path". when I run get-dhcpreservation on an IP that has all of its variables set, "root path" is not something it returns, and it is not something that I can set with powershell -- plus, i'd rather it not be removed.
are there any other methods to update a dhcp reservations mac address?
after fiddling around with Set-DhcpServerv4Reservation there is really no way to set the mac address with that command without deleting option values that are set, such as iscsi targets. there is also seemingl
the fix was using Get-DhcpServerv4OptionValue to store what would be deleted as a variable, use set-dhcpserver4reservation to set the MAC address, then use set-dhcpserverv4optionvalue to add back what was deleted.
not the most ideal solution but i was successfully able to update the mac address while preserving everything that the command was deleting.

ssh_init: Network error: Cannot assign requested address

I am trying to set up a connection and transfer files using putty on a windows 10 platform. I have verified that the default port in putty is 22. When I run the command in the command line to connect and transfer files though I get the above error. Any idea why this is or what I should do?
Did you try:
pscp -P 22 c:\documents\foo.txt user#example.com:/tmp/foo
I had to go into the Putty Default Settings and "Save" them again, despite port 22 showing as the default. Worked for me to avoid adding the -P 22 option every time.
I had the same error and ended up at this page. The -P 22 did not solve my problem.
I use Putty saved sessions and double checked my command line and had the same error as the OP.
I was using:
pscp -l SESSION_NAME_IN_PUTTY ip:/remote_path local_path
I reviewed the command line options for pscp and changed the -l to -load and it worked.
The final command looked like:
pscp -load SESSION_NAME_IN_PUTTY ip:/remote_path local_path
Note: If you still have the error, please review your spelling of SESSION_NAME_IN_PUTTY and ensure it is an exact match. One letter off, can cause the same error.
In my case I had created a shortened "session name" in Putty -- that is, a shorter representation of the full hostname. This worked for most Putty functions -- but when I tried to use pscp I found that I needed to have a session name that was identical to the hostname.
I'm my case I was hitting this error because SSH was not enabled in Raspbian.

How to change & verify hostname in windows server 2012 (AWS EC2)

I am using Windows Server 2012-R2 (amazon ec2) machine.
and I want to change and verify hostname in it. I checked on net and found hostname command. But when I run hostname or hostname -i command I get following error..
sethostname: Use the Network Control Panel Applet to set hostname.
hostname -s is not supported.
I further googled this problem and apparently this command is not usable on windows 2012-r2 servers. Is there any alternative or workaround command that can do the job for me??
On windows the computer name is also often referred to as hostname. However this creates some confusion. Some people use the term hostname to refer to the leftmost part of domain name which can only be set on a DNS server. However another meaning of a hostname is just an arbitrary label assigned to a machine on a computer network, and this can be directly changed on the specific machine.
There are several ways to change the computer name from the command line on windows 2012:
Method 1. Open cmd and type:
SCONFIG and you will get selection menu where #2 says Computer Name:
Method 2. From cmd type:
netdom renamecomputer %computername% /newname:<NewName> /reboot:0
Method 3. From the PowerShell console:
netdom renamecomputer $env:computername /newname:<NewName> /reboot:0
To verify the name form cmd type:
nbtstat -A xxx.xxx.xxx.xxx (where x is the ip address)
Another way to verify the name form cmd just type "hostname" without any parameters:
hostname

Get IP ADDRESS from MAC ADDRESS for Printers

Is it possible to get IP from MAC Address of printer.
I have got MAC address and want to know what IP is assigned to it via DHCP server.
I tried the below query and it does give me all the IP address in scope but I need to be able to search for the one I am looking for.
netsh dhcp server \\DHCP server scope 10.65.22.0 show clients 1
I tried using Where {$_.uniqueID -like "002128903a09"} but it does not seems to like it.
Thanks
So netsh is an external application, and will return a bunch of text, but not objects, so you can't check a property (like $_.uniqueID) using a Where statement. You have two options here, you can search for the line of text that has your MAC and consume the whole line, or you can parse the text and convert it to objects. I am not familiar with the results that get spit out when you run that command, so if you want to give a sample of that (update your question to include it, don't put it in a comment), I can probably help you parse the text into objects, or just search it for a MAC address.
Or, one option would be to pipe the command into the Select-String cmdlet, and have that search for your MAC address.
$MACAddr = ("002128903a09" -split "(..)"|?{$_}) -join "-"
netsh dhcp server \\DHCP server scope 10.65.22.0 show clients 1 | Select-String -SimpleMatch $MACAddr
I believe that will at least find the line that has your MAC, and you can get the IP from there.
Edit: Updated with MAC Address formatting corrected, thanks to #JanChrbolka for helping me with the correct format!