DHCP Setting in Mac OS X [closed] - macos

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Are there any command line interfaces to the DHCP settings in Mac OS X? I have found that inside System Profiler, the Network tab provides a lot of useful information, but I have not found any documentation about any command line equivalents.

You may use
networksetup -listallnetworkservices
networksetup -getinfo <networkservice>
networksetup -setdhcp <networkservice> [clientid]
networkservice is something like Ethernet (all availabe listed by the first command)

You can also use:
ipconfig getpacket `interface`
where interface would be en0, en1 etc.
ie:
ipconfig getpacket en1
op = BOOTREPLY
htype = 1
flags = 0
hlen = 6
hops = 0
xid = 215448168
secs = 3
ciaddr = 0.0.0.0
yiaddr = 192.168.15.121
siaddr = 0.0.0.0
giaddr = 0.0.0.0
chaddr = 0:19:e3:6:70:95
sname =
file =
options:
Options count is 8
dhcp_message_type (uint8): ACK 0x5
server_identifier (ip): 192.168.15.1
lease_time (uint32): 0xa8c0
subnet_mask (ip): 255.255.255.0
router (ip_mult): {192.168.15.1}
domain_name_server (ip_mult): {192.168.15.249, 192.168.15.240}
domain_name (string): domain.com
end (none):
You can also do:
ipconfig getoption en0 optionname
ie: ipconfig getoption en1 router
192.168.15.1

You should look at:
ifconfig(8)
netstat(1)
netintro(4)
The most important of these (netintro isn't actually a utility but rather introductory information on unix networking) is ifconfig which is the command line tool used to configure the various network interfaces you may have installed on your machine (like your ethernet card and your airport card) as well as any virtual interfaces (like your loopback address and things like parallels).

Related

What is this command prompt code in MacOS?

I know this code works on Windows, but how do I get workable code executable on MacOS?
netsh -c interface ipv4 add neighbors "(connection name)" "(router
address)" "(mac address)" store=persistent
Any suggestions please...
try typing "man arp" into the terminal. Something like this might work :
arp -s hostname ether_addr
Create an ARP entry for the host called hostname with the Ethernet address ether_addr. The Ethernet address is
given as six hex bytes separated by colons. The entry will be permanent unless the word temp is given in the
command. If the word pub is given, the entry will be ``published''; i.e., this system will act as an ARP server,
responding to requests for hostname even though the host address is not its own. In this case the ether_addr can
be given as auto in which case the interfaces on this host will be examined, and if one of them is found to
occupy the same subnet, its Ethernet address will be used. If the only keyword is also specified, this will cre-
ate a ``published (proxy only)'' entry. This type of entry is created automatically if arp detects that a rout-
ing table entry for hostname already exists.

Extract only MAC addresses from arp-scan -l

I want to collect only MAC addresses from arp-scan -l, omitting IP addresses and the devices name. How do we do it? I know that these in the middle column are all MAC addresses.
192.168.1.1 bc:98:89:47:20:f8 Fiberhome Telecommunication Technologies Co.,LTD
192.168.1.3 70:18:8b:5e:01:fd Hon Hai Precision Ind. Co.,Ltd.
192.168.1.5 90:e7:c4:da:80:76 HTC Corporation
192.168.1.6 b8:27:eb:b0:4d:25 Raspberry Pi Foundation
I want like this
bc:98:89:47:20:f8
70:18:8b:5e:01:fd
90:e7:c4:da:80:76
b8:27:eb:b0:4d:25
Edit:
arp-scan -l gives the following result
Interface: wlp5s0, datalink type: EN10MB (Ethernet)
Starting arp-scan 1.9.5 with 256 hosts (https://github.com/royhills/arp-scan)
192.168.1.1 bc:98:89:47:20:f8 Fiberhome Telecommunication Technologies Co.,LTD
192.168.1.5 90:e7:c4:da:80:76 HTC Corporation
192.168.1.3 70:18:8b:5e:01:fd Hon Hai Precision Ind. Co.,Ltd.
192.168.1.5 90:e7:c4:da:80:76 HTC Corporation (DUP: 2)
192.168.1.6 b8:27:eb:b0:4d:25 Raspberry Pi Foundation
192.168.1.6 b8:27:eb:b0:4d:25 Raspberry Pi Foundation (DUP: 2)
192.168.1.4 80:35:c1:4a:a5:dc (Unknown)
9 packets received by filter, 0 packets dropped by kernel
Ending arp-scan 1.9.5: 256 hosts scanned in 3.017 seconds (84.85 hosts/sec). 7 responded
I am assuming that you are using a linux-like shell and awk utility is installed( it is mostly pre-installed )-
arp-scan -l | awk '/.*:.*:.*:.*:.*:.*/{print $2}'
Learn basic Unix shell!
In particular the cut command can be used to extract columns from text. Set the field separator to space (probably default) and select the second field.
Using --plain option of arp-scan can make things easier. It will display plain output showing only responding hosts. The hosts' information are separated by tab, MAC address (2nd column) can be extracted easily through cut, as Anony-Mousse described:
arp-scan -l --plain | cut -f 2

Scapy Sniffer - Receiving RSSI

I am interested in getting the RSSI values if APs using a scapy sniffer. I am using sig_str = -(256-ord(packet.notdecoded[-4:-3]))
to get the RSSI values. However, I am getting -256 for all the APs. The notdecoded part is then 0. Could someone please help me figure this one out?
PS: I have already referenced this relevant post.
https://stackoverflow.com/a/34118234/4804221
TIA!
Prerequisite
Assuming the interface is in monitor mode, and correct channel assigned.
Following example configures iface=wlan0 to monitor mode and listens to channel=6
$ sudo ip link set wlan0 down
$ sudo iw dev wlan0 set type monitor
$ sudo ip link set wlan0 up
$ sudo iw dev wlan0 set channel 6
Python3
RSSI from a packet can be earned by dBm_AntSignal if RadioTap header is correctly sniffed together.
from scapy.all import RadioTap
from scapy.all import sniff
# sniff a packet from the interface
pkt = sniff(iface="wlan0", count=1)
pkt = pkt[0]
# getting the RSSI
radiotap = pkt.getlayer(RadioTap)
rssi = radiotap.dBm_AntSignal
print("RSSI={}".format(rssi)) # RSSI=-84
Python2
Seems like dBm_AntSignal is not working on python2 scapy, following example will work.
extra = pkt.notdecoded
rssi = -(256-ord(extra[-4:-3]))
Hope this helps.

Mac OS X Lion cannot resolve localhost [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I have found serval questions about this but no one helps for me, I am searching for
days to get my problem solved but I can't get it done, I hope someone can help
me with this big issue.
I try to ping my localhost, I need this to develop my web apps. I do this by zendServer.
This problem cames up when I upgraded my OS X to Lion.
I use internet over Apple timecapsule but I think this doesn't matter to make it able to use your localhost?
Host file (sudo nano /private/etc/hosts):
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
Dig result:
leny-pc:~ nickyklaasse$ dig localhost
; <<>> DiG 9.7.3-P3 <<>> localhost
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 18908
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;localhost. IN A
;; ANSWER SECTION:
localhost. 10800 IN A 127.0.0.1
;; Query time: 20 msec
;; SERVER: 192.168.1.254#53(192.168.1.254)
;; WHEN: Thu Dec 1 13:08:07 2011
;; MSG SIZE rcvd: 43
Host result:
leny-pc:~ nickyklaasse$ host localhost
localhost has address 127.0.0.1
localhost has IPv6 address ::1
Ping result:
leny-pc:~ nickyklaasse$ ping localhost
ping: cannot resolve localhost: Unknown host
I hope some one can help me to an answer.
With kind regards,
Nicky
Comment this 2 lines and try again:
::1 localhost
fe80::1%lo0 localhost
and let me know what happen
Resolved by a clean new installation of Mac Os Lion by DVD

how to know 2 lan pc is connetced with my program in php?

I have 4 PCs which are connected through the LAN. I am making a PHP program that will
differentiate each PC separately and i will keep each pc record.
But when i am getting an IP address i am getting same IP for all. I guess i should retrieve MAC address for all pcs separately, but i don't know how will i fetch MAC address.
I am using Linux OS.
Programing tips will be appreciated.
As far as I know, you cannot do this with PHP alone. However, if you have exec() rights on the server, the you might be able to use:
arp -a ipaddress
Where ipaddress is the IP address of the computer on your LAN. You would need to use something like regex to seperate the MAC address from the rest of the output.
I don't think that the mac-adress is included in the http-header. So it is probably hard to get it via php. I think you're better off trying to fix the ip-issue. Sorry I can't help you more.
Edit:
Actually... searching around a little I found a possible solution:
$mac = `ping -c 1 $ip && arp -a | grep $ip`
You probably have to parse the output though. I get:
xxx.xxx.local (192.168.0.10) at d5:c2:c3:13:a2:b1 [ether] on eth0
When doing arp -a 192.168.0.10
Edit:
Like the post under states, you would need exec-rights.
Edit:
Sorry, just realized that in order for this to work, you would need the ip... Which you don't have.
PEAR’s Net_Ping is a niffty wrapper class for executing ping calls from PHP. You can use it to check if a remote server is responding correctly. The library can be download from here.
pear install Net_Ping-2.4.4
<?php
require_once "Net/Ping.php";
$ping = Net_Ping::factory();
if(PEAR::isError($ping))
echo $ping->getMessage();
else
{
/* Number of packets to send */
$ping->setArgs(array('count' => 4));
$rawData = $ping->ping('google.com');
print_r($rawData);
}
?>

Resources